Example usage for org.bouncycastle.asn1.x509.qualified SemanticsInformation getSemanticsIdentifier

List of usage examples for org.bouncycastle.asn1.x509.qualified SemanticsInformation getSemanticsIdentifier

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.x509.qualified SemanticsInformation getSemanticsIdentifier.

Prototype

public ASN1ObjectIdentifier getSemanticsIdentifier() 

Source Link

Usage

From source file:net.sf.keystore_explorer.crypto.x509.X509Ext.java

License:Open Source License

private String getSemanticInformationValueString(QcStatementType qcStatementType,
        SemanticsInformation semanticsInfo, int baseIndentLevel) throws IOException {

    // @formatter:off

    /*/* w w w  .  j a  v  a 2s . co  m*/
    SemanticsInformation ::= SEQUENCE
    {
       semanticsIdentifier OBJECT IDENTIFIER OPTIONAL,
       nameRegistrationAuthorities NameRegistrationAuthorities OPTIONAL
    }
    NameRegistrationAuthorities ::= SEQUENCE SIZE(1..MAX) OF GeneralName
     */

    // @formatter:on

    ASN1ObjectIdentifier semanticsIdentifier = semanticsInfo.getSemanticsIdentifier();
    GeneralName[] nameRegistrationAuthorities = semanticsInfo.getNameRegistrationAuthorities();

    StringBuilder sb = new StringBuilder();

    sb.append(INDENT.toString(baseIndentLevel));
    if (qcStatementType == QcStatementType.QC_SYNTAX_V1) {
        sb.append(res.getString(QcStatementType.QC_SYNTAX_V1.getResKey()));
    } else {
        sb.append(res.getString(QcStatementType.QC_SYNTAX_V2.getResKey()));
    }
    sb.append(NEWLINE);

    if (semanticsIdentifier != null) {
        sb.append(INDENT.toString(baseIndentLevel + 1));
        sb.append(MessageFormat.format(res.getString("QCSyntax.SemanticsIdentifier"),
                semanticsIdentifier.getId()));
        sb.append(NEWLINE);
    }

    if (nameRegistrationAuthorities != null) {
        sb.append(INDENT.toString(baseIndentLevel + 1));
        sb.append(res.getString("QCSyntax.NameRegistrationAuthorities"));
        sb.append(NEWLINE);

        for (GeneralName nameRegistrationAuthority : nameRegistrationAuthorities) {
            sb.append(INDENT.toString(baseIndentLevel + 2));
            sb.append(GeneralNameUtil.toString(nameRegistrationAuthority));
            sb.append(NEWLINE);
        }
    }

    return sb.toString();
}