November 2017
Intermediate to advanced
542 pages
14h 24m
English
Another way to use a custom expression instead of using a CustomWebSecurityExpressionHandler interface is to add a @Component web, as follows:
// src/main/java/com/packtpub/springsecurity/web/access/expression/ CustomWebExpression.java @Component public class CustomWebExpression { public boolean isLocal(Authentication authentication, HttpServletRequest request) { return "localhost".equals(request.getServerName()); }}
Now, let's update our initialization SQL query to use the new expression. You will notice that we are able to reference the @Component directly since SpEL supports Java Bean conventions:
// src/main/resources/data.sqlinsert into security_filtermetadata(id,ant_pattern,expression,sort_order) ...
Read now
Unlock full access