Package org.jruby.ext.openssl

Examples of org.jruby.ext.openssl.ASN1$ASN1Primitive


        assertTrue(Math.abs(begin.getTime() - resultCert.getNotBefore().getTime()) < 1000);
        assertTrue(Math.abs(ends.getTime() - resultCert.getNotAfter().getTime()) < 1000);

        byte[] subjectKeyIdentifierExtValue = resultCert.getExtensionValue(X509Extension.subjectKeyIdentifier.getId());
        assertNotNull(subjectKeyIdentifierExtValue);
        ASN1Primitive subjectKeyIdentifier = JcaX509ExtensionUtils.parseExtensionValue(
                subjectKeyIdentifierExtValue);
        ASN1Primitive expSKI = jxeu.createSubjectKeyIdentifier(pubKey).toASN1Primitive();
        assertArrayEquals(expSKI.getEncoded(), subjectKeyIdentifier.getEncoded());

        byte[] authorityKeyIdentifierExtValue = resultCert.getExtensionValue(X509Extension.authorityKeyIdentifier.getId());
        ASN1Primitive authorityKeyIdentifier = JcaX509ExtensionUtils.parseExtensionValue(
                authorityKeyIdentifierExtValue);
        ASN1Primitive expAKI = jxeu.createAuthorityKeyIdentifier(caPubKey).toASN1Primitive();
        assertArrayEquals(expAKI.getEncoded(), authorityKeyIdentifier.getEncoded());

        assertEquals(-1, resultCert.getBasicConstraints());

        byte[] netscapeCertTypeExtValue = resultCert.getExtensionValue(MiscObjectIdentifiers.netscapeCertType.getId());
        assertNotNull(netscapeCertTypeExtValue);
View Full Code Here


        if (!DSA_TYPE.equals(pemObj.getType())) {
            throw new CryptoException("PEM file does not contain a DSA private key");
        }

        ASN1InputStream asnIn = new ASN1InputStream(pemObj.getContent());
        ASN1Primitive ao = asnIn.readObject();
        if (ao == null) {
            throw new CryptoException("PEM file does not contain an ASN.1 object");
        }
        if (!(ao instanceof ASN1Sequence)) {
            throw new CryptoException("PEM file does not contain a sequence");
View Full Code Here

                DERInteger p = (DERInteger)identifiers.getObjectAt(0);
                DERInteger q = (DERInteger)identifiers.getObjectAt(1);
                DERInteger g = (DERInteger)identifiers.getObjectAt(2);

                ASN1Primitive pkPrim = pk.parsePublicKey();
                if (!(pkPrim instanceof ASN1Integer)) {
                    throw new CryptoException("Invalid DSA public key format: Public key is not an integer");
                }
                DERInteger y = (DERInteger)pkPrim;
View Full Code Here

    return s;
  }

  public static ASN1Primitive toASN1Primitive(final byte[] bytes) throws IOException {
    ASN1InputStream inputStream = new ASN1InputStream(bytes);
    ASN1Primitive obj = inputStream.readObject();
    inputStream.close();
    return obj;
  }
View Full Code Here

    DERSequence sequence = (DERSequence) BouncyCastleProviderHelper.toASN1Primitive(bytes);
    return sequence;
  }

  public static String getStringFromTag(final DERTaggedObject tag) {
    ASN1Primitive obj = tag.getObject();
    return ICPBrasilHelper.getStringFromObject(obj);
  }
View Full Code Here

    if (crldistribuitionPointsBytes == null) {
      return new URL[0];
    }

    ASN1Primitive crldistribuitionPointsObject = BouncyCastleProviderHelper.toASN1Primitive(crldistribuitionPointsBytes);
    DEROctetString crldistribuitionPointsString = (DEROctetString) crldistribuitionPointsObject;

    crldistribuitionPointsObject = BouncyCastleProviderHelper.toASN1Primitive(crldistribuitionPointsString.getOctets());
    CRLDistPoint distPoint = CRLDistPoint.getInstance(crldistribuitionPointsObject);
View Full Code Here

    if (crldistribuitionPointsBytes == null) {
      return new URL[0];
    }

    ASN1Primitive crldistribuitionPointsObject = BouncyCastleProviderHelper.toASN1Primitive(crldistribuitionPointsBytes);
    DEROctetString crldistribuitionPointsString = (DEROctetString) crldistribuitionPointsObject;

    crldistribuitionPointsObject = BouncyCastleProviderHelper.toASN1Primitive(crldistribuitionPointsString.getOctets());
    CRLDistPoint distPoint = CRLDistPoint.getInstance(crldistribuitionPointsObject);
View Full Code Here

        SignerInformationStore signerInformationStore = signedData.getSignerInfos();
        List list = new ArrayList();
        for (Object o : signerInformationStore.getSigners()) {
          SignerInformation signerInformation = (SignerInformation) o;
          TimeStamp timeStamp = timeStampClient.getTimeStamp(signerInformation.getSignature());
          ASN1Primitive asn1Primitive = BouncyCastleProviderHelper.toASN1Primitive(timeStamp.getEncoded());
          DERSet derSet = new DERSet(asn1Primitive);

          Hashtable hashtable = new Hashtable();
          Attribute attribute = new Attribute(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken, derSet);
          hashtable.put(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken, attribute);
View Full Code Here

          // unsignedAttributeTable, PKCSObjectIdentifiers.pkcs_9_at_messageDigest);

          DERSequence timeStampDerSequence = this.getAttribute(signedAttributeTable, unsignedAttributeTable, PKCSObjectIdentifiers.id_aa_signatureTimeStampToken);
          if (timeStampDerSequence != null) {
            if (timeStampDerSequence.size() == 2) {
              ASN1Primitive derObjectIdentifier = ((ASN1Primitive) timeStampDerSequence.getObjectAt(0)).toASN1Primitive();
              ASN1Primitive derObjectValue = ((ASN1Primitive) timeStampDerSequence.getObjectAt(1)).toASN1Primitive();
              if ((derObjectIdentifier instanceof ASN1ObjectIdentifier) && (derObjectValue instanceof DERSet)) {
                // ASN1ObjectIdentifier asn1ObjectIdentifier = (ASN1ObjectIdentifier)
                // derObjectIdentifier;
                DERSet set = (DERSet) derObjectValue;
                ASN1Encodable encodable = set.getObjectAt(0);
                TimeStampToken timeStampToken = new TimeStampToken(new CMSSignedData(encodable.toASN1Primitive().getEncoded()));
                TimeStamp timeStamp = BouncyCastleTimeStampHelper.toTimeStamp(timeStampToken);
                signature.setTimeStamp(timeStamp);
              }
            }
          }

          DERSequence signTimeDerSequence = this.getAttribute(signedAttributeTable, unsignedAttributeTable, PKCSObjectIdentifiers.pkcs_9_at_signingTime);
          if (signTimeDerSequence != null) {
            ASN1Primitive derObjectIdentifier = ((ASN1Primitive) signTimeDerSequence.getObjectAt(0)).toASN1Primitive();
            ASN1Primitive derObjectValue = ((ASN1Primitive) signTimeDerSequence.getObjectAt(1)).toASN1Primitive();
            if ((derObjectIdentifier instanceof ASN1ObjectIdentifier) && (derObjectValue instanceof DERSet)) {
              DERSet set = (DERSet) derObjectValue;
              ASN1UTCTime time = (ASN1UTCTime) set.getObjectAt(0);
              signature.setDate(time.getAdjustedDate());
            }
View Full Code Here

  public static String toString(final byte[] bytes) {
    return new String(bytes, ConstantesICPBrasil.DEFAULT_CHARSET);
  }

  public static String getStringFromTag(final DERTaggedObject tag) {
    ASN1Primitive obj = tag.getObject();
    return ICPBrasilHelper.getStringFromObject(obj);
  }
View Full Code Here

TOP

Related Classes of org.jruby.ext.openssl.ASN1$ASN1Primitive

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.