Code example for KeyException

0
        } else if (key instanceof RSAPublicKey) {
            RSAPublicKey rkey = (RSAPublicKey) key;
            exponent = new DOMCryptoBinary(rkey.getPublicExponent());
            modulus = new DOMCryptoBinary(rkey.getModulus());
        } else { 
            throw new KeyException("unsupported key algorithm: " +
                key.getAlgorithm());
        } 
    } 
 
    /** 
     * Creates a <code>DOMKeyValue</code> from an element. 
     * 
     * @param kvElem a KeyValue element 
     */ 
    public DOMKeyValue(Element kvElem) throws MarshalException {
        Element kvtElem = DOMUtils.getFirstChildElement(kvElem);
        if (kvtElem.getLocalName().equals("DSAKeyValue")) {
            publicKey = unmarshalDSAKeyValue(kvtElem);
        } else if (kvtElem.getLocalName().equals("RSAKeyValue")) {