Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.google.code.springcryptoutils.core.signature;
 
 
The default implementation for verifying the authenticity of messages using base64 encoded digital signatures.

Author(s):
Mirko Caserta (mirko.caserta@gmail.com)
public class Base64EncodedVerifierImpl implements Base64EncodedVerifier {
    private VerifierImpl verifier = new VerifierImpl();
    private String charsetName = "UTF-8";

    
The signature algorithm. The default is SHA1withRSA.

Parameters:
algorithm the signature algorithm
    public void setAlgorithm(String algorithm) {
        .setAlgorithm(algorithm);
    }

    
The public key for verifying the message.

Parameters:
publicKey the public key
    public void setPublicKey(PublicKey publicKey) {
        .setPublicKey(publicKey);
    }

    
The charset to use when converting a string into a raw byte array representation. The default is UTF-8.

Parameters:
charsetName the charset name (default: UTF-8)
    public void setCharsetName(String charsetName) {
        this. = charsetName;
    }

    
Verifies the authenticity of a message using a base64 encoded digital signature.

Parameters:
message the original message to verify
signature the base64 encoded digital signature
Returns:
true if the original message is verified by the digital signature
    public boolean verify(String messageString signature) {
        try {
            return .verify(message.getBytes(), Base64.decodeBase64(signature));
        } catch (UnsupportedEncodingException e) {
            throw new SignatureException("unsupported encoding: charsetName=" + e);
        }
    }
New to GrepCode? Check out our FAQ X