Code example for TrustAnchor

Methods: getNameConstraints

0
        PublicKey pk = new TestKeyPair(keyAlg).getPublic();
 
        byte[] nc = getEncodingPSOnly();
        byte[] ncCopy = nc.clone();
        // sub testcase 5 - nameConstraints can be null 
        TrustAnchor ta = new TrustAnchor(new X500Principal(validCaNameRfc2253),
                pk, ncCopy);
        // modify 
        ncCopy[0]=(byte)0;
        // check that above modification did not change 
        // object internal state 
        assertTrue(Arrays.equals(nc, ta.getNameConstraints()));
    } 
 
    /** 
     * Test #4 for <code>TrustAnchor(X500Principal, PublicKey, byte[])</code> constructor<br>  
     * Assertion: <code>NullPointerException</code> if <code>caPrincipal</code> 
     * or <code>caPublicKey</code> parameter is <code>null</code><br> 
     * Test preconditions: pass <code>null</code> as mentioned parameter<br> 
     * Expected: NullPointerException 
     * @throws InvalidKeySpecException