Java Code Examples for com.sun.org.apache.xml.internal.security.algorithms.MessageDigestAlgorithm#isEqual()

The following examples show how to use com.sun.org.apache.xml.internal.security.algorithms.MessageDigestAlgorithm#isEqual() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Reference.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests reference validation is success or false
 *
 * @return true if reference validation is success, otherwise false
 * @throws ReferenceNotInitializedException
 * @throws XMLSecurityException
 */
public boolean verify()
    throws ReferenceNotInitializedException, XMLSecurityException {
    byte[] elemDig = this.getDigestValue();
    byte[] calcDig = this.calculateDigest(true);
    boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);

    if (!equal) {
        log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
        log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
        log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
    } else {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
        }
    }

    return equal;
}
 
Example 2
Source File: IntegrityHmac.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 3
Source File: Reference.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests reference validation is success or false
 *
 * @return true if reference validation is success, otherwise false
 * @throws ReferenceNotInitializedException
 * @throws XMLSecurityException
 */
public boolean verify()
    throws ReferenceNotInitializedException, XMLSecurityException {
    byte[] elemDig = this.getDigestValue();
    byte[] calcDig = this.calculateDigest(true);
    boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);

    if (!equal) {
        log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
        log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
        log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
    } else {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
        }
    }

    return equal;
}
 
Example 4
Source File: IntegrityHmac.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 5
Source File: IntegrityHmac.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 6
Source File: IntegrityHmac.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 7
Source File: Reference.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests reference validation is success or false
 *
 * @return true if reference validation is success, otherwise false
 * @throws ReferenceNotInitializedException
 * @throws XMLSecurityException
 */
public boolean verify()
    throws ReferenceNotInitializedException, XMLSecurityException {
    byte[] elemDig = this.getDigestValue();
    byte[] calcDig = this.calculateDigest(true);
    boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);

    if (!equal) {
        log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
        log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
        log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
    } else {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
        }
    }

    return equal;
}
 
Example 8
Source File: IntegrityHmac.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 9
Source File: Reference.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests reference validation is success or false
 *
 * @return true if reference validation is success, otherwise false
 * @throws ReferenceNotInitializedException
 * @throws XMLSecurityException
 */
public boolean verify()
    throws ReferenceNotInitializedException, XMLSecurityException {
    byte[] elemDig = this.getDigestValue();
    byte[] calcDig = this.calculateDigest(true);
    boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);

    if (!equal) {
        log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
        log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
        log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
    } else {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
        }
    }

    return equal;
}
 
Example 10
Source File: IntegrityHmac.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 11
Source File: Reference.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Tests reference validation is success or false
 *
 * @return true if reference validation is success, otherwise false
 * @throws ReferenceNotInitializedException
 * @throws XMLSecurityException
 */
public boolean verify()
    throws ReferenceNotInitializedException, XMLSecurityException {
    byte[] elemDig = this.getDigestValue();
    byte[] calcDig = this.calculateDigest(true);
    boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);

    if (!equal) {
        log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
        log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
        log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
    } else {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
        }
    }

    return equal;
}
 
Example 12
Source File: IntegrityHmac.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 13
Source File: IntegrityHmac.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 14
Source File: IntegrityHmac.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 15
Source File: Reference.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests reference validation is success or false
 *
 * @return true if reference validation is success, otherwise false
 * @throws ReferenceNotInitializedException
 * @throws XMLSecurityException
 */
public boolean verify()
    throws ReferenceNotInitializedException, XMLSecurityException {
    byte[] elemDig = this.getDigestValue();
    byte[] calcDig = this.calculateDigest(true);
    boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);

    if (!equal) {
        log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
        log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
        log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
    } else {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
        }
    }

    return equal;
}
 
Example 16
Source File: IntegrityHmac.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
Example 17
Source File: Reference.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests reference validation is success or false
 *
 * @return true if reference validation is success, otherwise false
 * @throws ReferenceNotInitializedException
 * @throws XMLSecurityException
 */
public boolean verify()
    throws ReferenceNotInitializedException, XMLSecurityException {
    byte[] elemDig = this.getDigestValue();
    byte[] calcDig = this.calculateDigest(true);
    boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);

    if (!equal) {
        log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
        log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
        log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
    } else {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
        }
    }

    return equal;
}
 
Example 18
Source File: Reference.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests reference validation is success or false
 *
 * @return true if reference validation is success, otherwise false
 * @throws ReferenceNotInitializedException
 * @throws XMLSecurityException
 */
public boolean verify()
    throws ReferenceNotInitializedException, XMLSecurityException {
    byte[] elemDig = this.getDigestValue();
    byte[] calcDig = this.calculateDigest(true);
    boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);

    if (!equal) {
        log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
        log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
        log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
    } else {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
        }
    }

    return equal;
}
 
Example 19
Source File: Reference.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests reference validation is success or false
 *
 * @return true if reference validation is success, otherwise false
 * @throws ReferenceNotInitializedException
 * @throws XMLSecurityException
 */
public boolean verify()
    throws ReferenceNotInitializedException, XMLSecurityException {
    byte[] elemDig = this.getDigestValue();
    byte[] calcDig = this.calculateDigest(true);
    boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);

    if (!equal) {
        log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
        log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
        log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
    } else {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
        }
    }

    return equal;
}
 
Example 20
Source File: IntegrityHmac.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Proxy method for {@link java.security.Signature#verify(byte[])}
 * which is executed on the internal {@link java.security.Signature} object.
 *
 * @param signature
 * @return true if the signature is correct
 * @throws XMLSignatureException
 */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
    try {
        if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
            if (log.isLoggable(java.util.logging.Level.FINE)) {
                log.log(java.util.logging.Level.FINE, "HMACOutputLength must not be less than " + getDigestLength());
            }
            Object[] exArgs = { String.valueOf(getDigestLength()) };
            throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
        } else {
            byte[] completeResult = this.macAlgorithm.doFinal();
            return MessageDigestAlgorithm.isEqual(completeResult, signature);
        }
    } catch (IllegalStateException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}