Search in sources :

Example 1 with ProcurationSyntax

use of org.bouncycastle.asn1.isismtt.x509.ProcurationSyntax in project keystore-explorer by kaikramer.

the class X509Ext method getProcurationStringValue.

private String getProcurationStringValue(byte[] octets) throws IOException {
    // @formatter:off
    /*
			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();
}
Also used : IssuerSerial(org.bouncycastle.asn1.x509.IssuerSerial) ProcurationSyntax(org.bouncycastle.asn1.isismtt.x509.ProcurationSyntax) DERBitString(org.bouncycastle.asn1.DERBitString) ASN1OctetString(org.bouncycastle.asn1.ASN1OctetString) DERBMPString(org.bouncycastle.asn1.DERBMPString) DERGeneralString(org.bouncycastle.asn1.DERGeneralString) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) DERPrintableString(org.bouncycastle.asn1.DERPrintableString) DERIA5String(org.bouncycastle.asn1.DERIA5String) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) GeneralName(org.bouncycastle.asn1.x509.GeneralName)

Aggregations

ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)1 DERBMPString (org.bouncycastle.asn1.DERBMPString)1 DERBitString (org.bouncycastle.asn1.DERBitString)1 DERGeneralString (org.bouncycastle.asn1.DERGeneralString)1 DERIA5String (org.bouncycastle.asn1.DERIA5String)1 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)1 ProcurationSyntax (org.bouncycastle.asn1.isismtt.x509.ProcurationSyntax)1 DirectoryString (org.bouncycastle.asn1.x500.DirectoryString)1 GeneralName (org.bouncycastle.asn1.x509.GeneralName)1 IssuerSerial (org.bouncycastle.asn1.x509.IssuerSerial)1