Java 类org.bouncycastle.asn1.ASN1Sequence 实例源码

项目:ipack    文件:McElieceCCA2PublicKey.java   
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();
}
项目:ipack    文件:PKIStatusInfo.java   
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);
        }
    }
}
项目:springboot-shiro-cas-mybatis    文件:X509SubjectAlternativeNameUPNPrincipalResolver.java   
/**
 * 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;
}
项目:springboot-shiro-cas-mybatis    文件:X509SubjectAlternativeNameUPNPrincipalResolver.java   
/**
 * 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;
}
项目:ipack    文件:DHParameter.java   
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;
    }
}
项目:ipack    文件:NameOrPseudonym.java   
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());
}
项目:ipack    文件:ProtectedPart.java   
public static ProtectedPart getInstance(Object o)
{
    if (o instanceof ProtectedPart)
    {
        return (ProtectedPart)o;
    }

    if (o != null)
    {
        return new ProtectedPart(ASN1Sequence.getInstance(o));
    }

    return null;
}
项目:cas-server-4.2.1    文件:X509SubjectAlternativeNameUPNPrincipalResolver.java   
/**
 * 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;
}
项目:ipack    文件:CscaMasterList.java   
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));
    }
}
项目:ipack    文件:POPOSigningKey.java   
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));
}
项目:ipack    文件:X509V2CRLGenerator.java   
/**
 * 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());
            }
        }
    }
}
项目:xitk    文件:Asn1SignTemplate.java   
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);
    }
}
项目:xitk    文件:Asn1NewKeyControl.java   
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);
        }
    }
}
项目:xitk    文件:Asn1P11ObjectIdentifier.java   
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);
    }
}
项目:ipack    文件:PKCS12SafeBagFactory.java   
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.");
}
项目:ipack    文件:IssuerSerial.java   
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));
    }
}
项目:ipack    文件:RecipientEncryptedKey.java   
/**
 * 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());
}
项目:ipack    文件:OtherCertID.java   
/**
 * 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));
    }
}
项目:ipack    文件:X509CRLParser.java   
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));
}
项目:ipack    文件:V2TBSCertListGenerator.java   
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);
}
项目:ipack    文件:TimeStampedData.java   
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));
}
项目:ipack    文件:AttCertIssuer.java   
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());
}
项目:ipack    文件:SemanticsInformation.java   
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));
        } 
    }
}
项目:ipack    文件:McEliecePublicKey.java   
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;
}
项目:ipack    文件:SafeBag.java   
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);
    }
}
项目:ipack    文件:SubjectPublicKeyInfo.java   
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;
}
项目:ipack    文件:IDEACBCPar.java   
public IDEACBCPar(
    ASN1Sequence  seq)
{
    if (seq.size() == 1)
    {
        iv = (ASN1OctetString)seq.getObjectAt(0);
    }
    else
    {
        iv = null;
    }
}
项目:ipack    文件:SMIMECapability.java   
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");
}
项目:ipack    文件:ResponseData.java   
/**
 * @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));
}
项目:ipack    文件:X500Name.java   
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;
}
项目:ipack    文件:DigestInfo.java   
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;
}
项目:ipack    文件:ESSCertIDv2.java   
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;
}
项目:ipack    文件:CRLBag.java   
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;
}
项目:ipack    文件:GeneralNames.java   
public static GeneralNames getInstance(
    Object  obj)
{
    if (obj instanceof GeneralNames)
    {
        return (GeneralNames)obj;
    }

    if (obj != null)
    {
        return new GeneralNames(ASN1Sequence.getInstance(obj));
    }

    return null;
}
项目:ipack    文件:QCStatement.java   
public static QCStatement getInstance(
    Object obj)
{
    if (obj instanceof QCStatement)
    {
        return (QCStatement)obj;
    }
    if (obj != null)
    {
        return new QCStatement(ASN1Sequence.getInstance(obj));            
    }

    return null;
}
项目:ipack    文件:KeySpecificInfo.java   
public KeySpecificInfo(
    ASN1Sequence  seq)
{
    Enumeration e = seq.getObjects();

    algorithm = (ASN1ObjectIdentifier)e.nextElement();
    counter = (ASN1OctetString)e.nextElement();
}
项目:ipack    文件:OtherRevVals.java   
public static OtherRevVals getInstance(Object obj)
{
    if (obj instanceof OtherRevVals)
    {
        return (OtherRevVals)obj;
    }
    if (obj != null)
    {
        return new OtherRevVals(ASN1Sequence.getInstance(obj));
    }

    return null;
}
项目:ipack    文件:ContentHints.java   
/**
 * 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));
    }
}
项目:ipack    文件:PollRepContent.java   
public static PollRepContent getInstance(Object o)
{
    if (o instanceof PollRepContent)
    {
        return (PollRepContent)o;
    }

    if (o != null)
    {
        return new PollRepContent(ASN1Sequence.getInstance(o));
    }

    return null;
}
项目:ipack    文件:CertificateList.java   
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");
    }
}