SyntaxHighlighter

Showing posts with label Spring Security. Show all posts
Showing posts with label Spring Security. Show all posts

Wednesday, April 24, 2013

Spring Security - logging the Authentication Object Aspect

Spring Security - logging the user Aspect

here's one inspired by StackOverflow(http://stackoverflow.com/questions/16186087/capture-successful-login-with-aspectj-and-spring-security/16187405)

to log the results of an authenticationManagers.authenticate when using in a web context, you need to use CGLIB.  here's an example;

here's the XML



 
  
 
 
 
  
   
    
   
  
 

 

 



and here's the aspect

package de.incompleteco.spring.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.security.core.Authentication;

@Aspect
public class AuthenticationManagerAspect {

 @AfterReturning(pointcut="execution(* org.springframework.security.authentication.AuthenticationManager.authenticate(..))"
   ,returning="result")
 public void after(JoinPoint joinPoint,Object result) throws Throwable {
  System.out.println(">>> user: " + ((Authentication) result).getName());
 }
 
}


Thursday, July 5, 2012

Spring Integration Security - AccessDecisionManager

Spring Integration Security - AccessDecisionManager

as of 2.1.0.RELEASE, Spring Integration Security does not provide a default AccessDecisionManager.  as such, you need to configure your own.  here's one i use for the basics;