Package org.apache.geronimo.crypto.asn1.x509

Examples of org.apache.geronimo.crypto.asn1.x509.V3TBSCertificateGenerator


        return (DERObjectIdentifier) dIn.readObject();
    }

    public static byte[] encodeGeneralName(String name) throws IOException {
        return encodeGeneralName(new X509Name(name));
    }
View Full Code Here


    public String generateCSR(X509Certificate cert, PrivateKey signingKey)
            throws Exception {

        String sigalg = cert.getSigAlgName();
        X509Name subject = new X509Name(cert.getSubjectDN().toString());
        PublicKey publicKey = cert.getPublicKey();
        ASN1Set attributes = null;

        PKCS10CertificationRequest csr = new PKCS10CertificationRequest(sigalg,
                subject, publicKey, attributes, signingKey);
View Full Code Here

        DERObject subPubkeyDerObj = ais.readObject();
        SubjectPublicKeyInfo subPubKeyInfo = SubjectPublicKeyInfo.getInstance(subPubkeyDerObj);
       
        // Create certificate generator and initialize fields
        // Certificate version is v3
        V3TBSCertificateGenerator v3certGen = new V3TBSCertificateGenerator();
        // Subject info
        v3certGen.setSubject(subName);
        v3certGen.setSubjectPublicKeyInfo(subPubKeyInfo);
        // Issuer info
        v3certGen.setIssuer(caName);
        // serial number
        v3certGen.setSerialNumber(new DERInteger(serialNum));
        // validity
        v3certGen.setStartDate(new Time(validFromDate));
        v3certGen.setEndDate(new Time(validToDate));
        // signature algorithm
        v3certGen.setSignature(algId);
       
        // Get the certificate info to be signed
        TBSCertificateStructure tbsCert = v3certGen.generateTBSCertificate();
        byte[] tobesigned = tbsCert.getEncoded();
       
        // Create the signature
        Signature signatureObj = Signature.getInstance(algorithm);
        signatureObj.initSign(caPriKey);
View Full Code Here

        DERObject subPubkeyDerObj = ais.readObject();
        SubjectPublicKeyInfo subPubKeyInfo = SubjectPublicKeyInfo.getInstance(subPubkeyDerObj);
       
        // Create certificate generator and initialize fields
        // Certificate version is v3
        V3TBSCertificateGenerator v3certGen = new V3TBSCertificateGenerator();
        // Subject info
        v3certGen.setSubject(subName);
        v3certGen.setSubjectPublicKeyInfo(subPubKeyInfo);
        // Issuer info
        v3certGen.setIssuer(caName);
        // serial number
        v3certGen.setSerialNumber(new DERInteger(serialNum));
        // validity
        v3certGen.setStartDate(new Time(validFromDate));
        v3certGen.setEndDate(new Time(validToDate));
        // signature algorithm
        v3certGen.setSignature(algId);
       
        // Get the certificate info to be signed
        TBSCertificateStructure tbsCert = v3certGen.generateTBSCertificate();
        byte[] tobesigned = tbsCert.getEncoded();
       
        // Create the signature
        Signature signatureObj = Signature.getInstance(algorithm);
        signatureObj.initSign(caPriKey);
View Full Code Here

    algorithms.put("ECDSAWITHSHA1", new DERObjectIdentifier("1.2.840.10045.4.1"));
    }

    public X509V3CertificateGenerator()
    {
        tbsGen = new V3TBSCertificateGenerator();
    }
View Full Code Here

    /**
     * reset the generator
     */
    public void reset()
    {
        tbsGen = new V3TBSCertificateGenerator();
        extensions = null;
        extOrdering = null;
    }
View Full Code Here

      List<Extension> orderedExtensions = getExtensionsWithoutPoison(
          parsedPreCertificate.getTBSCertificate().getExtensions(),
          issuerInformation.getX509authorityKeyIdentifier());

      V3TBSCertificateGenerator tbsCertificateGenerator = new V3TBSCertificateGenerator();
      TBSCertificate tbsPart = parsedPreCertificate.getTBSCertificate();
      // Copy certificate.
      // Version 3 is implied by the generator.
      tbsCertificateGenerator.setSerialNumber(tbsPart.getSerialNumber());
      tbsCertificateGenerator.setSignature(tbsPart.getSignature());
      if (issuerInformation.getName() != null) {
        tbsCertificateGenerator.setIssuer(issuerInformation.getName());
      } else {
        tbsCertificateGenerator.setIssuer(tbsPart.getIssuer());
      }
      tbsCertificateGenerator.setStartDate(tbsPart.getStartDate());
      tbsCertificateGenerator.setEndDate(tbsPart.getEndDate());
      tbsCertificateGenerator.setSubject(tbsPart.getSubject());
      tbsCertificateGenerator.setSubjectPublicKeyInfo(tbsPart.getSubjectPublicKeyInfo());
      tbsCertificateGenerator.setIssuerUniqueID(tbsPart.getIssuerUniqueId());
      tbsCertificateGenerator.setSubjectUniqueID(tbsPart.getSubjectUniqueId());
      tbsCertificateGenerator.setExtensions(
          new Extensions(orderedExtensions.toArray(new Extension[]{})));
      return tbsCertificateGenerator.generateTBSCertificate();
    } catch (CertificateException e) {
      throw new CertificateTransparencyException("Certificate error: " + e.getMessage(), e);
    } catch (IOException e) {
      throw new CertificateTransparencyException("Error deleting extension: " + e.getMessage(), e);
    }
View Full Code Here

    private String                      signatureAlgorithm;
    private X509ExtensionsGenerator     extGenerator;

    public X509V3CertificateGenerator()
    {
        tbsGen = new V3TBSCertificateGenerator();
        extGenerator = new X509ExtensionsGenerator();
    }
View Full Code Here

    /**
     * reset the generator
     */
    public void reset()
    {
        tbsGen = new V3TBSCertificateGenerator();
        extGenerator.reset();
    }
View Full Code Here

    private String                      signatureAlgorithm;
    private X509ExtensionsGenerator     extGenerator;

    public X509V3CertificateGenerator()
    {
        tbsGen = new V3TBSCertificateGenerator();
        extGenerator = new X509ExtensionsGenerator();
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.crypto.asn1.x509.V3TBSCertificateGenerator

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.