private McElieceCCA2PublicKey(ASN1Sequence seq) { oid = ((ASN1ObjectIdentifier)seq.getObjectAt(0)); BigInteger bigN = ((ASN1Integer)seq.getObjectAt(1)).getValue(); n = bigN.intValue(); BigInteger bigT = ((ASN1Integer)seq.getObjectAt(2)).getValue(); t = bigT.intValue(); matrixG = ((ASN1OctetString)seq.getObjectAt(3)).getOctets(); }
private PKIStatusInfo( ASN1Sequence seq) { this.status = ASN1Integer.getInstance(seq.getObjectAt(0)); this.statusString = null; this.failInfo = null; if (seq.size() > 2) { this.statusString = PKIFreeText.getInstance(seq.getObjectAt(1)); this.failInfo = DERBitString.getInstance(seq.getObjectAt(2)); } else if (seq.size() > 1) { Object obj = seq.getObjectAt(1); if (obj instanceof DERBitString) { this.failInfo = DERBitString.getInstance(obj); } else { this.statusString = PKIFreeText.getInstance(obj); } } }
/** * Get UPN String. * * @param seq ASN1Sequence abstraction representing subject alternative name. * First element is the object identifier, second is the object itself. * * @return UPN string or null */ private String getUPNStringFromSequence(final ASN1Sequence seq) { if (seq != null) { // First in sequence is the object identifier, that we must check final ASN1ObjectIdentifier id = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0)); if (id != null && UPN_OBJECTID.equals(id.getId())) { final ASN1TaggedObject obj = (ASN1TaggedObject) seq.getObjectAt(1); ASN1Primitive prim = obj.getObject(); // Due to bug in java cert.getSubjectAltName, it can be tagged an extra time if (prim instanceof ASN1TaggedObject) { prim = ASN1TaggedObject.getInstance(((ASN1TaggedObject) prim)).getObject(); } if (prim instanceof ASN1OctetString) { return new String(((ASN1OctetString) prim).getOctets()); } else if (prim instanceof ASN1String) { return ((ASN1String) prim).getString(); } else{ return null; } } } return null; }
/** * Retrieves Subject Alternative Name UPN extension as a principal id String. * * @param certificate X.509 certificate credential. * * @return Resolved principal ID or null if no SAN UPN extension is available in provided certificate. * * @see AbstractX509PrincipalResolver#resolvePrincipalInternal(java.security.cert.X509Certificate) * @see java.security.cert.X509Certificate#getSubjectAlternativeNames() */ @Override protected String resolvePrincipalInternal(final X509Certificate certificate) { logger.debug("Resolving principal from Subject Alternative Name UPN for {}", certificate); try { final Collection<List<?>> subjectAltNames = certificate.getSubjectAlternativeNames(); if (subjectAltNames != null) { for (final List<?> sanItem : subjectAltNames) { final ASN1Sequence seq = getAltnameSequence(sanItem); final String upnString = getUPNStringFromSequence(seq); if (upnString != null) { return upnString; } } } } catch (final CertificateParsingException e) { logger.error("Error is encountered while trying to retrieve subject alternative names collection from certificate", e); logger.debug("Returning null principal id..."); return null; } logger.debug("Returning null principal id..."); return null; }
private DHParameter( ASN1Sequence seq) { Enumeration e = seq.getObjects(); p = ASN1Integer.getInstance(e.nextElement()); g = ASN1Integer.getInstance(e.nextElement()); if (e.hasMoreElements()) { l = (ASN1Integer)e.nextElement(); } else { l = null; } }
public static NameOrPseudonym getInstance(Object obj) { if (obj == null || obj instanceof NameOrPseudonym) { return (NameOrPseudonym)obj; } if (obj instanceof ASN1String) { return new NameOrPseudonym(DirectoryString.getInstance(obj)); } if (obj instanceof ASN1Sequence) { return new NameOrPseudonym((ASN1Sequence)obj); } throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName()); }
public static ProtectedPart getInstance(Object o) { if (o instanceof ProtectedPart) { return (ProtectedPart)o; } if (o != null) { return new ProtectedPart(ASN1Sequence.getInstance(o)); } return null; }
private CscaMasterList( ASN1Sequence seq) { if (seq == null || seq.size() == 0) { throw new IllegalArgumentException( "null or empty sequence passed."); } if (seq.size() != 2) { throw new IllegalArgumentException( "Incorrect sequence size: " + seq.size()); } version = ASN1Integer.getInstance(seq.getObjectAt(0)); ASN1Set certSet = ASN1Set.getInstance(seq.getObjectAt(1)); certList = new Certificate[certSet.size()]; for (int i = 0; i < certList.length; i++) { certList[i] = Certificate.getInstance(certSet.getObjectAt(i)); } }
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)); }
/** * Add the CRLEntry objects contained in a previous CRL. * * @param other the X509CRL to source the other entries from. */ public void addCRL(X509CRL other) throws CRLException { Set revocations = other.getRevokedCertificates(); if (revocations != null) { Iterator it = revocations.iterator(); while (it.hasNext()) { X509CRLEntry entry = (X509CRLEntry)it.next(); ASN1InputStream aIn = new ASN1InputStream(entry.getEncoded()); try { tbsGen.addCRLEntry(ASN1Sequence.getInstance(aIn.readObject())); } catch (IOException e) { throw new CRLException("exception processing encoding of CRL: " + e.toString()); } } } }
public static Asn1SignTemplate getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof Asn1SignTemplate) { return (Asn1SignTemplate) obj; } try { if (obj instanceof ASN1Sequence) { return new Asn1SignTemplate((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse encoded object: " + ex.getMessage(), ex); } }
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 Asn1P11ObjectIdentifier getInstance(Object obj) throws BadAsn1ObjectException { if (obj == null || obj instanceof Asn1P11ObjectIdentifier) { return (Asn1P11ObjectIdentifier) obj; } try { if (obj instanceof ASN1Sequence) { return new Asn1P11ObjectIdentifier((ASN1Sequence) obj); } else if (obj instanceof byte[]) { return getInstance(ASN1Primitive.fromByteArray((byte[]) obj)); } else { throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName()); } } catch (IOException | IllegalArgumentException ex) { throw new BadAsn1ObjectException("unable to parse encoded object: " + ex.getMessage(), ex); } }
public PKCS12SafeBagFactory(ContentInfo info, InputDecryptorProvider inputDecryptorProvider) throws PKCSException { if (info.getContentType().equals(PKCSObjectIdentifiers.encryptedData)) { CMSEncryptedData encData = new CMSEncryptedData(org.bouncycastle.asn1.cms.ContentInfo.getInstance(info)); try { this.safeBagSeq = ASN1Sequence.getInstance(encData.getContent(inputDecryptorProvider)); } catch (CMSException e) { throw new PKCSException("unable to extract data: " + e.getMessage(), e); } return; } throw new IllegalArgumentException("encryptedData requires constructor with decryptor."); }
private IssuerSerial( ASN1Sequence seq) { if (seq.size() != 2 && seq.size() != 3) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } issuer = GeneralNames.getInstance(seq.getObjectAt(0)); serial = ASN1Integer.getInstance(seq.getObjectAt(1)); if (seq.size() == 3) { issuerUID = DERBitString.getInstance(seq.getObjectAt(2)); } }
/** * return a RecipientEncryptedKey object from the given object. * * @param obj the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static RecipientEncryptedKey getInstance( Object obj) { if (obj == null || obj instanceof RecipientEncryptedKey) { return (RecipientEncryptedKey)obj; } if (obj instanceof ASN1Sequence) { return new RecipientEncryptedKey((ASN1Sequence)obj); } throw new IllegalArgumentException("Invalid RecipientEncryptedKey: " + obj.getClass().getName()); }
/** * constructor */ private OtherCertID(ASN1Sequence seq) { if (seq.size() < 1 || seq.size() > 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } if (seq.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString) { otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0)); } else { otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0)); } if (seq.size() > 1) { issuerSerial = IssuerSerial.getInstance(seq.getObjectAt(1)); } }
private CRL readDERCRL( InputStream in) throws IOException, CRLException { 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)).getCRLs(); return getCRL(); } } return new X509CRLObject(CertificateList.getInstance(seq)); }
private static ASN1Sequence createInvalidityDateExtension(ASN1GeneralizedTime invalidityDate) { ASN1EncodableVector v = new ASN1EncodableVector(); try { v.add(Extension.invalidityDate); v.add(new DEROctetString(invalidityDate.getEncoded())); } catch (IOException e) { throw new IllegalArgumentException("error encoding reason: " + e); } return new DERSequence(v); }
private TimeStampedData(ASN1Sequence seq) { this.version = ASN1Integer.getInstance(seq.getObjectAt(0)); int index = 1; if (seq.getObjectAt(index) instanceof DERIA5String) { this.dataUri = DERIA5String.getInstance(seq.getObjectAt(index++)); } if (seq.getObjectAt(index) instanceof MetaData || seq.getObjectAt(index) instanceof ASN1Sequence) { this.metaData = MetaData.getInstance(seq.getObjectAt(index++)); } if (seq.getObjectAt(index) instanceof ASN1OctetString) { this.content = ASN1OctetString.getInstance(seq.getObjectAt(index++)); } this.temporalEvidence = Evidence.getInstance(seq.getObjectAt(index)); }
public static AttCertIssuer getInstance( Object obj) { if (obj == null || obj instanceof AttCertIssuer) { return (AttCertIssuer)obj; } else if (obj instanceof V2Form) { return new AttCertIssuer(V2Form.getInstance(obj)); } else if (obj instanceof GeneralNames) { return new AttCertIssuer((GeneralNames)obj); } else if (obj instanceof ASN1TaggedObject) { return new AttCertIssuer(V2Form.getInstance((ASN1TaggedObject)obj, false)); } else if (obj instanceof ASN1Sequence) { return new AttCertIssuer(GeneralNames.getInstance(obj)); } throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName()); }
private SemanticsInformation(ASN1Sequence seq) { Enumeration e = seq.getObjects(); if (seq.size() < 1) { throw new IllegalArgumentException("no objects in SemanticsInformation"); } Object object = e.nextElement(); if (object instanceof ASN1ObjectIdentifier) { semanticsIdentifier = ASN1ObjectIdentifier.getInstance(object); if (e.hasMoreElements()) { object = e.nextElement(); } else { object = null; } } if (object != null) { ASN1Sequence generalNameSeq = ASN1Sequence.getInstance(object); nameRegistrationAuthorities = new GeneralName[generalNameSeq.size()]; for (int i= 0; i < generalNameSeq.size(); i++) { nameRegistrationAuthorities[i] = GeneralName.getInstance(generalNameSeq.getObjectAt(i)); } } }
public static McEliecePublicKey getInstance(Object o) { if (o instanceof McEliecePublicKey) { return (McEliecePublicKey)o; } else if (o != null) { return new McEliecePublicKey(ASN1Sequence.getInstance(o)); } return null; }
private SafeBag( ASN1Sequence seq) { this.bagId = (ASN1ObjectIdentifier)seq.getObjectAt(0); this.bagValue = ((ASN1TaggedObject)seq.getObjectAt(1)).getObject(); if (seq.size() == 3) { this.bagAttributes = (ASN1Set)seq.getObjectAt(2); } }
public static SubjectPublicKeyInfo getInstance( Object obj) { if (obj instanceof SubjectPublicKeyInfo) { return (SubjectPublicKeyInfo)obj; } else if (obj != null) { return new SubjectPublicKeyInfo(ASN1Sequence.getInstance(obj)); } return null; }
public IDEACBCPar( ASN1Sequence seq) { if (seq.size() == 1) { iv = (ASN1OctetString)seq.getObjectAt(0); } else { iv = null; } }
public static SMIMECapability getInstance( Object obj) { if (obj == null || obj instanceof SMIMECapability) { return (SMIMECapability)obj; } if (obj instanceof ASN1Sequence) { return new SMIMECapability((ASN1Sequence)obj); } throw new IllegalArgumentException("Invalid SMIMECapability"); }
/** * @deprecated use method taking Extensions * @param responderID * @param producedAt * @param responses * @param responseExtensions */ public ResponseData( ResponderID responderID, DERGeneralizedTime producedAt, ASN1Sequence responses, X509Extensions responseExtensions) { this(V1, responderID, ASN1GeneralizedTime.getInstance(producedAt), responses, Extensions.getInstance(responseExtensions)); }
public static X500Name getInstance( X500NameStyle style, Object obj) { if (obj instanceof X500Name) { return getInstance(style, ((X500Name)obj).toASN1Primitive()); } else if (obj != null) { return new X500Name(style, ASN1Sequence.getInstance(obj)); } return null; }
public static DigestInfo getInstance( Object obj) { if (obj instanceof DigestInfo) { return (DigestInfo)obj; } else if (obj != null) { return new DigestInfo(ASN1Sequence.getInstance(obj)); } return null; }
public static ESSCertIDv2 getInstance( Object o) { if (o instanceof ESSCertIDv2) { return (ESSCertIDv2) o; } else if (o != null) { return new ESSCertIDv2(ASN1Sequence.getInstance(o)); } return null; }
public static CRLBag getInstance(Object o) { if (o instanceof CRLBag) { return (CRLBag)o; } else if (o != null) { return new CRLBag(ASN1Sequence.getInstance(o)); } return null; }
public static GeneralNames getInstance( Object obj) { if (obj instanceof GeneralNames) { return (GeneralNames)obj; } if (obj != null) { return new GeneralNames(ASN1Sequence.getInstance(obj)); } return null; }
public static QCStatement getInstance( Object obj) { if (obj instanceof QCStatement) { return (QCStatement)obj; } if (obj != null) { return new QCStatement(ASN1Sequence.getInstance(obj)); } return null; }
public KeySpecificInfo( ASN1Sequence seq) { Enumeration e = seq.getObjects(); algorithm = (ASN1ObjectIdentifier)e.nextElement(); counter = (ASN1OctetString)e.nextElement(); }
public static OtherRevVals getInstance(Object obj) { if (obj instanceof OtherRevVals) { return (OtherRevVals)obj; } if (obj != null) { return new OtherRevVals(ASN1Sequence.getInstance(obj)); } return null; }
/** * constructor */ private ContentHints(ASN1Sequence seq) { ASN1Encodable field = seq.getObjectAt(0); if (field.toASN1Primitive() instanceof DERUTF8String) { contentDescription = DERUTF8String.getInstance(field); contentType = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(1)); } else { contentType = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0)); } }
public static PollRepContent getInstance(Object o) { if (o instanceof PollRepContent) { return (PollRepContent)o; } if (o != null) { return new PollRepContent(ASN1Sequence.getInstance(o)); } return null; }
public CertificateList( ASN1Sequence seq) { if (seq.size() == 3) { tbsCertList = TBSCertList.getInstance(seq.getObjectAt(0)); sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1)); sig = DERBitString.getInstance(seq.getObjectAt(2)); } else { throw new IllegalArgumentException("sequence wrong size for CertificateList"); } }