Package org.apache.commons.ssl.asn1

Examples of org.apache.commons.ssl.asn1.DEREncodable


                    e.printStackTrace(System.err);
                    throw new PKCS7Exception(F_PKCS7_DATADECODE, -1, e);
                }
            }

            DEREncodable params = encAlg.getParameters();
            try {
                String algo = org.jruby.ext.openssl.Cipher.Algorithm.getAlgorithmBase(evpCipher);
                if(params != null && params instanceof ASN1OctetString) {
                    if (algo.startsWith("RC2")) {
                        // J9's IBMJCE needs this exceptional RC2 support.
View Full Code Here


        EncContent ec = new EncContent();
        ec.setContentType(nid);
        ec.setAlgorithm(AlgorithmIdentifier.getInstance(sequence.getObjectAt(1)));
        if(sequence.size() > 2 && sequence.getObjectAt(2) instanceof DERTaggedObject && ((DERTaggedObject)(sequence.getObjectAt(2))).getTagNo() == 0) {
            DEREncodable ee = ((DERTaggedObject)(sequence.getObjectAt(2))).getObject();
            if(ee instanceof ASN1Sequence && ((ASN1Sequence)ee).size() > 0) {
                ByteList combinedOctets = new ByteList();
                Enumeration enm = ((ASN1Sequence)ee).getObjects();
                while (enm.hasMoreElements()) {
                    byte[] octets = ((ASN1OctetString)enm.nextElement()).getOctets();
View Full Code Here

            if(sakid.getAuthorityCertIssuer() != null) {
                GeneralName[] gens = sakid.getAuthorityCertIssuer().getNames();
                org.bouncycastle.asn1.x509.X509Name nm = null;
                for(int i=0;i<gens.length;i++) {
                    if(gens[i].getTagNo() == GeneralName.directoryName) {
                        DEREncodable nameTmp = gens[i].getName();
                        if (nameTmp instanceof org.bouncycastle.asn1.x509.X509Name) {
                            nm = (org.bouncycastle.asn1.x509.X509Name)nameTmp;
                        } else if (nameTmp instanceof DERSequence) {
                            nm = new org.bouncycastle.asn1.x509.X509Name((DERSequence)nameTmp);
                        } else {
View Full Code Here

     */
    public static Signed fromASN1(DEREncodable content) throws PKCS7Exception{
        ASN1Sequence sequence = (ASN1Sequence)content;
        DERInteger version = (DERInteger)sequence.getObjectAt(0);
        ASN1Set digestAlgos = (ASN1Set)sequence.getObjectAt(1);
        DEREncodable contentInfo = sequence.getObjectAt(2);

        DEREncodable certificates = null;
        DEREncodable crls = null;

        int index = 3;
        DEREncodable tmp = sequence.getObjectAt(index);
        if((tmp instanceof DERTaggedObject) && ((DERTaggedObject)tmp).getTagNo() == 0) {
            certificates = ((DERTaggedObject)tmp).getObject();
            index++;
        }

View Full Code Here

    private static Collection<X509AuxCertificate> certificatesFromASN1Set(DEREncodable content) throws PKCS7Exception {
        Collection<X509AuxCertificate> result = new ArrayList<X509AuxCertificate>();
        if (content instanceof DERSequence) {
            try {
                for (Enumeration<?> enm = ((DERSequence) content).getObjects(); enm.hasMoreElements();) {
                    DEREncodable current = (DEREncodable) enm.nextElement();
                    result.add(certificateFromASN1(current));
                }
            } catch (IllegalArgumentException iae) {
                result.add(certificateFromASN1(content));
            }
        } else if (content instanceof DERSet) {
            // EXPLICIT Set shouldn't apper here but keep this for backward compatibility.
            for (Enumeration<?> enm = ((DERSet) content).getObjects(); enm.hasMoreElements();) {
                DEREncodable current = (DEREncodable) enm.nextElement();
                result.add(certificateFromASN1(current));
            }
        } else {
            throw new PKCS7Exception(PKCS7.F_B64_READ_PKCS7, PKCS7.R_CERTIFICATE_VERIFY_ERROR, "unknown certificates format");
        }
View Full Code Here

     */
    public static Envelope fromASN1(DEREncodable content) {
        ASN1Sequence sequence = (ASN1Sequence)content;
        DERInteger version = (DERInteger)sequence.getObjectAt(0);
        ASN1Set recipients = (ASN1Set)sequence.getObjectAt(1);
        DEREncodable encContent = sequence.getObjectAt(2);       

        Envelope envelope = new Envelope();
        envelope.setVersion(version.getValue().intValue());
        envelope.setRecipientInfo(recipientInfosFromASN1Set(recipients));
        envelope.setEncData(EncContent.fromASN1(encContent));
View Full Code Here

        if (subject instanceof X500Principal) {
            return ((X500Principal) subject).getEncoded();
        } else if (subject instanceof X509Name) {
            final ByteArrayOutputStream bout = new ByteArrayOutputStream();
            final DEROutputStream der = new DEROutputStream(bout);
            final DEREncodable nm = (DEREncodable) subject;
            der.writeObject(nm.getDERObject());
            return bout.toByteArray();
        } else {
            throw new ClassCastException("unsupported input class: "
                    + subject.getClass().toString());
        }
View Full Code Here

    if (subject instanceof X500Principal) {
      return ((X500Principal) subject).getEncoded();
    } else if (subject instanceof X509Name) {
      final ByteArrayOutputStream bout = new ByteArrayOutputStream();
      final DEROutputStream der = new DEROutputStream(bout);
      final DEREncodable nm = (DEREncodable) subject;
      der.writeObject(nm.getDERObject());
      return bout.toByteArray();
    } else {
      throw new ClassCastException("unsupported input class: "
          + subject.getClass().toString());
    }
View Full Code Here

    }

    static String getSignatureName(
        AlgorithmIdentifier sigAlgId)
    {
        DEREncodable params = sigAlgId.getParameters();

        if (params != null && !DERNull.INSTANCE.equals(params))
        {
            if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
            {
View Full Code Here

            return new ElGamalPrivateKeyParameters(derX.getValue(), new ElGamalParameters(params.getP(), params.getG()));
        }
        else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa))
        {
            DERInteger derX = (DERInteger)keyInfo.getPrivateKey();
            DEREncodable de = keyInfo.getAlgorithmId().getParameters();

            DSAParameters parameters = null;
            if (de != null)
            {
                DSAParameter params = DSAParameter.getInstance(de.getDERObject());
                parameters = new DSAParameters(params.getP(), params.getQ(), params.getG());
            }

            return new DSAPrivateKeyParameters(derX.getValue(), parameters);
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.ssl.asn1.DEREncodable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.