Code example for InvalidKeyException

Methods: printStackTrace

0
            mac.init(new SecretKeySpec(key, "HmacSHA1"));
            result = new SecretKeySpec(mac.doFinal(keyMetirials), "HmacSHA1");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        } 
        return result;
    } 
 
    public static XMLSignature sign(Key signKey, Element signElement)
            throws XKMSException { 
 
        String xmlSignatureAlgorithm = null;
 
        if (signKey instanceof SecretKeySpec) {
            xmlSignatureAlgorithm = XMLSignature.ALGO_ID_MAC_HMAC_SHA1;
 
        } else if (signKey instanceof PrivateKey) {
            xmlSignatureAlgorithm = XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1;