use of org.aspectj.lang.annotation.AfterReturning in project entando-core by entando.
the class UserProfileManager method updateProfile.
@AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.updateUser(..)) && args(user,..)")
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'UserProfile_'.concat(#user.username)")
public void updateProfile(Object user) {
if (user != null) {
UserDetails userDetails = (UserDetails) user;
Object profile = userDetails.getProfile();
if (null != profile) {
try {
this.updateProfile(userDetails.getUsername(), (IUserProfile) profile);
} catch (Throwable t) {
logger.error("Error updating profile to user {}", userDetails.getUsername(), t);
}
}
}
}
use of org.aspectj.lang.annotation.AfterReturning in project profile by craftercms.
the class RefreshCurrentAuthenticationOnProfileUpdateAspect method refreshCurrentAuthentication.
@AfterReturning(value = "execution(* org.craftercms.profile.api.services.ProfileService.updateProfile(..)) || " + "execution(* org.craftercms.profile.api.services.ProfileService.verifyProfile(..)) || " + "execution(* org.craftercms.profile.api.services.ProfileService.enableProfile(..)) || " + "execution(* org.craftercms.profile.api.services.ProfileService.disableProfile(..)) || " + "execution(* org.craftercms.profile.api.services.ProfileService.addRoles(..)) || " + "execution(* org.craftercms.profile.api.services.ProfileService.removeRoles(..)) || " + "execution(* org.craftercms.profile.api.services.ProfileService.updateAttributes(..)) || " + "execution(* org.craftercms.profile.api.services.ProfileService.removeAttributes(..)) || " + "execution(* org.craftercms.profile.api.services.ProfileService.changePassword(..))", returning = "updatedProfile")
public void refreshCurrentAuthentication(Profile updatedProfile) {
Authentication auth = SecurityUtils.getCurrentAuthentication();
if (auth != null) {
Profile profile = auth.getProfile();
if (profile.equals(updatedProfile)) {
String ticket = auth.getTicket();
auth = new DefaultAuthentication(ticket, updatedProfile);
// Put updated authentication in cache
authenticationCache.putAuthentication(auth);
// Update current authentication object
SecurityUtils.setCurrentAuthentication(auth);
}
}
}
use of org.aspectj.lang.annotation.AfterReturning in project paascloud-master by paascloud.
the class BindingResultAop method doAfter.
/**
* Do after.
*
* @param joinPoint the join point
*/
@AfterReturning(pointcut = "validateAnnotation()")
public void doAfter(final JoinPoint joinPoint) {
String methodName = joinPoint.getSignature().getName();
Object target = joinPoint.getTarget();
// 得到拦截的方法
Method method = getMethodByClassAndName(target.getClass(), methodName);
Object[] objects = joinPoint.getArgs();
// 方法的参数
assert method != null;
ValidateAnnotation annotation = (ValidateAnnotation) getAnnotationByMethod(method, ValidateAnnotation.class);
if (annotation != null) {
BindingResult bindingResult = null;
for (Object arg : objects) {
if (arg instanceof BindingResult) {
bindingResult = (BindingResult) arg;
}
}
if (bindingResult != null && bindingResult.hasErrors()) {
String errorInfo = bindingResult.getFieldError().getDefaultMessage();
throw new IllegalArgumentException(errorInfo);
}
}
}
use of org.aspectj.lang.annotation.AfterReturning in project entando-core by entando.
the class UserProfileManagerAspect method updateProfile.
@AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.updateUser(..)) && args(user,..)")
public void updateProfile(Object user) {
if (user != null) {
UserDetails userDetails = (UserDetails) user;
Object profile = userDetails.getProfile();
if (null != profile) {
try {
this.getUserProfileManager().updateProfile(userDetails.getUsername(), (IUserProfile) profile);
} catch (Throwable t) {
logger.error("Error updating profile to user {}", userDetails.getUsername(), t);
}
}
}
}
use of org.aspectj.lang.annotation.AfterReturning in project entando-core by entando.
the class UserProfileManagerAspect method addProfile.
@AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.addUser(..)) && args(user,..)")
public void addProfile(Object user) {
if (user != null) {
UserDetails userDetails = (UserDetails) user;
Object profile = userDetails.getProfile();
if (null != profile) {
try {
this.getUserProfileManager().addProfile(userDetails.getUsername(), (IUserProfile) profile);
} catch (Throwable t) {
logger.error("Error adding profile on user {}", userDetails.getUsername(), t);
}
}
}
}
Aggregations