How to add AccessDescisionVoters to AccessDescisionManager in Spring Security

Here’s a pretty neat approach to add AccessDescisionVoters to the default AccessDescisionManager in Spring Security:


Convert Image to byte array in Java

If you don’t want to make use of IOUtils from Apache Commons Lang, you should you know, the code in the finally block would be something like

UnknownHostException with ‘%’ in IPv6 address

dnsjava to resolve whatever address request.getRemoteAddr() would return. This worked very well in most cases. However, in some cases I would see something like: [quote] Invalid address: fe80::1d9:b65a:ed86:7940%11[/quote] Not being much of a networking expert I was puzzled about the ‘%11’. Once again came to rescue:

Maven hbm2ddl: fixing java.lang.ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy

Creating a DDL in the Maven build with the hibernate3-maven-plugin fails if you explicitly configure an array of javax.persistence.CascadeType values in your JPA annotations. The stacktrace is similar to

Once I realized what the actual cause is, the fix was simple. Turns out that the CascadeType is not in the classpath when Maven runs […]

Self signed certificates in Apache HttpClient

When you need to support self-signed SSL certificates in your Apache HttpClient based application you can use the contributed EasySSLProtocolSocketFactory as described in the HttpClient docs. Instead of using HttpClient’s HostConfiguration object directly you’d modify its protocol socket factory in your code like so:

Somewhere you’d instantiate a HttpClient object. Then you get its […]