Java Code Examples for org.bouncycastle.asn1.DERPrintableString#getInstance()
The following examples show how to use
org.bouncycastle.asn1.DERPrintableString#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: SignedAssertion.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
private SignedAssertion(ASN1Sequence seq) { if (seq.size() != 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } this.assertion = DERPrintableString.getInstance(seq.getObjectAt(1)); }
Example 2
Source File: X509Ext.java From keystore-explorer with GNU General Public License v3.0 | 4 votes |
private String getDeclarationOfMajorityStringValue(byte[] octets) { // @formatter:off /* DeclarationOfMajoritySyntax ::= CHOICE { notYoungerThan [0] IMPLICIT INTEGER, fullAgeAtCountry [1] IMPLICIT SEQUENCE { fullAge BOOLEAN DEFAULT TRUE, country PrintableString (SIZE(2)) }, dateOfBirth [2] IMPLICIT GeneralizedTime } */ // @formatter:on StringBuilder sb = new StringBuilder(); DeclarationOfMajority declarationOfMajority = DeclarationOfMajority.getInstance(octets); int notYoungerThan = declarationOfMajority.notYoungerThan(); ASN1Sequence fullAgeAtCountry = declarationOfMajority.fullAgeAtCountry(); ASN1GeneralizedTime dateOfBirth = declarationOfMajority.getDateOfBirth(); if (notYoungerThan != -1) { sb.append(MessageFormat.format(res.getString("DeclarationOfMajority.notYoungerThan"), notYoungerThan)); sb.append(NEWLINE); } if (fullAgeAtCountry != null) { ASN1Boolean fullAge = ASN1Boolean.getInstance(fullAgeAtCountry.getObjectAt(0)); DERPrintableString country = DERPrintableString.getInstance(fullAgeAtCountry.getObjectAt(1)); sb.append(MessageFormat.format(res.getString("DeclarationOfMajority.fullAgeAtCountry"), country.toString(), fullAge.toString())); sb.append(NEWLINE); } if (dateOfBirth != null) { sb.append(MessageFormat.format(res.getString("DeclarationOfMajority.dateOfBirth"), dateOfBirth)); sb.append(NEWLINE); } return sb.toString(); }
Example 3
Source File: ExtensionSyntaxChecker.java From xipki with Apache License 2.0 | 4 votes |
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); } }