Code example for KeyFactory

Methods: generatePublic

0
     * The test checks out that the method throws up InvalidKeySpecException 
     * if argument is neither "X509EncodedKeySpec" nor "DSAPublicKeySpec" 
     */ 
    public final void testGeneratePublicKeySpec01() throws Exception { 
        try { 
            kf.generatePublic(pkcs8KeySpec);
            fail("testcase1: no InvalidKeySpecException");
        } catch (InvalidKeySpecException e) {
        } 
        try { 
            kf.generatePublic(null);
            fail("testcase2: no InvalidKeySpecException");
        } catch (InvalidKeySpecException e) {
        } 
    } 
 
 
    /** 
     * A test against the "generatePublic(KeySpec)" method. 
     * The test checks out that the method returns DSAPublicKey 
     * if argument is "X509EncodedKeySpec"