Search in sources :

Example 6 with CertificateValidity

use of sun.security.x509.CertificateValidity in project OpenAttestation by OpenAttestation.

the class X509Builder method valid.

public X509Builder valid(Date from, Date to) {
    try {
        certificateValidity = new CertificateValidity(from, to);
        // CertificateException, IOException
        info.set(X509CertInfo.VALIDITY, certificateValidity);
    } catch (Exception e) {
        fault(e, "valid(%s,%s)", from == null ? "null" : from.toString(), to == null ? "null" : to.toString());
    }
    return this;
}
Also used : CertificateValidity(sun.security.x509.CertificateValidity)

Example 7 with CertificateValidity

use of sun.security.x509.CertificateValidity in project jdk8u_jdk by JetBrains.

the class SimpleSigner method getSelfCert.

private X509Certificate getSelfCert() throws Exception {
    long validity = 1000;
    X509CertImpl certLocal;
    Date firstDate, lastDate;
    firstDate = new Date();
    lastDate = new Date();
    lastDate.setTime(lastDate.getTime() + validity + 1000);
    CertificateValidity interval = new CertificateValidity(firstDate, lastDate);
    X509CertInfo info = new X509CertInfo();
    // Add all mandatory attributes
    info.set(X509CertInfo.VERSION, new CertificateVersion(CertificateVersion.V1));
    info.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber((int) (firstDate.getTime() / 1000)));
    info.set(X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId(algId));
    info.set(X509CertInfo.SUBJECT, agent);
    info.set(X509CertInfo.KEY, new CertificateX509Key(publicKey));
    info.set(X509CertInfo.VALIDITY, interval);
    info.set(X509CertInfo.ISSUER, agent);
    certLocal = new X509CertImpl(info);
    certLocal.sign(privateKey, algId.getName());
    return certLocal;
}
Also used : CertificateSerialNumber(sun.security.x509.CertificateSerialNumber) X509CertInfo(sun.security.x509.X509CertInfo) X509CertImpl(sun.security.x509.X509CertImpl) CertificateVersion(sun.security.x509.CertificateVersion) CertificateValidity(sun.security.x509.CertificateValidity) CertificateAlgorithmId(sun.security.x509.CertificateAlgorithmId) CertificateX509Key(sun.security.x509.CertificateX509Key) Date(java.util.Date)

Aggregations

CertificateValidity (sun.security.x509.CertificateValidity)6 CertificateAlgorithmId (sun.security.x509.CertificateAlgorithmId)5 X509CertImpl (sun.security.x509.X509CertImpl)5 Date (java.util.Date)4 AlgorithmId (sun.security.x509.AlgorithmId)4 CertificateSerialNumber (sun.security.x509.CertificateSerialNumber)4 CertificateVersion (sun.security.x509.CertificateVersion)4 CertificateX509Key (sun.security.x509.CertificateX509Key)4 X500Name (sun.security.x509.X500Name)4 X509CertInfo (sun.security.x509.X509CertInfo)4 BigInteger (java.math.BigInteger)3 CertificateIssuerName (sun.security.x509.CertificateIssuerName)3 CertificateSubjectName (sun.security.x509.CertificateSubjectName)3 PrivateKey (java.security.PrivateKey)2 SecureRandom (java.security.SecureRandom)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Field (java.lang.reflect.Field)1 KeyPair (java.security.KeyPair)1 KeyPairGenerator (java.security.KeyPairGenerator)1 PublicKey (java.security.PublicKey)1