Search in sources :

Example 6 with AdmissionSyntax

use of org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax in project xipki by xipki.

the class XmlX509Certprofile method initAdmission.

private void initAdmission(Set<ASN1ObjectIdentifier> extnIds, ExtensionsType extensionsType) throws CertprofileException {
    ASN1ObjectIdentifier type = ObjectIdentifiers.id_extension_admission;
    if (!extensionControls.containsKey(type)) {
        return;
    }
    extnIds.remove(type);
    AdmissionSyntax extConf = (AdmissionSyntax) getExtensionValue(type, extensionsType, AdmissionSyntax.class);
    if (extConf == null) {
        return;
    }
    this.admission = XmlX509CertprofileUtil.buildAdmissionSyntax(extensionControls.get(type).isCritical(), extConf);
}
Also used : AdmissionSyntax(org.xipki.ca.certprofile.x509.jaxb.AdmissionSyntax) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 7 with AdmissionSyntax

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

the class X509Ext method getAdmissionStringValue.

private String getAdmissionStringValue(byte[] octets) throws IOException {
    // @formatter:off
    /*
			 AdmissionSyntax ::= SEQUENCE
		     {
		       admissionAuthority GeneralName OPTIONAL,
		       contentsOfAdmissions SEQUENCE OF Admissions
		     }
		     Admissions ::= SEQUENCE
		     {
		       admissionAuthority [0] EXPLICIT GeneralName OPTIONAL
		       namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL
		       professionInfos SEQUENCE OF ProfessionInfo
		     }
		     NamingAuthority ::= SEQUENCE
		     {
		       namingAuthorityId OBJECT IDENTIFIER OPTIONAL,
		       namingAuthorityUrl IA5String OPTIONAL,
		       namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL
		     }
		     ProfessionInfo ::= SEQUENCE
		     {
		       namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
		       professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
		       professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
		       registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
		       addProfessionInfo OCTET STRING OPTIONAL
		     }
		 */
    // @formatter:on
    StringBuilder sb = new StringBuilder();
    int indentLevel = 1;
    AdmissionSyntax admissionSyntax = AdmissionSyntax.getInstance(ASN1Sequence.getInstance(octets));
    GeneralName admissionAuthority = admissionSyntax.getAdmissionAuthority();
    if (admissionAuthority != null) {
        sb.append(MessageFormat.format(res.getString("Admission.AdmissionAuthority"), GeneralNameUtil.toString(admissionAuthority)));
        sb.append(NEWLINE);
    }
    Admissions[] admissions = admissionSyntax.getContentsOfAdmissions();
    int admissionNr = 0;
    for (Admissions admission : admissions) {
        sb.append(MessageFormat.format(res.getString("Admission.Admission"), ++admissionNr));
        sb.append(NEWLINE);
        admissionAuthority = admission.getAdmissionAuthority();
        NamingAuthority namingAuthority = admission.getNamingAuthority();
        ProfessionInfo[] professionInfos = admission.getProfessionInfos();
        if (admissionAuthority != null) {
            sb.append(INDENT.toString(indentLevel));
            sb.append(MessageFormat.format(res.getString("Admission.AdmissionAuthority"), GeneralNameUtil.toString(admissionAuthority)));
            sb.append(NEWLINE);
        }
        if (namingAuthority != null) {
            sb.append(getNamingAuthorityStringValue(namingAuthority, indentLevel));
        }
        for (ProfessionInfo professionInfo : professionInfos) {
            namingAuthority = professionInfo.getNamingAuthority();
            ASN1ObjectIdentifier[] professionOIDs = professionInfo.getProfessionOIDs();
            String registrationNumber = professionInfo.getRegistrationNumber();
            ASN1OctetString addProfessionInfo = professionInfo.getAddProfessionInfo();
            sb.append(INDENT.toString(indentLevel));
            sb.append(res.getString("Admission.ProfessionInfo"));
            sb.append(NEWLINE);
            indentLevel++;
            if (namingAuthority != null) {
                sb.append(getNamingAuthorityStringValue(namingAuthority, indentLevel));
            }
            DirectoryString[] professionItems = professionInfo.getProfessionItems();
            for (DirectoryString professionItem : professionItems) {
                sb.append(INDENT.toString(indentLevel));
                sb.append(MessageFormat.format(res.getString("Admission.ProfessionItem"), professionItem.toString()));
                sb.append(NEWLINE);
            }
            if (professionOIDs != null) {
                for (ASN1ObjectIdentifier professionOID : professionOIDs) {
                    sb.append(INDENT.toString(indentLevel));
                    sb.append(MessageFormat.format(res.getString("Admission.ProfessionOID"), professionOID.getId()));
                    sb.append(NEWLINE);
                }
            }
            if (registrationNumber != null) {
                sb.append(INDENT.toString(indentLevel));
                sb.append(MessageFormat.format(res.getString("Admission.RegistrationNumber"), registrationNumber));
                sb.append(NEWLINE);
            }
            if (addProfessionInfo != null) {
                sb.append(INDENT.toString(indentLevel));
                sb.append(MessageFormat.format(res.getString("Admission.AddProfessionInfo"), HexUtil.getHexString(addProfessionInfo.getOctets())));
                sb.append(NEWLINE);
            }
            indentLevel--;
        }
    }
    return sb.toString();
}
Also used : ASN1OctetString(org.bouncycastle.asn1.ASN1OctetString) 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) IssuingDistributionPoint(org.bouncycastle.asn1.x509.IssuingDistributionPoint) CRLDistPoint(org.bouncycastle.asn1.x509.CRLDistPoint) DistributionPoint(org.bouncycastle.asn1.x509.DistributionPoint) AdmissionSyntax(org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax) Admissions(org.bouncycastle.asn1.isismtt.x509.Admissions) NamingAuthority(org.bouncycastle.asn1.isismtt.x509.NamingAuthority) GeneralName(org.bouncycastle.asn1.x509.GeneralName) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) ProfessionInfo(org.bouncycastle.asn1.isismtt.x509.ProfessionInfo)

Aggregations

ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)5 LinkedList (java.util.LinkedList)3 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)3 AdmissionSyntax (org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax)3 Admissions (org.bouncycastle.asn1.isismtt.x509.Admissions)3 ProfessionInfo (org.bouncycastle.asn1.isismtt.x509.ProfessionInfo)3 DirectoryString (org.bouncycastle.asn1.x500.DirectoryString)3 GeneralName (org.bouncycastle.asn1.x509.GeneralName)3 AdmissionSyntax (org.xipki.ca.certprofile.x509.jaxb.AdmissionSyntax)3 AdmissionsType (org.xipki.ca.certprofile.x509.jaxb.AdmissionsType)3 ProfessionInfoType (org.xipki.ca.certprofile.x509.jaxb.ProfessionInfoType)3 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)2 DEROctetString (org.bouncycastle.asn1.DEROctetString)2 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)2 DERSequence (org.bouncycastle.asn1.DERSequence)2 NamingAuthority (org.bouncycastle.asn1.isismtt.x509.NamingAuthority)2 ExtensionType (org.xipki.ca.certprofile.x509.jaxb.ExtensionType)2 ExtensionValueType (org.xipki.ca.certprofile.x509.jaxb.ExtensionValueType)2 ExtensionsType (org.xipki.ca.certprofile.x509.jaxb.ExtensionsType)2 KeyUsageEnum (org.xipki.ca.certprofile.x509.jaxb.KeyUsageEnum)2