Search in sources :

Example 1 with NamingAuthority

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

the class XmlX509CertprofileUtil method buildNamingAuthority.

private static NamingAuthority buildNamingAuthority(NamingAuthorityType jaxb) {
    ASN1ObjectIdentifier oid = (jaxb.getOid() == null) ? null : new ASN1ObjectIdentifier(jaxb.getOid().getValue());
    String url = StringUtil.isBlank(jaxb.getUrl()) ? null : jaxb.getUrl();
    DirectoryString text = StringUtil.isBlank(jaxb.getText()) ? null : new DirectoryString(jaxb.getText());
    return new NamingAuthority(oid, url, text);
}
Also used : NamingAuthority(org.bouncycastle.asn1.isismtt.x509.NamingAuthority) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 2 with NamingAuthority

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

the class XmlX509CertprofileUtil method buildAdmissionSyntax.

public static AdmissionSyntaxOption buildAdmissionSyntax(boolean critical, AdmissionSyntax type) throws CertprofileException {
    List<AdmissionsOption> admissionsList = new LinkedList<>();
    for (AdmissionsType at : type.getContentsOfAdmissions()) {
        List<ProfessionInfoOption> professionInfos = new LinkedList<>();
        for (ProfessionInfoType pi : at.getProfessionInfo()) {
            NamingAuthority namingAuthorityL3 = null;
            if (pi.getNamingAuthority() != null) {
                namingAuthorityL3 = buildNamingAuthority(pi.getNamingAuthority());
            }
            List<OidWithDescType> oidTypes = pi.getProfessionOid();
            List<ASN1ObjectIdentifier> oids = null;
            if (CollectionUtil.isNonEmpty(oidTypes)) {
                oids = new LinkedList<>();
                for (OidWithDescType k : oidTypes) {
                    oids.add(new ASN1ObjectIdentifier(k.getValue()));
                }
            }
            RegistrationNumber rnType = pi.getRegistrationNumber();
            RegistrationNumberOption rno = (rnType == null) ? null : new RegistrationNumberOption(rnType.getRegex(), rnType.getConstant());
            ProfessionInfoOption pio = new ProfessionInfoOption(namingAuthorityL3, pi.getProfessionItem(), oids, rno, pi.getAddProfessionInfo());
            professionInfos.add(pio);
        }
        GeneralName admissionAuthority = null;
        if (at.getNamingAuthority() != null) {
            admissionAuthority = GeneralName.getInstance(asn1PrimitivefromByteArray(at.getAdmissionAuthority()));
        }
        NamingAuthority namingAuthority = null;
        if (at.getNamingAuthority() != null) {
            namingAuthority = buildNamingAuthority(at.getNamingAuthority());
        }
        AdmissionsOption admissionsOption = new AdmissionsOption(admissionAuthority, namingAuthority, professionInfos);
        admissionsList.add(admissionsOption);
    }
    GeneralName admissionAuthority = null;
    if (type.getAdmissionAuthority() != null) {
        admissionAuthority = GeneralName.getInstance(type.getAdmissionAuthority());
    }
    return new AdmissionSyntaxOption(critical, admissionAuthority, admissionsList);
}
Also used : ProfessionInfoOption(org.xipki.ca.certprofile.commonpki.ProfessionInfoOption) OidWithDescType(org.xipki.ca.certprofile.x509.jaxb.OidWithDescType) AdmissionsOption(org.xipki.ca.certprofile.commonpki.AdmissionsOption) RegistrationNumberOption(org.xipki.ca.certprofile.commonpki.RegistrationNumberOption) AdmissionSyntaxOption(org.xipki.ca.certprofile.commonpki.AdmissionSyntaxOption) LinkedList(java.util.LinkedList) AdmissionsType(org.xipki.ca.certprofile.x509.jaxb.AdmissionsType) ProfessionInfoType(org.xipki.ca.certprofile.x509.jaxb.ProfessionInfoType) NamingAuthority(org.bouncycastle.asn1.isismtt.x509.NamingAuthority) RegistrationNumber(org.xipki.ca.certprofile.x509.jaxb.ProfessionInfoType.RegistrationNumber) GeneralName(org.bouncycastle.asn1.x509.GeneralName) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 3 with NamingAuthority

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

the class X509Ext method getNamingAuthorityStringValue.

private String getNamingAuthorityStringValue(NamingAuthority namingAuthority, int indentLevel) throws IOException {
    // @formatter:off
    /*
		     NamingAuthority ::= SEQUENCE
		     {
		       namingAuthorityId OBJECT IDENTIFIER OPTIONAL,
		       namingAuthorityUrl IA5String OPTIONAL,
		       namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL
		     }
		 */
    // @formatter:on
    StringBuilder sb = new StringBuilder();
    ASN1ObjectIdentifier namingAuthorityId = namingAuthority.getNamingAuthorityId();
    String namingAuthorityUrl = namingAuthority.getNamingAuthorityUrl();
    DirectoryString namingAuthorityText = namingAuthority.getNamingAuthorityText();
    if (namingAuthorityId != null) {
        sb.append(INDENT.toString(indentLevel));
        sb.append(MessageFormat.format(res.getString("Admission.NamingAuthorityOID"), namingAuthorityId.getId()));
        sb.append(NEWLINE);
    }
    if (namingAuthorityUrl != null) {
        sb.append(INDENT.toString(indentLevel));
        sb.append(MessageFormat.format(res.getString("Admission.NamingAuthorityURL"), namingAuthorityUrl));
        sb.append(NEWLINE);
    }
    if (namingAuthorityText != null) {
        sb.append(INDENT.toString(indentLevel));
        sb.append(MessageFormat.format(res.getString("Admission.NamingAuthorityText"), namingAuthorityText.toString()));
        sb.append(NEWLINE);
    }
    return sb.toString();
}
Also used : 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) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 4 with NamingAuthority

use of org.bouncycastle.asn1.isismtt.x509.NamingAuthority 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)4 NamingAuthority (org.bouncycastle.asn1.isismtt.x509.NamingAuthority)3 DirectoryString (org.bouncycastle.asn1.x500.DirectoryString)3 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)2 DERBMPString (org.bouncycastle.asn1.DERBMPString)2 DERBitString (org.bouncycastle.asn1.DERBitString)2 DERGeneralString (org.bouncycastle.asn1.DERGeneralString)2 DERIA5String (org.bouncycastle.asn1.DERIA5String)2 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)2 GeneralName (org.bouncycastle.asn1.x509.GeneralName)2 LinkedList (java.util.LinkedList)1 AdmissionSyntax (org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax)1 Admissions (org.bouncycastle.asn1.isismtt.x509.Admissions)1 ProfessionInfo (org.bouncycastle.asn1.isismtt.x509.ProfessionInfo)1 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)1 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)1 IssuingDistributionPoint (org.bouncycastle.asn1.x509.IssuingDistributionPoint)1 AdmissionSyntaxOption (org.xipki.ca.certprofile.commonpki.AdmissionSyntaxOption)1 AdmissionsOption (org.xipki.ca.certprofile.commonpki.AdmissionsOption)1 ProfessionInfoOption (org.xipki.ca.certprofile.commonpki.ProfessionInfoOption)1