O'Reilly logo

Spring Security 3 by Peter Mularien

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a custom implementation of an SpEL expression handler

We'll illustrate a simple example of extending the base SpEL expression handler to provide an expression that will grant access if the current minute of the day is an even number. Although this is a contrived example, it illustrates all the steps required to implement your own custom SpEL expression methods.

Let's create a com.packtpub.springsecurity.security.CustomWebSecurityExpressionRoot class to set up a custom extension to WebSecurityExpressionRoot.

public class CustomWebSecurityExpressionRootextends WebSecurityExpressionRoot { public CustomWebSecurityExpressionRoot(Authentication a, FilterInvocation fi) { super(a, fi); } public boolean isEvenMinute() { return (Calendar.getInstance().get(Calendar.MINUTE) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required