Code example for KeyFactory

Methods: generatePrivate

0
     * The test checks out that the method throws up InvalidKeySpecException 
     * if argument is neither "PKCS8EncodedKeySpec" nor "DSAPrivateKeySpec" 
     */ 
    public final void testGeneratePrivateKeySpec01() throws Exception { 
        try { 
            kf.generatePrivate(x509KeySpec);
            fail("testcase1: no InvalidKeySpecException");
        } catch (InvalidKeySpecException e) {
        } 
        try { 
            kf.generatePrivate(null);
            fail("testcase2: no InvalidKeySpecException");
        } catch (InvalidKeySpecException e) {
        } 
    } 
 
 
    /** 
     * A test against the "generatePrivate(KeySpec)" method. 
     * The test checks out that the method returns DSAPrivateKey 
     * if argument is "PKCS8EncodedKeySpec"