Code example for InvalidKeySpecException

0
                } 
 
                throw new InvalidKeySpecException("'keySpec' is neither DSAPublicKeySpec nor X509EncodedKeySpec");
            } 
        } 
        throw new InvalidKeySpecException("'key' is neither DSAPublicKey nor DSAPrivateKey");
    } 
 
    /** 
     * The method generates a DSAPublicKey object from the provided key. 
     * 
     * @param 
     *    key - a DSAPublicKey object or DSAPrivateKey object. 
     * 
     * @return 
     *    object of the same type as the "key" argument 
     * 
     * @throws InvalidKeyException 
     *     if "key" is neither DSAPublicKey nor DSAPrivateKey 
     */ 
    protected Key engineTranslateKey(Key key) throws InvalidKeyException {