Code example for InvalidKeyException

0
            throw new InvalidKeyException("key parameter is null");
        } 
         
        if (!key.getAlgorithm().equalsIgnoreCase(algName))
        { 
            throw new InvalidKeyException("Key not of type " + algName + ".");
        } 
 
        return new SecretKeySpec(key.getEncoded(), algName);
    } 
 
    /* 
     * classes that inherit from us 
     */ 
     
    static public class PBEKeyFactory 
        extends JCESecretKeyFactory 
    { 
        private boolean forCipher;
        private int     scheme;
        private int     digest;