Home > My Work > How to sign and verify a message using spring

How to sign and verify a message using spring

You can use spring-crypto-utils a wrapper around java’s native cryptography API. I’m very proud of my little collaboration to this project, hosted by Mirko Caserta.

With real little configuration…

    <crypt:keystore id="keystore" location="classpath:keystore.jks" password="password"/>
    <crypt:privateKey id="privateKey" keystore-ref="keystore" alias="test" password="password"/>
    <crypt:signer id="signer" privateKey-ref="privateKey" algorithm="SHA1withRSA"/>

…you can sign a message using a code like this:

public class MyBusinessSigner {

    @Autowired
    private Signer signer;

    public void myBusinessMethod() {
        // I am not a very useful business method but
        // I can do digital signatures!
        byte[] signature = signer.sign(messageToBeTrusted);
    }
}
Advertisements
Categories: My Work Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: