2016-09-02 4 views
1

안녕하세요, 저는 스프링 부트 + 스프링 보안으로 프로젝트를 가지고 있습니다. 나는 다음과 같이 정의 사용자 정의 주석 건물입니다 :이 주석은 클래스 '방법에 적용됩니다커스텀 어노테이션에서 스프링 보안 표현 사용하기

@Retention(RUNTIME) 
@Target(METHOD) 
public @interface CustomAnnotation { 
    String condition(); 
    String[] fields() default {}; 
} 

합니다. 나는 "조건"매개 변수를 표현식을 평가할 부분에서 평가할 '스프링 보안 표현식'으로하고 싶습니다. 그리고 그것이 사실이라면 어떤 논리를 수행 할 것입니다. 나는 봄 보안 발현을 의미하는 경우

@Pointcut("@annotation(customAnnotation)" ) 
public void pointcutForCustomAnnotation(CustomAnnotation customAnnotation) { 
// Do nothing. 
} 

@Around("pointcutForCustomAnnotation(customAnnotation)") 
public Object customAspect(ProceedingJoinPoint pjp, CustomAnnotation customAnnotation) throws Throwable { 
    // Here should go the logic to evaluate spring security expression 
    String condition = customAnnotation.condition(); 
    String[] fieldsToHide = customAnnotation.fields(); 
} 

, 내가 @Preauthorize, @PostAuthorize, @PreFilter @PostFilter 스프링 주석에 사용되는 것을 의미 다음과 같이

가로 세로가 정의됩니다.

hasRole('ROLE_USER') 
isAuthenticated() 

는 어떻게 측면에서 스프링 보안 식을 계산할 수 있습니다 : 예를 들어 ? 나는 쉽게 시작하는 지점이 될 수이 작업을

답변

0

다음 요점을 수행하는 클래스 I 스프링 프레임 워크를 가지고있을 것 같아요 :

Programmatically check Spring Security expressions

이 글은 같은 문제에 대한 몇 가지 adations과 나를 위해 일한

Grails. (표현식 핸 드러 조회를 변경해야했습니다)

관련 문제