Code Monkeyism

Programming is hard by Stephan Schmidt

Gabriel for Guice

After fiddling around with the security framework Gabriel I wrote some time back and which I need for Reposita. I thought about combining Gabriel with Google Guice for fun. The only problem was that Gabriel can be used with interceptors to protect methods. How could I get them working with Guice?

I was using Dynaop, the best aop framework for Java, which I wrote a Spring bean factory for to use with Gabriel. For Guice I tried to port it when Bob told me that Guice already supports interceptors :-) So using my AOP alliance interceptors from Gabriel with Guice was a no brainer. Everything worked as excpected. Guice is great.

So protecting methods with annotations is easy now with Gabriel:

public interface SecureObject {

  @NeedsPermission("SET_NAME")
  public void setName(String name);
}

Two things I’m still thinking about are what to call the annotation ? NeedsPermission, Permission, WithPermission? And to get the interface method I currently iterate over all interfaces of the class, any ideas how to do that faster?

Otherwise: http://gabriel.reposita.org/

About the author: Stephan Schmidt is currently a team manager at ImmobilienScout24 in Berlin. Stephan has been working as a head of development and CTO. He has used a lot of different technologies in the last 20 years including Java, Rails and Python. Stephans main field of interest is maintainablity and productivity in software development. Want to know more? All views are only his own.

If you did like this article but you don't want to subscribe to new articles with your reader, you can follow me on Twitter or subscribe to new posts with your email:

Leave a Reply