Java Code Examples for org.bouncycastle.asn1.DERIA5String#getInstance()

The following examples show how to use org.bouncycastle.asn1.DERIA5String#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OCSPCertificateVerifier.java    From oxAuth with MIT License 5 votes vote down vote up
@SuppressWarnings({ "deprecation", "resource" })
private String getOCSPUrl(X509Certificate certificate) throws IOException {
	ASN1Primitive obj;
	try {
		obj = getExtensionValue(certificate, Extension.authorityInfoAccess.getId());
	} catch (IOException ex) {
		log.error("Failed to get OCSP URL", ex);
		return null;
	}

	if (obj == null) {
		return null;
	}

	AuthorityInformationAccess authorityInformationAccess = AuthorityInformationAccess.getInstance(obj);

	AccessDescription[] accessDescriptions = authorityInformationAccess.getAccessDescriptions();
	for (AccessDescription accessDescription : accessDescriptions) {
		boolean correctAccessMethod = accessDescription.getAccessMethod().equals(X509ObjectIdentifiers.ocspAccessMethod);
		if (!correctAccessMethod) {
			continue;
		}

		GeneralName name = accessDescription.getAccessLocation();
		if (name.getTagNo() != GeneralName.uniformResourceIdentifier) {
			continue;
		}

		DERIA5String derStr = DERIA5String.getInstance((ASN1TaggedObject) name.toASN1Primitive(), false);
		return derStr.getString();
	}

	return null;

}
 
Example 2
Source File: CRLCertificateVerifier.java    From oxAuth with MIT License 5 votes vote down vote up
public String getCrlUri(X509Certificate certificate) throws IOException {
	ASN1Primitive obj;
	try {
		obj = getExtensionValue(certificate, Extension.cRLDistributionPoints.getId());
	} catch (IOException ex) {
		log.error("Failed to get CRL URL", ex);
		return null;
	}

	if (obj == null) {
		return null;
	}

	CRLDistPoint distPoint = CRLDistPoint.getInstance(obj);

	DistributionPoint[] distributionPoints = distPoint.getDistributionPoints();
	for (DistributionPoint distributionPoint : distributionPoints) {
		DistributionPointName distributionPointName = distributionPoint.getDistributionPoint();
		if (DistributionPointName.FULL_NAME != distributionPointName.getType()) {
			continue;
		}

		GeneralNames generalNames = (GeneralNames) distributionPointName.getName();
		GeneralName[] names = generalNames.getNames();
		for (GeneralName name : names) {
			if (name.getTagNo() != GeneralName.uniformResourceIdentifier) {
				continue;
			}

			DERIA5String derStr = DERIA5String.getInstance((ASN1TaggedObject) name.toASN1Primitive(), false);
			return derStr.getString();
		}
	}

	return null;
}
 
Example 3
Source File: DNetscapeSslServerName.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private void prepopulateWithValue(byte[] value) throws IOException {
	DERIA5String netscapeSslServerName = DERIA5String.getInstance(value);

	jtfNetscapeSslServerName.setText(netscapeSslServerName.getString());
	jtfNetscapeSslServerName.setCaretPosition(0);
}
 
Example 4
Source File: ExtensionSyntaxChecker.java    From xipki with Apache License 2.0 4 votes vote down vote up
private static ASN1Encodable getParsedImplicitValue(String name, ASN1TaggedObject taggedObject,
    FieldType fieldType) throws BadCertTemplateException {
  try {
    switch (fieldType) {
      case BIT_STRING:
        return DERBitString.getInstance(taggedObject, false);
      case BMPString:
        return DERBMPString.getInstance(taggedObject, false);
      case BOOLEAN:
        return ASN1Boolean.getInstance(taggedObject, false);
      case ENUMERATED:
        return ASN1Enumerated.getInstance(taggedObject, false);
      case GeneralizedTime:
        return DERGeneralizedTime.getInstance(taggedObject, false);
      case IA5String:
        return DERIA5String.getInstance(taggedObject, false);
      case INTEGER:
        return ASN1Integer.getInstance(taggedObject, false);
      case Name:
        return X500Name.getInstance(taggedObject, false);
      case NULL:
        if (!(taggedObject.getObject() instanceof ASN1OctetString
            && ((ASN1OctetString) taggedObject.getObject()).getOctets().length == 0)) {
          throw new BadCertTemplateException("invalid " + name);
        }
        return DERNull.INSTANCE;
      case OCTET_STRING:
        return DEROctetString.getInstance(taggedObject, false);
      case OID:
        return ASN1ObjectIdentifier.getInstance(taggedObject, false);
      case PrintableString:
        return DERPrintableString.getInstance(taggedObject, false);
      case RAW:
        return taggedObject.getObject();
      case SEQUENCE:
      case SEQUENCE_OF:
        return ASN1Sequence.getInstance(taggedObject, false);
      case SET:
      case SET_OF:
        return ASN1Set.getInstance(taggedObject, false);
      case TeletexString:
        return DERT61String.getInstance(taggedObject, false);
      case UTCTime:
        return DERUTCTime.getInstance(taggedObject, false);
      case UTF8String:
        return DERUTF8String.getInstance(taggedObject, false);
      default:
        throw new RuntimeException("Unknown FieldType " + fieldType);
    }
  } catch (IllegalArgumentException ex) {
    throw new BadCertTemplateException("invalid " + name, ex);
  }
}
 
Example 5
Source File: DNetscapeCertificateRenewalUrl.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private void prepopulateWithValue(byte[] value) throws IOException {
	DERIA5String netscapeCertificateRenewalUrl = DERIA5String.getInstance(value);

	jtfNetscapeCertificateRenewalUrl.setText(netscapeCertificateRenewalUrl.getString());
	jtfNetscapeCertificateRenewalUrl.setCaretPosition(0);
}
 
Example 6
Source File: DNetscapeCaPolicyUrl.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private void prepopulateWithValue(byte[] value) throws IOException {
	DERIA5String netscapeCaPolicyUrl = DERIA5String.getInstance(value);

	jtfNetscapeCaPolicyUrl.setText(netscapeCaPolicyUrl.getString());
	jtfNetscapeCaPolicyUrl.setCaretPosition(0);
}
 
Example 7
Source File: DNetscapeCaRevocationUrl.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private void prepopulateWithValue(byte[] value) throws IOException {
	DERIA5String netscapeCaRevocationUrl = DERIA5String.getInstance(value);

	jtfNetscapeCaRevocationUrl.setText(netscapeCaRevocationUrl.getString());
	jtfNetscapeCaRevocationUrl.setCaretPosition(0);
}
 
Example 8
Source File: DNetscapeRevocationUrl.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private void prepopulateWithValue(byte[] value) throws IOException {
	DERIA5String netscapeRevocationUrl = DERIA5String.getInstance(value);

	jtfNetscapeRevocationUrl.setText(netscapeRevocationUrl.getString());
	jtfNetscapeRevocationUrl.setCaretPosition(0);
}
 
Example 9
Source File: DNetscapeComment.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private void prepopulateWithValue(byte[] value) throws IOException {
	DERIA5String netscapeComment = DERIA5String.getInstance(value);

	jtaNetscapeComment.setText(netscapeComment.getString());
	jtaNetscapeComment.setCaretPosition(0);
}
 
Example 10
Source File: X509Ext.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private String getNetscapeBaseUrlStringValue(byte[] value) throws IOException {
	// @formatter:off

	/* NetscapeBaseUrl ::= DERIA5String */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	DERIA5String netscapeBaseUrl = DERIA5String.getInstance(value);

	sb.append(netscapeBaseUrl.getString());
	sb.append(NEWLINE);

	return sb.toString();
}
 
Example 11
Source File: DNetscapeBaseUrl.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private void prepopulateWithValue(byte[] value) throws IOException {
	DERIA5String netscapeBaseUrl = DERIA5String.getInstance(value);

	jtfNetscapeBaseUrl.setText(netscapeBaseUrl.getString());
	jtfNetscapeBaseUrl.setCaretPosition(0);
}
 
Example 12
Source File: X509Ext.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private String getNetscapeCommentStringValue(byte[] value) throws IOException {
	// @formatter:off

	/* NetscapeComment ::= DERIA5String */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	DERIA5String netscapeComment = DERIA5String.getInstance(value);

	sb.append(netscapeComment.getString());
	sb.append(NEWLINE);

	return sb.toString();
}
 
Example 13
Source File: X509Ext.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private String getNetscapeSslServerNameStringValue(byte[] value) throws IOException {
	// @formatter:off

	/* NetscapeSslServerName ::= DERIA5String */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	DERIA5String netscapeSslServerName = DERIA5String.getInstance(value);

	sb.append(netscapeSslServerName.getString());
	sb.append(NEWLINE);

	return sb.toString();
}
 
Example 14
Source File: X509Ext.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private String getNetscapeCaPolicyUrlStringValue(byte[] value) throws IOException {
	// @formatter:off

	/* NetscapeCAPolicyUrl ::= DERIA5String */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	DERIA5String netscapeCaPolicyUrl = DERIA5String.getInstance(value);

	sb.append(netscapeCaPolicyUrl.getString());
	sb.append(NEWLINE);

	return sb.toString();
}
 
Example 15
Source File: X509Ext.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private String getNetscapeCertificateRenewalStringValue(byte[] value) throws IOException {
	// @formatter:off

	/* NetscapeCertRenewalUrl ::= DERIA5String */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	DERIA5String netscapeCertRenewalUrl = DERIA5String.getInstance(value);

	sb.append(netscapeCertRenewalUrl.getString());
	sb.append(NEWLINE);

	return sb.toString();
}
 
Example 16
Source File: X509Ext.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private String getNetscapeCaRevocationUrlStringValue(byte[] value) throws IOException {
	// @formatter:off

	/* NetscapeCARevocationUrl ::= DERIA5String */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	DERIA5String netscapeCaRevocationUrl = DERIA5String.getInstance(value);

	sb.append(netscapeCaRevocationUrl.getString());
	sb.append(NEWLINE);

	return sb.toString();
}
 
Example 17
Source File: X509Ext.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private String getNetscapeRevocationUrlStringValue(byte[] value) throws IOException {
	// @formatter:off

	/* NetscapeRevocationUrl ::= DERIA5String */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	DERIA5String netscapeRevocationUrl = DERIA5String.getInstance(value);

	sb.append(netscapeRevocationUrl.getString());
	sb.append(NEWLINE);

	return sb.toString();
}