public KeyAgreeRecipientInfo( ASN1Sequence seq) { int index = 0; version = (ASN1Integer)seq.getObjectAt(index++); originator = OriginatorIdentifierOrKey.getInstance( (ASN1TaggedObject)seq.getObjectAt(index++), true); if (seq.getObjectAt(index) instanceof ASN1TaggedObject) { ukm = ASN1OctetString.getInstance( (ASN1TaggedObject)seq.getObjectAt(index++), true); } keyEncryptionAlgorithm = AlgorithmIdentifier.getInstance( seq.getObjectAt(index++)); recipientEncryptedKeys = (ASN1Sequence)seq.getObjectAt(index++); }
private X509AttributeCertificate getCertificate() throws IOException { if (sData != null) { while (sDataObjectCount < sData.size()) { Object obj = sData.getObjectAt(sDataObjectCount++); if (obj instanceof ASN1TaggedObject && ((ASN1TaggedObject)obj).getTagNo() == 2) { return new X509V2AttributeCertificate( ASN1Sequence.getInstance((ASN1TaggedObject)obj, false).getEncoded()); } } } return null; }
private Certificate readDERCertificate( InputStream in) throws IOException, CertificateParsingException { ASN1InputStream dIn = new ASN1InputStream(in); ASN1Sequence seq = (ASN1Sequence)dIn.readObject(); if (seq.size() > 1 && seq.getObjectAt(0) instanceof DERObjectIdentifier) { if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData)) { sData = new SignedData(ASN1Sequence.getInstance( (ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates(); return getCertificate(); } } return new X509CertificateObject( org.bouncycastle.asn1.x509.Certificate.getInstance(seq)); }
private ASN1Primitive getObjectInTag(int tagNo) { Enumeration e = seq.getObjects(); while (e.hasMoreElements()) { ASN1Encodable obj = (ASN1Encodable)e.nextElement(); if (obj instanceof ASN1TaggedObject) { ASN1TaggedObject tag = (ASN1TaggedObject)obj; if (tag.getTagNo() == tagNo) { return tag.getObject().toASN1Primitive(); } } } return null; }
/** * @deprectaed use PrivateKeyInfo.getInstance() * @param seq */ public PrivateKeyInfo( ASN1Sequence seq) { Enumeration e = seq.getObjects(); BigInteger version = ((ASN1Integer)e.nextElement()).getValue(); if (version.intValue() != 0) { throw new IllegalArgumentException("wrong version for private key info"); } algId = AlgorithmIdentifier.getInstance(e.nextElement()); privKey = ASN1OctetString.getInstance(e.nextElement()); if (e.hasMoreElements()) { attributes = ASN1Set.getInstance((ASN1TaggedObject)e.nextElement(), false); } }
/** * @deprecated use getInstance() */ public ContentInfo( ASN1Sequence seq) { if (seq.size() < 1 || seq.size() > 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } contentType = (ASN1ObjectIdentifier)seq.getObjectAt(0); if (seq.size() > 1) { ASN1TaggedObject tagged = (ASN1TaggedObject)seq.getObjectAt(1); if (!tagged.isExplicit() || tagged.getTagNo() != 0) { throw new IllegalArgumentException("Bad tag for 'content'"); } content = tagged.getObject(); } }
public DistributionPoint( ASN1Sequence seq) { for (int i = 0; i != seq.size(); i++) { ASN1TaggedObject t = ASN1TaggedObject.getInstance(seq.getObjectAt(i)); switch (t.getTagNo()) { case 0: distributionPoint = DistributionPointName.getInstance(t, true); break; case 1: reasons = new ReasonFlags(DERBitString.getInstance(t, false)); break; case 2: cRLIssuer = GeneralNames.getInstance(t, false); } } }
Store getAttributeCertificates(ASN1Set certSet) { if (certSet != null) { List certList = new ArrayList(certSet.size()); for (Enumeration en = certSet.getObjects(); en.hasMoreElements();) { ASN1Primitive obj = ((ASN1Encodable)en.nextElement()).toASN1Primitive(); if (obj instanceof ASN1TaggedObject) { certList.add(new X509AttributeCertificateHolder(AttributeCertificate.getInstance(((ASN1TaggedObject)obj).getObject()))); } } return new CollectionStore(certList); } return new CollectionStore(new ArrayList()); }
public AlgorithmIdentifier getDigestAlgorithm() throws IOException { if (nextObject == null) { nextObject = seq.readObject(); } if (nextObject instanceof ASN1TaggedObjectParser) { AlgorithmIdentifier obj = AlgorithmIdentifier.getInstance((ASN1TaggedObject)nextObject.toASN1Primitive(), false); nextObject = null; return obj; } return null; }
public CertStatus( ASN1TaggedObject choice) { this.tagNo = choice.getTagNo(); switch (choice.getTagNo()) { case 0: value = DERNull.INSTANCE; break; case 1: value = RevokedInfo.getInstance(choice, false); break; case 2: value = DERNull.INSTANCE; } }
private RevRepContent(ASN1Sequence seq) { Enumeration en = seq.getObjects(); status = ASN1Sequence.getInstance(en.nextElement()); while (en.hasMoreElements()) { ASN1TaggedObject tObj = ASN1TaggedObject.getInstance(en.nextElement()); if (tObj.getTagNo() == 0) { revCerts = ASN1Sequence.getInstance(tObj, true); } else { crls = ASN1Sequence.getInstance(tObj, true); } } }
public static X509Extensions getInstance( Object obj) { if (obj == null || obj instanceof X509Extensions) { return (X509Extensions)obj; } if (obj instanceof ASN1Sequence) { return new X509Extensions((ASN1Sequence)obj); } if (obj instanceof Extensions) { return new X509Extensions((ASN1Sequence)((Extensions)obj).toASN1Primitive()); } if (obj instanceof ASN1TaggedObject) { return getInstance(((ASN1TaggedObject)obj).getObject()); } throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName()); }
public static Holder getInstance(Object obj) { if (obj instanceof Holder) { return (Holder)obj; } else if (obj instanceof ASN1TaggedObject) { return new Holder(ASN1TaggedObject.getInstance(obj)); } else if (obj != null) { return new Holder(ASN1Sequence.getInstance(obj)); } return null; }
/** * Constructor for a holder for an V1 attribute certificate. * * @param tagObj The ASN.1 tagged holder object. */ private Holder(ASN1TaggedObject tagObj) { switch (tagObj.getTagNo()) { case 0: baseCertificateID = IssuerSerial.getInstance(tagObj, false); break; case 1: entityName = GeneralNames.getInstance(tagObj, false); break; default: throw new IllegalArgumentException("unknown tag in Holder"); } version = 0; }
private OOBCertHash(ASN1Sequence seq) { int index = seq.size() - 1; hashVal = DERBitString.getInstance(seq.getObjectAt(index--)); for (int i = index; i >= 0; i--) { ASN1TaggedObject tObj = (ASN1TaggedObject)seq.getObjectAt(i); if (tObj.getTagNo() == 0) { hashAlg = AlgorithmIdentifier.getInstance(tObj, true); } else { certId = CertId.getInstance(tObj, true); } } }
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); } } }
public static RequestedCertificate getInstance(Object obj) { if (obj == null || obj instanceof RequestedCertificate) { return (RequestedCertificate)obj; } if (obj instanceof ASN1Sequence) { return new RequestedCertificate(Certificate.getInstance(obj)); } if (obj instanceof ASN1TaggedObject) { return new RequestedCertificate((ASN1TaggedObject)obj); } throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName()); }
public KeyTransRecipientInfo( RecipientIdentifier rid, AlgorithmIdentifier keyEncryptionAlgorithm, ASN1OctetString encryptedKey) { if (rid.toASN1Primitive() instanceof ASN1TaggedObject) { this.version = new ASN1Integer(2); } else { this.version = new ASN1Integer(0); } this.rid = rid; this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; this.encryptedKey = encryptedKey; }
private OptionalValidity(ASN1Sequence seq) { Enumeration en = seq.getObjects(); while (en.hasMoreElements()) { ASN1TaggedObject tObj = (ASN1TaggedObject)en.nextElement(); if (tObj.getTagNo() == 0) { notBefore = Time.getInstance(tObj, true); } else { notAfter = Time.getInstance(tObj, true); } } }
private POPOPrivKey(ASN1TaggedObject obj) { this.tagNo = obj.getTagNo(); switch (tagNo) { case thisMessage: this.obj = DERBitString.getInstance(obj, false); break; case subsequentMessage: this.obj = SubsequentMessage.valueOf(ASN1Integer.getInstance(obj, false).getValue().intValue()); break; case dhMAC: this.obj = DERBitString.getInstance(obj, false); break; case agreeMAC: this.obj = PKMACValue.getInstance(obj, false); break; case encryptedKey: this.obj = EnvelopedData.getInstance(obj, false); break; default: throw new IllegalArgumentException("unknown tag in POPOPrivKey"); } }
private POPOSigningKey(ASN1Sequence seq) { int index = 0; if (seq.getObjectAt(index) instanceof ASN1TaggedObject) { ASN1TaggedObject tagObj = (ASN1TaggedObject)seq.getObjectAt(index++); if (tagObj.getTagNo() != 0) { throw new IllegalArgumentException( "Unknown POPOSigningKeyInput tag: " + tagObj.getTagNo()); } poposkInput = POPOSigningKeyInput.getInstance(tagObj.getObject()); } algorithmIdentifier = AlgorithmIdentifier.getInstance(seq.getObjectAt(index++)); signature = DERBitString.getInstance(seq.getObjectAt(index)); }
private CertifiedKeyPair(ASN1Sequence seq) { certOrEncCert = CertOrEncCert.getInstance(seq.getObjectAt(0)); if (seq.size() >= 2) { if (seq.size() == 2) { ASN1TaggedObject tagged = ASN1TaggedObject.getInstance(seq.getObjectAt(1)); if (tagged.getTagNo() == 0) { privateKey = EncryptedValue.getInstance(tagged.getObject()); } else { publicationInfo = PKIPublicationInfo.getInstance(tagged.getObject()); } } else { privateKey = EncryptedValue.getInstance(ASN1TaggedObject.getInstance(seq.getObjectAt(1))); publicationInfo = PKIPublicationInfo.getInstance(ASN1TaggedObject.getInstance(seq.getObjectAt(2))); } } }
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()); } }
public static RecipientInfo getInstance( Object o) { if (o == null || o instanceof RecipientInfo) { return (RecipientInfo)o; } else if (o instanceof ASN1Sequence) { return new RecipientInfo((ASN1Sequence)o); } else if (o instanceof ASN1TaggedObject) { return new RecipientInfo((ASN1TaggedObject)o); } throw new IllegalArgumentException("unknown object in factory: " + o.getClass().getName()); }
private POPOSigningKeyInput(ASN1Sequence seq) { ASN1Encodable authInfo = (ASN1Encodable)seq.getObjectAt(0); if (authInfo instanceof ASN1TaggedObject) { ASN1TaggedObject tagObj = (ASN1TaggedObject)authInfo; if (tagObj.getTagNo() != 0) { throw new IllegalArgumentException( "Unknown authInfo tag: " + tagObj.getTagNo()); } sender = GeneralName.getInstance(tagObj.getObject()); } else { publicKeyMAC = PKMACValue.getInstance(authInfo); } publicKey = SubjectPublicKeyInfo.getInstance(seq.getObjectAt(1)); }
private OriginatorInfo( ASN1Sequence seq) { switch (seq.size()) { case 0: // empty break; case 1: ASN1TaggedObject o = (ASN1TaggedObject)seq.getObjectAt(0); switch (o.getTagNo()) { case 0 : certs = ASN1Set.getInstance(o, false); break; case 1 : crls = ASN1Set.getInstance(o, false); break; default: throw new IllegalArgumentException("Bad tag in OriginatorInfo: " + o.getTagNo()); } break; case 2: certs = ASN1Set.getInstance((ASN1TaggedObject)seq.getObjectAt(0), false); crls = ASN1Set.getInstance((ASN1TaggedObject)seq.getObjectAt(1), false); break; default: throw new IllegalArgumentException("OriginatorInfo too big"); } }
public static DVCSResponse getInstance(Object obj) { if (obj == null || obj instanceof DVCSResponse) { return (DVCSResponse)obj; } else { if (obj instanceof byte[]) { try { return getInstance(ASN1Primitive.fromByteArray((byte[])obj)); } catch (IOException e) { throw new IllegalArgumentException("failed to construct sequence from byte[]: " + e.getMessage()); } } if (obj instanceof ASN1Sequence) { DVCSCertInfo dvCertInfo = DVCSCertInfo.getInstance(obj); return new DVCSResponse(dvCertInfo); } if (obj instanceof ASN1TaggedObject) { ASN1TaggedObject t = ASN1TaggedObject.getInstance(obj); DVCSErrorNotice dvErrorNote = DVCSErrorNotice.getInstance(t, false); return new DVCSResponse(dvErrorNote); } } throw new IllegalArgumentException("Couldn't convert from object to DVCSResponse: " + obj.getClass().getName()); }
private BasicOCSPResponse( ASN1Sequence seq) { this.tbsResponseData = ResponseData.getInstance(seq.getObjectAt(0)); this.signatureAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(1)); this.signature = (DERBitString)seq.getObjectAt(2); if (seq.size() > 3) { this.certs = ASN1Sequence.getInstance((ASN1TaggedObject)seq.getObjectAt(3), true); } }
public OriginatorPublicKey getOriginatorKey() { if (id instanceof ASN1TaggedObject && ((ASN1TaggedObject)id).getTagNo() == 1) { return OriginatorPublicKey.getInstance((ASN1TaggedObject)id, false); } return null; }
/** * Constructor from ASN1Sequence. * <p/> * The sequence is of type CertificatePair: * <p/> * <pre> * CertificatePair ::= SEQUENCE { * forward [0] Certificate OPTIONAL, * reverse [1] Certificate OPTIONAL, * -- at least one of the pair shall be present -- } * </pre> * * @param seq The ASN.1 sequence. */ private CertificatePair(ASN1Sequence seq) { if (seq.size() != 1 && seq.size() != 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } Enumeration e = seq.getObjects(); while (e.hasMoreElements()) { ASN1TaggedObject o = ASN1TaggedObject.getInstance(e.nextElement()); if (o.getTagNo() == 0) { forward = Certificate.getInstance(o, true); } else if (o.getTagNo() == 1) { reverse = Certificate.getInstance(o, true); } else { throw new IllegalArgumentException("Bad tag number: " + o.getTagNo()); } } }
/** * Creates an instance of a Target from the given object. * <p> * <code>obj</code> can be a Target or a {@link ASN1TaggedObject} * * @param obj The object. * @return A Target instance. * @throws IllegalArgumentException if the given object cannot be * interpreted as Target. */ public static Target getInstance(Object obj) { if (obj == null || obj instanceof Target) { return (Target) obj; } else if (obj instanceof ASN1TaggedObject) { return new Target((ASN1TaggedObject)obj); } throw new IllegalArgumentException("unknown object in factory: " + obj.getClass()); }
public static CertStatus getInstance( Object obj) { if (obj == null || obj instanceof CertStatus) { return (CertStatus)obj; } else if (obj instanceof ASN1TaggedObject) { return new CertStatus((ASN1TaggedObject)obj); } throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName()); }
private KEKRecipientInfo getKEKInfo(ASN1TaggedObject o) { if (o.isExplicit()) { // compatibilty with erroneous version return KEKRecipientInfo.getInstance(o, true); } else { return KEKRecipientInfo.getInstance(o, false); } }
private MQVuserKeyingMaterial( ASN1Sequence seq) { // TODO Check seq has either 1 or 2 elements this.ephemeralPublicKey = OriginatorPublicKey.getInstance( seq.getObjectAt(0)); if (seq.size() > 1) { this.addedukm = ASN1OctetString.getInstance( (ASN1TaggedObject)seq.getObjectAt(1), true); } }
public DistributionPointName( ASN1TaggedObject obj) { this.type = obj.getTagNo(); if (type == 0) { this.name = GeneralNames.getInstance(obj, false); } else { this.name = ASN1Set.getInstance(obj, false); } }
private CertEtcToken(ASN1TaggedObject choice) { this.tagNo = choice.getTagNo(); switch (tagNo) { case TAG_CERTIFICATE: value = Certificate.getInstance(choice, false); break; case TAG_ESSCERTID: value = ESSCertID.getInstance(choice.getObject()); break; case TAG_PKISTATUS: value = PKIStatusInfo.getInstance(choice, false); break; case TAG_ASSERTION: value = ContentInfo.getInstance(choice.getObject()); break; case TAG_CRL: value = CertificateList.getInstance(choice, false); break; case TAG_OCSPCERTSTATUS: value = CertStatus.getInstance(choice.getObject()); break; case TAG_OCSPCERTID: value = CertID.getInstance(choice, false); break; case TAG_OCSPRESPONSE: value = OCSPResponse.getInstance(choice, false); break; case TAG_CAPABILITIES: value = SMIMECapabilities.getInstance(choice.getObject()); break; default: throw new IllegalArgumentException("Unknown tag: " + tagNo); } }
public SignedData( ASN1Sequence seq) { Enumeration e = seq.getObjects(); version = (ASN1Integer)e.nextElement(); digestAlgorithms = ((ASN1Set)e.nextElement()); contentInfo = ContentInfo.getInstance(e.nextElement()); while (e.hasMoreElements()) { ASN1Primitive o = (ASN1Primitive)e.nextElement(); // // an interesting feature of SignedData is that there appear to be varying implementations... // for the moment we ignore anything which doesn't fit. // if (o instanceof ASN1TaggedObject) { ASN1TaggedObject tagged = (ASN1TaggedObject)o; switch (tagged.getTagNo()) { case 0: certificates = ASN1Set.getInstance(tagged, false); break; case 1: crls = ASN1Set.getInstance(tagged, false); break; default: throw new IllegalArgumentException("unknown tag value " + tagged.getTagNo()); } } else { signerInfos = (ASN1Set)o; } } }
private TBSRequest( ASN1Sequence seq) { int index = 0; if (seq.getObjectAt(0) instanceof ASN1TaggedObject) { ASN1TaggedObject o = (ASN1TaggedObject)seq.getObjectAt(0); if (o.getTagNo() == 0) { versionSet = true; version = ASN1Integer.getInstance((ASN1TaggedObject)seq.getObjectAt(0), true); index++; } else { version = V1; } } else { version = V1; } if (seq.getObjectAt(index) instanceof ASN1TaggedObject) { requestorName = GeneralName.getInstance((ASN1TaggedObject)seq.getObjectAt(index++), true); } requestList = (ASN1Sequence)seq.getObjectAt(index++); if (seq.size() == (index + 1)) { requestExtensions = Extensions.getInstance((ASN1TaggedObject)seq.getObjectAt(index), true); } }
private OCSPResponse( ASN1Sequence seq) { responseStatus = OCSPResponseStatus.getInstance(seq.getObjectAt(0)); if (seq.size() == 2) { responseBytes = ResponseBytes.getInstance( (ASN1TaggedObject)seq.getObjectAt(1), true); } }
private Evidence(ASN1TaggedObject tagged) { if (tagged.getTagNo() == 0) { this.tstEvidence = TimeStampTokenEvidence.getInstance(tagged, false); } }