Code example for X509Certificate

Methods: getExtensionValue

0
     * Test 1 alt name: URI (URL). 
     * @throws SecurityException 
     * @throws CertificateParsingException  
     */ 
    public void testGetSubjectAltNames1NameURL() throws SecurityException, CertificateParsingException { 
        X509Certificate cert = entityCert1AltNameURL;
        // Sanity checks 
        byte[] extensionValue = cert.getExtensionValue(subjectAltNameExtensionOID);
        assertNotNull("Entity cert's Java native getExtensionValue() was null",  
                extensionValue);
        assertTrue("Entity cert's extension value was empty", extensionValue.length > 0);
        assertNotNull("Entity cert's Java native getSubjectAltenativeNames() was null",  
                cert.getSubjectAlternativeNames());
         
        Set<Integer> nameTypes = new HashSet<Integer>();
        nameTypes.add(altNameTypeURI);
         
        List altNames = getAltNames(cert, nameTypes);
        assertNotNull("X509Util.getAltNames() returned null", altNames);
         
        assertTrue("Failed to find expected KeyName value", altNames.contains(altNameURL));