Search in sources :

Example 1 with URIName

use of org.mozilla.jss.netscape.security.x509.URIName in project jss by dogtagpki.

the class SubjectInfoAccessExtension method main.

public static void main(String[] argv) {
    AuthInfoAccessExtension aia = new AuthInfoAccessExtension(false);
    GeneralName ocspName = new GeneralName(new URIName("http://ocsp.netscape.com"));
    aia.addAccessDescription(METHOD_OCSP, ocspName);
    GeneralName caIssuersName = new GeneralName(new URIName("http://ocsp.netscape.com"));
    aia.addAccessDescription(METHOD_CA_ISSUERS, caIssuersName);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        aia.encode(os);
        System.out.println(Utils.base64encode(os.toByteArray(), true));
    } catch (IOException e) {
        System.out.println(e.toString());
    }
    try {
        // test serialization
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(aia);
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bis);
        AuthInfoAccessExtension clone = (AuthInfoAccessExtension) ois.readObject();
        System.out.println(clone);
    } catch (Exception e) {
        System.out.println(e.toString());
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) GeneralName(org.mozilla.jss.netscape.security.x509.GeneralName) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) URIName(org.mozilla.jss.netscape.security.x509.URIName) ObjectInputStream(java.io.ObjectInputStream)

Example 2 with URIName

use of org.mozilla.jss.netscape.security.x509.URIName in project j2objc by google.

the class URICertStore method getInstance.

/**
 * Creates a CertStore from information included in the AccessDescription
 * object of a certificate's Authority Information Access Extension.
 */
static CertStore getInstance(AccessDescription ad) {
    if (!ad.getAccessMethod().equals((Object) AccessDescription.Ad_CAISSUERS_Id)) {
        return null;
    }
    GeneralNameInterface gn = ad.getAccessLocation().getName();
    if (!(gn instanceof URIName)) {
        return null;
    }
    URI uri = ((URIName) gn).getURI();
    try {
        return URICertStore.getInstance(new URICertStore.URICertStoreParameters(uri));
    } catch (Exception ex) {
        if (debug != null) {
            debug.println("exception creating CertStore: " + ex);
            ex.printStackTrace();
        }
        return null;
    }
}
Also used : GeneralNameInterface(sun.security.x509.GeneralNameInterface) URI(java.net.URI) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) CertStoreException(java.security.cert.CertStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CRLException(java.security.cert.CRLException) URIName(sun.security.x509.URIName)

Example 3 with URIName

use of org.mozilla.jss.netscape.security.x509.URIName in project j2objc by google.

the class OCSP method getResponderURI.

static URI getResponderURI(X509CertImpl certImpl) {
    // Examine the certificate's AuthorityInfoAccess extension
    AuthorityInfoAccessExtension aia = certImpl.getAuthorityInfoAccessExtension();
    if (aia == null) {
        return null;
    }
    List<AccessDescription> descriptions = aia.getAccessDescriptions();
    for (AccessDescription description : descriptions) {
        if (description.getAccessMethod().equals((Object) AccessDescription.Ad_OCSP_Id)) {
            GeneralName generalName = description.getAccessLocation();
            if (generalName.getType() == GeneralNameInterface.NAME_URI) {
                URIName uri = (URIName) generalName.getName();
                return uri.getURI();
            }
        }
    }
    return null;
}
Also used : AuthorityInfoAccessExtension(sun.security.x509.AuthorityInfoAccessExtension) AccessDescription(sun.security.x509.AccessDescription) GeneralName(sun.security.x509.GeneralName) URIName(sun.security.x509.URIName)

Example 4 with URIName

use of org.mozilla.jss.netscape.security.x509.URIName in project jdk8u_jdk by JetBrains.

the class URICertStore method getInstance.

/**
     * Creates a CertStore from information included in the AccessDescription
     * object of a certificate's Authority Information Access Extension.
     */
static CertStore getInstance(AccessDescription ad) {
    if (!ad.getAccessMethod().equals((Object) AccessDescription.Ad_CAISSUERS_Id)) {
        return null;
    }
    GeneralNameInterface gn = ad.getAccessLocation().getName();
    if (!(gn instanceof URIName)) {
        return null;
    }
    URI uri = ((URIName) gn).getURI();
    try {
        return URICertStore.getInstance(new URICertStore.URICertStoreParameters(uri));
    } catch (Exception ex) {
        if (debug != null) {
            debug.println("exception creating CertStore: " + ex);
            ex.printStackTrace();
        }
        return null;
    }
}
Also used : GeneralNameInterface(sun.security.x509.GeneralNameInterface) URI(java.net.URI) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) CertStoreException(java.security.cert.CertStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CRLException(java.security.cert.CRLException) URIName(sun.security.x509.URIName)

Example 5 with URIName

use of org.mozilla.jss.netscape.security.x509.URIName in project Bytecoder by mirkosertic.

the class URICertStore method getInstance.

/**
 * Creates a CertStore from information included in the AccessDescription
 * object of a certificate's Authority Information Access Extension.
 */
static CertStore getInstance(AccessDescription ad) {
    if (!ad.getAccessMethod().equals(AccessDescription.Ad_CAISSUERS_Id)) {
        return null;
    }
    GeneralNameInterface gn = ad.getAccessLocation().getName();
    if (!(gn instanceof URIName)) {
        return null;
    }
    URI uri = ((URIName) gn).getURI();
    try {
        return URICertStore.getInstance(new URICertStoreParameters(uri));
    } catch (Exception ex) {
        if (debug != null) {
            debug.println("exception creating CertStore: " + ex);
            ex.printStackTrace();
        }
        return null;
    }
}
Also used : GeneralNameInterface(sun.security.x509.GeneralNameInterface) URICertStoreParameters(java.security.cert.URICertStoreParameters) URI(java.net.URI) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) CertStoreException(java.security.cert.CertStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CRLException(java.security.cert.CRLException) URIName(sun.security.x509.URIName)

Aggregations

URIName (sun.security.x509.URIName)7 IOException (java.io.IOException)6 CertificateException (java.security.cert.CertificateException)5 URI (java.net.URI)3 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 CRLException (java.security.cert.CRLException)3 CertStoreException (java.security.cert.CertStoreException)3 AccessDescription (sun.security.x509.AccessDescription)3 AuthorityInfoAccessExtension (sun.security.x509.AuthorityInfoAccessExtension)3 GeneralName (sun.security.x509.GeneralName)3 GeneralNameInterface (sun.security.x509.GeneralNameInterface)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 GeneralName (org.mozilla.jss.netscape.security.x509.GeneralName)2 URIName (org.mozilla.jss.netscape.security.x509.URIName)2 URICertStoreParameters (java.security.cert.URICertStoreParameters)1