Code example for InvalidKeySpecException

0
            } else if (encoded == null) {
                throw new InvalidKeySpecException("Key is not encodable");
            } 
            return (T) new X509EncodedKeySpec(encoded);
        } else { 
            throw new InvalidKeySpecException("Unsupported key type and key spec combination; key="
                    + key.getClass().getName() + ", keySpec=" + keySpec.getName());
        } 
    } 
 
    @Override 
    protected Key engineTranslateKey(Key key) throws InvalidKeyException {
        if (key == null) {
            throw new InvalidKeyException("key == null");
        } 
        if ((key instanceof OpenSSLECPublicKey) || (key instanceof OpenSSLECPrivateKey)) {
            return key;
        } else if (key instanceof ECPublicKey) {
            ECPublicKey ecKey = (ECPublicKey) key;
 
            ECPoint w = ecKey.getW();