Code example for InvalidKeySpecException

0
 
            return (KeySpec)c.newInstance(p);
        } 
        catch (Exception e)
        { 
            throw new InvalidKeySpecException(e.toString());
        } 
    } 
 
    protected SecretKey engineTranslateKey(
        SecretKey key)
    throws InvalidKeyException 
    { 
        if (key == null)
        { 
            throw new InvalidKeyException("key parameter is null");
        } 
         
        if (!key.getAlgorithm().equalsIgnoreCase(algName))
        { 
            throw new InvalidKeyException("Key not of type " + algName + ".");