Code example for Mac

Methods: doFinalinit

        if (outputLengthSet && outputLength < getDigestLength()) {
            throw new XMLSignatureException 
                ("HMACOutputLength must not be less than " + getDigestLength()); 
        hmac.init((SecretKey) key);
        si.canonicalize(context, new MacOutputStream(hmac));
        byte[] result = hmac.doFinal();
        return MessageDigest.isEqual(sig, result);
    byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context)
        throws InvalidKeyException, XMLSignatureException { 
        if (key == null || si == null) {
            throw new NullPointerException();
        if (!(key instanceof SecretKey)) {
            throw new InvalidKeyException("key must be SecretKey");
Stop searching for code, let great code find you!  Add Codota to your java IDE