use of org.mozilla.jss.netscape.security.x509.URIName in project jdk8u_jdk by JetBrains.
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;
}
use of org.mozilla.jss.netscape.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.");
}
use of org.mozilla.jss.netscape.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;
}
use of org.mozilla.jss.netscape.security.x509.URIName in project jss by dogtagpki.
the class AuthInfoAccessExtension 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());
}
}
Aggregations