org.bouncycastle.asn1.DERGeneralString Java Examples

The following examples show how to use org.bouncycastle.asn1.DERGeneralString. 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: X509Ext.java    From portecle with 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
	// https://www.mail-archive.com/[email protected]/msg06546.html
	return escapeHtml(((DERGeneralString) as.getObjectAt(0)).getString());
}
 
Example #2
Source File: X509Ext.java    From keystore-explorer with 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(NEWLINE);
	sb.append(MessageFormat.format(res.getString("EntrustInformationFlags"), entrustInfoFlags.getString()));
	sb.append(NEWLINE);

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

	sb.append(indentSequence.toString(indentLevel));

	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=");
	}

	sb.append("'");
	sb.append(asn1String.getString());
	sb.append("'");
	sb.append(NEWLINE);

	return sb.toString();
}