Search in sources :

Example 6 with PKCS10

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();
}
Also used : PKCS10Attribute(sun.security.pkcs10.PKCS10Attribute)

Example 7 with PKCS10

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.");
}
Also used : PKCS10(sun.security.pkcs10.PKCS10)

Aggregations

PKCS10 (sun.security.pkcs10.PKCS10)6 PKCS10Attribute (sun.security.pkcs10.PKCS10Attribute)5 PrivateKey (java.security.PrivateKey)3 Signature (java.security.Signature)3 PublicKey (java.security.PublicKey)2 Certificate (java.security.cert.Certificate)2 CertificateException (java.security.cert.CertificateException)2 X509Certificate (java.security.cert.X509Certificate)2 ObjectIdentifier (sun.security.util.ObjectIdentifier)2 IOException (java.io.IOException)1 Key (java.security.Key)1 KeyPair (java.security.KeyPair)1 KeyPairGenerator (java.security.KeyPairGenerator)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 UnrecoverableEntryException (java.security.UnrecoverableEntryException)1 UnrecoverableKeyException (java.security.UnrecoverableKeyException)1 CertStoreException (java.security.cert.CertStoreException)1 MessageFormat (java.text.MessageFormat)1 GregorianCalendar (java.util.GregorianCalendar)1