Code example for InvalidKeyException

0
        { 
            throw new InvalidKeyException(e.getMessage());
        } 
        catch (IllegalBlockSizeException e2)
        { 
            throw new InvalidKeyException(e2.getMessage());
        } 
 
        if (wrappedKeyType == Cipher.SECRET_KEY)
        { 
            return new SecretKeySpec(encoded, wrappedKeyAlgorithm);
        } 
        /* 
        else if (wrappedKeyAlgorithm.equals("") && wrappedKeyType == Cipher.PRIVATE_KEY) 
        { 
             
            // * The caller doesnt know the algorithm as it is part of 
            // * the encrypted data. 
              
            ASN1InputStream bIn = new ASN1InputStream(encoded);