use of sun.security.pkcs10.PKCS10 in project jdk8u_jdk by JetBrains.
the class PKCS10AttrEncoding method checkAttributes.
static void checkAttributes(Enumeration attrs) {
int numOfAttrs = 0;
while (attrs.hasMoreElements()) {
numOfAttrs++;
PKCS10Attribute attr = (PKCS10Attribute) attrs.nextElement();
if (constructedMap.containsKey(attr.getAttributeId())) {
if (constructedMap.get(attr.getAttributeId()).equals(attr.getAttributeValue())) {
System.out.print("AttributeId: " + attr.getAttributeId());
System.out.println(" AttributeValue: " + attr.getAttributeValue());
} else {
failedCount++;
System.out.print("< AttributeId: " + attr.getAttributeId());
System.out.println(" AttributeValue: " + constructedMap.get(attr.getAttributeId()));
System.out.print("< AttributeId: " + attr.getAttributeId());
System.out.println(" AttributeValue: " + attr.getAttributeValue());
}
} else {
failedCount++;
System.out.println("No " + attr.getAttributeId() + " in DER encoded PKCS10 Request");
}
}
if (numOfAttrs != constructedMap.size()) {
failedCount++;
System.out.println("Incorrect number of attributes.");
}
System.out.println();
}
use of sun.security.pkcs10.PKCS10 in project jdk8u_jdk by JetBrains.
the class UnstructuredName method main.
public static void main(String[] args) throws Exception {
PKCS10 req = new PKCS10(Base64.getMimeDecoder().decode(csrStr));
// If PKCS9Attribute did not accept the PrintableString ASN.1 tag,
// this would fail with an IOException
Object attr = req.getAttributes().getAttribute("1.2.840.113549.1.9.2");
// Check that the attribute exists
if (attr == null) {
throw new Exception("Attribute should not be null.");
}
System.out.println("Test passed.");
}
Aggregations