Search in sources :

Example 1 with CertificateExtensions

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

the class X509Builder method keyUsageCRLSign.

public X509Builder keyUsageCRLSign() {
    try {
        v3();
        if (keyUsageExtension == null) {
            keyUsageExtension = new KeyUsageExtension();
        }
        keyUsageExtension.set(KeyUsageExtension.CRL_SIGN, true);
        if (certificateExtensions == null) {
            certificateExtensions = new CertificateExtensions();
        }
        certificateExtensions.set(keyUsageExtension.getExtensionId().toString(), keyUsageExtension);
        info.set(X509CertInfo.EXTENSIONS, certificateExtensions);
    } catch (Exception e) {
        fault(e, "keyUsageCRLSign");
    }
    return this;
}
Also used : CertificateExtensions(sun.security.x509.CertificateExtensions) KeyUsageExtension(sun.security.x509.KeyUsageExtension) ExtendedKeyUsageExtension(sun.security.x509.ExtendedKeyUsageExtension)

Example 2 with CertificateExtensions

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

the class X509Builder method extKeyUsage.

public X509Builder extKeyUsage(ObjectIdentifier oid) {
    try {
        v3();
        if (extendedKeyUsageExtensionList == null) {
            extendedKeyUsageExtensionList = new Vector<ObjectIdentifier>();
        }
        extendedKeyUsageExtensionList.add(oid);
        extendedKeyUsageExtension = new ExtendedKeyUsageExtension(extendedKeyUsageExtensionIsCritical, extendedKeyUsageExtensionList);
        if (certificateExtensions == null) {
            certificateExtensions = new CertificateExtensions();
        }
        certificateExtensions.set(extendedKeyUsageExtension.getExtensionId().toString(), extendedKeyUsageExtension);
        info.set(X509CertInfo.EXTENSIONS, certificateExtensions);
    } catch (Exception e) {
        fault(e, "extKeyUsage(%s)", oid.toString());
    }
    return this;
}
Also used : ExtendedKeyUsageExtension(sun.security.x509.ExtendedKeyUsageExtension) CertificateExtensions(sun.security.x509.CertificateExtensions) ObjectIdentifier(sun.security.util.ObjectIdentifier)

Example 3 with CertificateExtensions

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

the class X509Builder method keyUsageDataEncipherment.

public X509Builder keyUsageDataEncipherment() {
    // for encrypting data
    try {
        v3();
        if (keyUsageExtension == null) {
            keyUsageExtension = new KeyUsageExtension();
        }
        keyUsageExtension.set(KeyUsageExtension.DATA_ENCIPHERMENT, true);
        if (certificateExtensions == null) {
            certificateExtensions = new CertificateExtensions();
        }
        certificateExtensions.set(keyUsageExtension.getExtensionId().toString(), keyUsageExtension);
        info.set(X509CertInfo.EXTENSIONS, certificateExtensions);
    } catch (Exception e) {
        fault(e, "keyUsageDataEncipherment");
    }
    return this;
}
Also used : CertificateExtensions(sun.security.x509.CertificateExtensions) KeyUsageExtension(sun.security.x509.KeyUsageExtension) ExtendedKeyUsageExtension(sun.security.x509.ExtendedKeyUsageExtension)

Example 4 with CertificateExtensions

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

the class X509Builder method keyUsageDigitalSignature.

public X509Builder keyUsageDigitalSignature() {
    // other than CA or CRL;  so this applies to API clients
    try {
        v3();
        if (keyUsageExtension == null) {
            keyUsageExtension = new KeyUsageExtension();
        }
        keyUsageExtension.set(KeyUsageExtension.DIGITAL_SIGNATURE, true);
        if (certificateExtensions == null) {
            certificateExtensions = new CertificateExtensions();
        }
        certificateExtensions.set(keyUsageExtension.getExtensionId().toString(), keyUsageExtension);
        info.set(X509CertInfo.EXTENSIONS, certificateExtensions);
    } catch (Exception e) {
        fault(e, "keyUsageDigitalSignature");
    }
    return this;
}
Also used : CertificateExtensions(sun.security.x509.CertificateExtensions) KeyUsageExtension(sun.security.x509.KeyUsageExtension) ExtendedKeyUsageExtension(sun.security.x509.ExtendedKeyUsageExtension)

Example 5 with CertificateExtensions

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

the class X509Builder method dnsAlternativeName.

public X509Builder dnsAlternativeName(String dns) {
    try {
        v3();
        String alternativeName = dns;
        if (dns.startsWith("dns:")) {
            alternativeName = dns.substring(4);
        }
        DNSName dnsName = new DNSName(alternativeName);
        if (alternativeNames == null) {
            alternativeNames = new GeneralNames();
        }
        alternativeNames.add(new GeneralName(dnsName));
        SubjectAlternativeNameExtension san = new SubjectAlternativeNameExtension(alternativeNames);
        if (certificateExtensions == null) {
            certificateExtensions = new CertificateExtensions();
        }
        certificateExtensions.set(san.getExtensionId().toString(), san);
        info.set(X509CertInfo.EXTENSIONS, certificateExtensions);
    } catch (Exception e) {
        fault(e, "dnsAlternativeName(%s)", dns);
    }
    return this;
}
Also used : GeneralNames(sun.security.x509.GeneralNames) SubjectAlternativeNameExtension(sun.security.x509.SubjectAlternativeNameExtension) CertificateExtensions(sun.security.x509.CertificateExtensions) GeneralName(sun.security.x509.GeneralName) DNSName(sun.security.x509.DNSName)

Aggregations

CertificateExtensions (sun.security.x509.CertificateExtensions)17 ExtendedKeyUsageExtension (sun.security.x509.ExtendedKeyUsageExtension)8 ObjectIdentifier (sun.security.util.ObjectIdentifier)6 KeyUsageExtension (sun.security.x509.KeyUsageExtension)6 SubjectAlternativeNameExtension (sun.security.x509.SubjectAlternativeNameExtension)5 CertificateException (java.security.cert.CertificateException)4 Date (java.util.Date)4 GeneralName (sun.security.x509.GeneralName)4 GeneralNames (sun.security.x509.GeneralNames)4 X509CertImpl (sun.security.x509.X509CertImpl)4 X509CertInfo (sun.security.x509.X509CertInfo)4 IOException (java.io.IOException)3 DerEncoder (sun.security.util.DerEncoder)3 DerOutputStream (sun.security.util.DerOutputStream)3 Iterator (java.util.Iterator)2 DerValue (sun.security.util.DerValue)2 BasicConstraintsExtension (sun.security.x509.BasicConstraintsExtension)2 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)1 Method (java.lang.reflect.Method)1 BigInteger (java.math.BigInteger)1