Example usage for org.bouncycastle.asn1.isismtt.x509 ProcurationSyntax getCountry

List of usage examples for org.bouncycastle.asn1.isismtt.x509 ProcurationSyntax getCountry

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.isismtt.x509 ProcurationSyntax getCountry.

Prototype

public String getCountry() 

Source Link

Usage

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

License:Open Source License

private String getProcurationStringValue(byte[] octets) throws IOException {

    // @formatter:off

    /*// w w w .  j a v a 2 s  .  co m
       ProcurationSyntax ::= SEQUENCE
       {
    country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL,
    typeOfSubstitution [2] EXPLICIT DirectoryString(SIZE(1..128)) OPTIONAL,
    signingFor [3] EXPLICIT SigningFor
       }
            
       SigningFor ::= CHOICE
       {
    thirdPerson GeneralName,
    certRef IssuerSerial
       }
     */

    // @formatter:on

    StringBuilder sb = new StringBuilder();

    ProcurationSyntax procurationSyntax = ProcurationSyntax.getInstance(octets);
    String country = procurationSyntax.getCountry();
    DirectoryString typeOfSubstitution = procurationSyntax.getTypeOfSubstitution();
    GeneralName thirdPerson = procurationSyntax.getThirdPerson();
    IssuerSerial certRef = procurationSyntax.getCertRef();

    if (country != null) {
        sb.append(MessageFormat.format(res.getString("Procuration.Country"), country));
        sb.append(NEWLINE);
    }

    if (typeOfSubstitution != null) {
        sb.append(MessageFormat.format(res.getString("Procuration.TypeOfSubstitution"),
                typeOfSubstitution.toString()));
        sb.append(NEWLINE);
    }

    if (thirdPerson != null) {
        sb.append(MessageFormat.format(res.getString("Procuration.ThirdPerson"),
                GeneralNameUtil.toString(thirdPerson)));
        sb.append(NEWLINE);
    }

    if (certRef != null) {
        sb.append(res.getString("Procuration.CertRef"));
        sb.append(NEWLINE);

        sb.append(INDENT);
        sb.append(res.getString("Procuration.CertRef.Issuer"));
        for (GeneralName generalName : certRef.getIssuer().getNames()) {
            sb.append(INDENT);
            sb.append(INDENT);
            sb.append(GeneralNameUtil.toString(generalName));
            sb.append(NEWLINE);
        }
        sb.append(NEWLINE);

        sb.append(INDENT);
        sb.append(MessageFormat.format(res.getString("Procuration.CertRef.SN"),
                HexUtil.getHexString(certRef.getSerial().getValue())));
        sb.append(NEWLINE);
    }

    return sb.toString();
}