List of usage examples for org.bouncycastle.asn1.x509.qualified SemanticsInformation getNameRegistrationAuthorities
public GeneralName[] getNameRegistrationAuthorities()
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 2 s . c om 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(); }
From source file:org.cesecore.certificates.util.cert.QCStatementExtension.java
License:Open Source License
/** Returns the 'NameRegistrationAuthorities' defined in the QCStatement extension (rfc3739). * /* w ww . j a v a2 s . c o m*/ * @param cert Certificate containing the extension * @return String with for example 'rfc822Name=foo2bar.se, rfc822Name=bar2foo.se' etc. Supports email, dns and uri name, or null of no RAs are found. * @throws IOException if there is a problem parsing the certificate */ public static String getQcStatementAuthorities(final Certificate cert) throws IOException { String ret = null; if (cert instanceof X509Certificate) { final X509Certificate x509cert = (X509Certificate) cert; final ASN1Primitive obj = getExtensionValue(x509cert, Extension.qCStatements.getId()); if (obj == null) { return null; } final ASN1Sequence seq = (ASN1Sequence) obj; SemanticsInformation si = null; // Look through all the QCStatements and see if we have a standard RFC3739 pkixQCSyntax for (int i = 0; i < seq.size(); i++) { final QCStatement qc = QCStatement.getInstance(seq.getObjectAt(i)); final ASN1ObjectIdentifier oid = qc.getStatementId(); if ((oid != null) && (oid.equals(RFC3739QCObjectIdentifiers.id_qcs_pkixQCSyntax_v1) || oid.equals(RFC3739QCObjectIdentifiers.id_qcs_pkixQCSyntax_v2))) { // We MAY have a SemanticsInformation object here final ASN1Encodable enc = qc.getStatementInfo(); if (enc != null) { si = SemanticsInformation.getInstance(enc); // We can break the loop now, we got it! break; } } } if (si != null) { final GeneralName[] gns = si.getNameRegistrationAuthorities(); if (gns == null) { return null; } final StringBuilder strBuf = new StringBuilder(); for (int i = 0; i < gns.length; i++) { final GeneralName gn = gns[i]; if (strBuf.length() != 0) { // Append comma so we get nice formatting if there are more than one authority strBuf.append(", "); } final String str = getGeneralNameString(gn.getTagNo(), gn.getName()); if (str != null) { strBuf.append(str); } } if (strBuf.length() > 0) { ret = strBuf.toString(); } } } return ret; }
From source file:org.ejbca.util.cert.QCStatementExtension.java
License:Open Source License
/** Returns the 'NameRegistrationAuthorities' defined in the QCStatement extension (rfc3739). * /* w w w. j a v a2s. co m*/ * @param cert Certificate containing the extension * @return String with for example 'rfc822Name=foo2bar.se, rfc822Name=bar2foo.se' etc. Supports email, dns and uri name, or null of no RAs are found. * @throws IOException if there is a problem parsing the certificate */ public static String getQcStatementAuthorities(final Certificate cert) throws IOException { String ret = null; if (cert instanceof X509Certificate) { final X509Certificate x509cert = (X509Certificate) cert; final DERObject obj = getExtensionValue(x509cert, X509Extensions.QCStatements.getId()); if (obj == null) { return null; } final ASN1Sequence seq = (ASN1Sequence) obj; SemanticsInformation si = null; // Look through all the QCStatements and see if we have a standard RFC3739 pkixQCSyntax for (int i = 0; i < seq.size(); i++) { final QCStatement qc = QCStatement.getInstance(seq.getObjectAt(i)); final DERObjectIdentifier oid = qc.getStatementId(); if ((oid != null) && (oid.equals(RFC3739QCObjectIdentifiers.id_qcs_pkixQCSyntax_v1) || oid.equals(RFC3739QCObjectIdentifiers.id_qcs_pkixQCSyntax_v2))) { // We MAY have a SemanticsInformation object here final ASN1Encodable enc = qc.getStatementInfo(); if (enc != null) { si = SemanticsInformation.getInstance(enc); // We can break the loop now, we got it! break; } } } if (si != null) { final GeneralName[] gns = si.getNameRegistrationAuthorities(); if (gns == null) { return null; } final StringBuilder strBuf = new StringBuilder(); for (int i = 0; i < gns.length; i++) { final GeneralName gn = gns[i]; if (strBuf.length() != 0) { // Append comma so we get nice formatting if there are more than one authority strBuf.append(", "); } final String str = getGeneralNameString(gn.getTagNo(), gn.getName()); if (str != null) { strBuf.append(str); } } if (strBuf.length() > 0) { ret = strBuf.toString(); } } } return ret; }