private Extension(ASN1Sequence seq) { if (seq.size() == 2) { this.extnId = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0)); this.critical = false; this.value = ASN1OctetString.getInstance(seq.getObjectAt(1)); } else if (seq.size() == 3) { this.extnId = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0)); this.critical = ASN1Boolean.getInstance(seq.getObjectAt(1)).isTrue(); this.value = ASN1OctetString.getInstance(seq.getObjectAt(2)); } else { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } }
private PKIArchiveOptions(ASN1TaggedObject tagged) { switch (tagged.getTagNo()) { case encryptedPrivKey: value = EncryptedKey.getInstance(tagged.getObject()); break; case keyGenParameters: value = ASN1OctetString.getInstance(tagged, false); break; case archiveRemGenPrivKey: value = ASN1Boolean.getInstance(tagged, false); break; default: throw new IllegalArgumentException("unknown tag number: " + tagged.getTagNo()); } }
private MetaData(ASN1Sequence seq) { this.hashProtected = ASN1Boolean.getInstance(seq.getObjectAt(0)); int index = 1; if (index < seq.size() && seq.getObjectAt(index) instanceof DERUTF8String) { this.fileName = DERUTF8String.getInstance(seq.getObjectAt(index++)); } if (index < seq.size() && seq.getObjectAt(index) instanceof DERIA5String) { this.mediaType = DERIA5String.getInstance(seq.getObjectAt(index++)); } if (index < seq.size()) { this.otherMetaData = Attributes.getInstance(seq.getObjectAt(index++)); } }
public TSTInfo(ASN1ObjectIdentifier tsaPolicyId, MessageImprint messageImprint, ASN1Integer serialNumber, ASN1GeneralizedTime genTime, Accuracy accuracy, ASN1Boolean ordering, ASN1Integer nonce, GeneralName tsa, Extensions extensions) { version = new ASN1Integer(1); this.tsaPolicyId = tsaPolicyId; this.messageImprint = messageImprint; this.serialNumber = serialNumber; this.genTime = genTime; this.accuracy = accuracy; this.ordering = ordering; this.nonce = nonce; this.tsa = tsa; this.extensions = extensions; }
public TimeStampReq( MessageImprint messageImprint, ASN1ObjectIdentifier tsaPolicy, ASN1Integer nonce, ASN1Boolean certReq, Extensions extensions) { // default version = new ASN1Integer(1); this.messageImprint = messageImprint; this.tsaPolicy = tsaPolicy; this.nonce = nonce; this.certReq = certReq; this.extensions = extensions; }
private Asn1NewKeyControl(ASN1Sequence seq) throws BadAsn1ObjectException { control = new P11NewKeyControl(); final int size = seq.size(); for (int i = 0; i < size; i++) { ASN1Encodable obj = seq.getObjectAt(i); if (obj instanceof ASN1TaggedObject) { continue; } ASN1TaggedObject tagObj = (ASN1TaggedObject) obj; int tagNo = tagObj.getTagNo(); if (tagNo == 0) { boolean bv = ((ASN1Boolean) tagObj.getObject()).isTrue(); control.setExtractable(bv); } } }
/** * Constructor from ASN1Sequence. * * the extensions are a list of constructed sequences, either with (OID, OctetString) or (OID, Boolean, OctetString) */ public X509Extensions( ASN1Sequence seq) { Enumeration e = seq.getObjects(); while (e.hasMoreElements()) { ASN1Sequence s = ASN1Sequence.getInstance(e.nextElement()); if (s.size() == 3) { extensions.put(s.getObjectAt(0), new X509Extension(ASN1Boolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2)))); } else if (s.size() == 2) { extensions.put(s.getObjectAt(0), new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1)))); } else { throw new IllegalArgumentException("Bad sequence size: " + s.size()); } ordering.addElement(s.getObjectAt(0)); } }
/** * <pre> * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension * * Extension ::= SEQUENCE { * extnId EXTENSION.&id ({ExtensionSet}), * critical BOOLEAN DEFAULT FALSE, * extnValue OCTET STRING } * </pre> */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vec = new ASN1EncodableVector(); Enumeration e = ordering.elements(); while (e.hasMoreElements()) { ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement(); X509Extension ext = (X509Extension)extensions.get(oid); ASN1EncodableVector v = new ASN1EncodableVector(); v.add(oid); if (ext.isCritical()) { v.add(ASN1Boolean.TRUE); } v.add(ext.getValue()); vec.add(new DERSequence(v)); } return new DERSequence(vec); }
public DeclarationOfMajority(boolean fullAge, String country) { if (country.length() > 2) { throw new IllegalArgumentException("country can only be 2 characters"); } if (fullAge) { declaration = new DERTaggedObject(false, 1, new DERSequence(new DERPrintableString(country, true))); } else { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(ASN1Boolean.FALSE); v.add(new DERPrintableString(country, true)); declaration = new DERTaggedObject(false, 1, new DERSequence(v)); } }
public ValidationPolicy(ValidationPolRef validationPolRef, ValidationAlg validationAlg, UserPolicySet userPolicySet, ASN1Boolean inhibitPolicyMapping, ASN1Boolean requireExplicitPolicy, ASN1Boolean inhibitAnyPolicy, TrustAnchors trustAnchors, KeyUsages keyUsages, KeyPurposeIds extendedKeyUsages, KeyPurposeIds specifiedKeyUsages) { this.validationPolRef = validationPolRef; this.validationAlg = validationAlg; this.userPolicySet = userPolicySet; this.inhibitPolicyMapping = inhibitPolicyMapping; this.requireExplicitPolicy = requireExplicitPolicy; this.inhibitAnyPolicy = inhibitAnyPolicy; this.trustAnchors = trustAnchors; this.keyUsages = keyUsages; this.extendedKeyUsages = extendedKeyUsages; this.specifiedKeyUsages = specifiedKeyUsages; }
private TranscriptDownloadMessage(ASN1Sequence seq) { this.queryID = ASN1Integer.getInstance(seq.getObjectAt(0)).getValue().longValue(); this.operationNumber = ASN1Integer.getInstance(seq.getObjectAt(1)).getValue().longValue(); this.stepNo = ASN1Integer.getInstance(seq.getObjectAt(2)).getValue().intValue(); this.type = TranscriptType.values()[ASN1Integer.getInstance(seq.getObjectAt(3)).getValue().intValue()]; this.maxNumberOfMessages = ASN1Integer.getInstance(seq.getObjectAt(4)).getValue().intValue(); this.withPairing = ASN1Boolean.getInstance(seq.getObjectAt(5)).isTrue(); if (seq.size() > 6) { this.seed = ASN1OctetString.getInstance(seq.getObjectAt(6)).getOctets(); } else { this.seed = null; } }