6 Aralık 2018 Perşembe

SpringSecurity DefaultMethodSecurityExpressionHandler Sınıfı

createSecurityExpressionRoot metodu
Sınıf içinde şöyle bir kod olsun.
@Autowired
private CustomPermissionEvaluator customPermissionEvaluator;

private AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
Şöyle yaparız.
@Override
protected MethodSecurityExpressionOperations createSecurityExpressionRoot(Authentication
 authentication, MethodInvocation invocation) {
  final CustomMethodSecurityExpressionRoot root = BeanAccessor.getBean(
    CustomMethodSecurityExpressionRoot.class, authentication);
  root.setPermissionEvaluator(customPermissionEvaluator);
  root.setTrustResolver(this.trustResolver);
  root.setRoleHierarchy(getRoleHierarchy());
  root.setTarget(invocation.getThis());
  return root;
}

Hiç yorum yok:

Yorum Gönder