Search in sources :

Example 6 with URIName

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

the class Parse method main.

public static void main(String[] args) throws Exception {
    /* Try to parse a CRLDistributionPointsExtension URI with a space. */
    try {
        CRLDistributionPointsExtensionTest(certWithSpaceInCDPStr);
        throw new RuntimeException("Illegally parsed a " + "CRLDistributionPointsExtension uri with a space.");
    } catch (IOException e) {
        System.out.println("Caught the correct exception.");
    }
    /* Try to parse a CRLDistributionPointsExtension URI with backslashes. */
    try {
        CRLDistributionPointsExtensionTest(certWithBackslashesInCDPStr);
        throw new RuntimeException("Illegally parsed a " + "CRLDistributionPointsExtension uri with a backslashes.");
    } catch (IOException e) {
        System.out.println("Caught the correct exception.");
    }
    /* Try to construct a URIName from a uri with a space. */
    String uriWithSpace = "file://crl file.crl";
    URIName name;
    try {
        name = new URIName(uriWithSpace);
        throw new RuntimeException("Illegally created a URIName " + "from a uri with a space.");
    } catch (IOException e) {
        System.out.println("Caught the correct exception.");
    }
    /* Try to construct a URIName from a uri with backslashes. */
    String uriWithBackslashes = "file://\\\\CRL\\crl_file.crl";
    try {
        name = new URIName(uriWithBackslashes);
        throw new RuntimeException("Illegally created a URIName " + "from a uri with backslashes.");
    } catch (IOException e) {
        System.out.println("Caught the correct exception.");
    }
    System.out.println("Tests passed.");
}
Also used : IOException(java.io.IOException) URIName(sun.security.x509.URIName)

Example 7 with URIName

use of sun.security.x509.URIName in project Bytecoder by mirkosertic.

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(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)

Aggregations

URIName (sun.security.x509.URIName)7 IOException (java.io.IOException)4 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 CertificateException (java.security.cert.CertificateException)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 URICertStoreParameters (java.security.cert.URICertStoreParameters)1