Archive

Archive for February, 2010

How to sign and verify a message using spring

February 19, 2010 Leave a comment

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: Uncategorized Tags: , ,

How to delete recursively nested directories in Linux by name

February 5, 2010 Leave a comment
find . -type d -name NOME-DIRECTORY -exec rm -rf {} \;

thanks to Mirko…

Categories: Uncategorized Tags:

How to exclude some nested dependencies with Maven

February 2, 2010 Leave a comment

With Maven it’s possible to have some configuration problems due to nested dependencies import (e.g. a project dependency importing another dependency).

We can resolve this problem using the following configuration:

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
In this example I’ve excluded the import of the nested slf4j-jdk14 library.
Categories: Uncategorized Tags: