Java Code Examples for org.bouncycastle.asn1.DERGeneralString

The following examples show how to use org.bouncycastle.asn1.DERGeneralString. These examples are extracted from open source projects. 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 Project: portecle   Source File:    License: GNU General Public License v2.0 5 votes vote down vote up
 * Get Entrust Version Extension (1.2.840.113533.7.65.0) extension value as a string.
 * @param bValue The octet string value
 * @return Extension value as a string
 * @throws IOException If an I/O problem occurs
private String getEntrustVersionExtensionStringValue(byte[] bValue)
    throws IOException
	// SEQUENCE encapsulated in a OCTET STRING
	ASN1Sequence as = (ASN1Sequence) ASN1Primitive.fromByteArray(bValue);
	// Also has BIT STRING, ignored here
	//[email protected]/msg06546.html
	return escapeHtml(((DERGeneralString) as.getObjectAt(0)).getString());
Example 2
Source Project: keystore-explorer   Source File:    License: GNU General Public License v3.0 5 votes vote down vote up
private String getEntrustVersionInformationStringValue(byte[] value) throws IOException {
	// @formatter:off

	 * EntrustVersInfoSyntax ::= OCTET STRING
	 * entrustVersInfo EXTENSION ::= { SYNTAX EntrustVersInfoSyntax,
	 * IDENTIFIED BY {id-entrust 0} }
	 * EntrustVersInfoSyntax ::= ASN1Sequence { entrustVers GeneralString,
	 * entrustInfoFlags EntrustInfoFlags }
	 * EntrustInfoFlags ::= BIT STRING { keyUpdateAllowed newExtensions (1),
	 * pKIXCertificate (2) }

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	ASN1Sequence entrustVersInfo = (ASN1Sequence) ASN1Primitive.fromByteArray(value);

	DERGeneralString entrustVers = (DERGeneralString) entrustVersInfo.getObjectAt(0);
	DERBitString entrustInfoFlags = (DERBitString) entrustVersInfo.getObjectAt(1);

	sb.append(MessageFormat.format(res.getString("EntrustVersion"), entrustVers.getString()));
	sb.append(MessageFormat.format(res.getString("EntrustInformationFlags"), entrustInfoFlags.getString()));

	return sb.toString();
Example 3
Source Project: keystore-explorer   Source File:    License: GNU General Public License v3.0 5 votes vote down vote up
private String dumpString(ASN1String asn1String) {
	StringBuilder sb = new StringBuilder();


	if (asn1String instanceof DERBMPString) {
		sb.append("BMP STRING=");
	} else if (asn1String instanceof DERGeneralString) {
		sb.append("GENERAL STRING=");
	} else if (asn1String instanceof DERIA5String) {
		sb.append("IA5 STRING=");
	} else if (asn1String instanceof DERNumericString) {
		sb.append("NUMERIC STRING=");
	} else if (asn1String instanceof DERPrintableString) {
		sb.append("PRINTABLE STRING=");
	} else if (asn1String instanceof DERT61String) {
		sb.append("TELETEX STRING=");
	} else if (asn1String instanceof DERUniversalString) {
		sb.append("UNIVERSAL STRING=");
	} else if (asn1String instanceof DERUTF8String) {
		sb.append("UTF8 STRING=");
	} else if (asn1String instanceof DERVisibleString) {
		sb.append("VISIBLE STRING=");
	} else {
		sb.append("UNKNOWN STRING=");


	return sb.toString();