Package org.apache.commons.ssl.asn1

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


          if (crlExt != null) {
            X509Extension ext = crlExt.getExtension(X509Extensions.ReasonCode);
            if (ext != null) {
              try {
                ASN1InputStream ai = new ASN1InputStream(ext.getValue().getOctets());
                DERObject obj = ai.readObject();
                DEREnumerated crlreason = DEREnumerated.getInstance(obj);
                // RevokedCertInfo.REVOCATION_REASON_AACOMPROMISE are the same integer values as the CRL reason extension code
                reason = crlreason.getValue().intValue();
                LOG.debug("CRLReason extension: "+reason);
              } catch (IOException e) {
View Full Code Here


                        X509Extension ext = exts.getExtension(X509Extensions.KeyUsage);
                        if (ext != null) {
                          ASN1OctetString os = ext.getValue();
                          ByteArrayInputStream bIs = new ByteArrayInputStream(os.getOctets());
                          ASN1InputStream dIs = new ASN1InputStream(bIs);
                          DERObject dob = dIs.readObject();
                          DERBitString bs = DERBitString.getInstance(dob);
                          keyusage = bs.intValue();                                                           
                          if (log.isDebugEnabled()) {
                            log.debug("We have a key usage request extension: "+keyusage);
                          }
View Full Code Here

  // convert PKCS#8 format to PKCS#1.
  private byte[] convert8to1(byte[] data) throws Exception {
    log.debug("SOTProxyCreateServlet::convert8to1() start.");

    DERObject keyInfo = SOTSignOnToolUtil.toDERObject(data);
    PrivateKeyInfo pkey = new PrivateKeyInfo(
        (DERConstructedSequence) keyInfo);
    // new PrivateKeyInfo((DERSequence)keyInfo);
    DERObject derKey = pkey.getPrivateKey();

    return SOTSignOnToolUtil.toByteArray(derKey);
  }
View Full Code Here

            throw new RuntimeException(e);
        }
    }

    private static TBSCertificateStructure getTBSCertificate(X509Certificate cert) throws GeneralSecurityException {
        DERObject derObject = toDer(cert.getTBSCertificate());
        return TBSCertificateStructure.getInstance(derObject);
    }
View Full Code Here

        // default for ordering
        ordering = new DERBoolean(false);
       
        while (e.hasMoreElements())
        {
            DERObject o = (DERObject) e.nextElement();

            if (o instanceof ASN1TaggedObject)
            {
                DERTaggedObject tagged = (DERTaggedObject) o;
View Full Code Here

    private DERObject getKeySpec() throws NoSuchAlgorithmException,
            InvalidKeySpecException, NoSuchProviderException
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        DERObject obj = null;
        try
        {

            baos.write(pubkey.getEncoded());
            baos.close();
View Full Code Here

                pkcs7input[20] = four;
                pkcs7input[21] = three;
                pkcs7input[22] = two;
                pkcs7input[23] = one;

                DERObject obj = createDERForRecipient(pkcs7input, certificate);

                ByteArrayOutputStream baos = new ByteArrayOutputStream();

                DEROutputStream k = new DEROutputStream(baos);
View Full Code Here

        AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance(s);
        AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
        ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
        DERObject derobject = asn1inputstream.readObject();
        KeyGenerator keygenerator = KeyGenerator.getInstance(s);
        keygenerator.init(128);
        SecretKey secretkey = keygenerator.generateKey();
        Cipher cipher = Cipher.getInstance(s);
        cipher.init(1, secretkey, algorithmparameters);
View Full Code Here

        if (crldpExt == null) {
            return new ArrayList<String>();
        }
        ASN1InputStream oAsnInStream = new ASN1InputStream(
                new ByteArrayInputStream(crldpExt));
        DERObject derObjCrlDP = oAsnInStream.readObject();
        DEROctetString dosCrlDP = (DEROctetString) derObjCrlDP;
        byte[] crldpExtOctets = dosCrlDP.getOctets();
        ASN1InputStream oAsnInStream2 = new ASN1InputStream(
                new ByteArrayInputStream(crldpExtOctets));
        DERObject derObj2 = oAsnInStream2.readObject();
        CRLDistPoint distPoint = CRLDistPoint.getInstance(derObj2);
        List<String> crlUrls = new ArrayList<String>();
        for (DistributionPoint dp : distPoint.getDistributionPoints()) {
            DistributionPointName dpn = dp.getDistributionPoint();
            // Look for URIs in fullName
View Full Code Here

{
    public TestResult perform()
    {
        byte[]  data = { 0, 1, 0, 1, 0, 0, 1 };
       
        DERObject    values[] = {
                new BERConstructedOctetString(data),
                new BERSequence(new DERPrintableString("hello world")),
                new BERSet(new DERPrintableString("hello world")),
                new BERTaggedObject(0, new DERPrintableString("hello world")),
                new DERApplicationSpecific(0 | DERTags.APPLICATION, data),
                new DERBitString(data),
                new DERBMPString("hello world"),
                new DERBoolean(true),
                new DERBoolean(false),
                new DEREnumerated(100),
                new DERGeneralizedTime(new Date()),
                new DERGeneralString("hello world"),
                new DERIA5String("hello"),
                new DERInteger(1000),
                new DERNull(),
                new DERNumericString("123456"),
                new DERObjectIdentifier("1.1.1.10000.1"),
                new DEROctetString(data),
                new DERPrintableString("hello world"),
                new DERSequence(new DERPrintableString("hello world")),
                new DERSet(new DERPrintableString("hello world")),
                new DERT61String("hello world"),
                new DERTaggedObject(0, new DERPrintableString("hello world")),
                new DERUniversalString(data),
                new DERUnknownTag(0xff & (~(DERTags.TAGGED | DERTags.APPLICATION)), data),
                new DERUTCTime(new Date()),
                new DERUTF8String("hello world"),
                new DERVisibleString("hello world")
            };
       
        try
        {
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            ASN1OutputStream        aOut = new ASN1OutputStream(bOut);
           
            for (int i = 0; i != values.length; i++)
            {
                aOut.writeObject(values[i]);
            }
           
            DERObject[] readValues = new DERObject[values.length];
           
            ByteArrayInputStream    bIn = new ByteArrayInputStream(bOut.toByteArray());
            ASN1InputStream         aIn = new ASN1InputStream(bIn);
           
            for (int i = 0; i != values.length; i++)
            {
                DERObject   o = aIn.readObject();
                if (!o.equals(values[i]))
                {
                    return new SimpleTestResult(false, getName() + ": Failed equality test for " + o);
                }
               
                if (o.hashCode() != values[i].hashCode())
                {
                    return new SimpleTestResult(false, getName() + ": Failed hashCode test for " + o);
                }
            }
        }
View Full Code Here

TOP

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

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.