2017-12-11 21 views
0

스프링 보안 4.2.3을 구현했다. JSF-2.2 웹 응용 프로그램에서 작동하고 그것은 지금까지 잘 작동합니다. 이제 스프링 보안의 authorize 태그에서 jsf bean 메소드에 액세스하는 데 문제가 있습니다.Spring 보안 권한 부여 태그로 관리되는 JSF beans에 접근하기

이 내가 항목 데이터에 따라 일부 행에 액세스를 거부 할 필요가 내 XHTML 데이터 테이블 : 단지 테스트 여기

<p:dataTable var="item" value="#{itemService.items}"> 
    <p:column headerText="Id"> 
     <h:outputText value="#{item.id}" /> 
    </p:column> 

    <p:column headerText="Name"> 
     <h:outputText value="#{item.name}" /> 
    </p:column> 

    <p:column headerText="Security"> 
     <sec:authorize access="#{securityService.checkAccessByItemId(item.id)}"> 
      <h:outputLabel value="#{helloWorld.secure}"/> 
     </sec:authorize> 
    </p:column> 
</p:dataTable> 

그리고 내 콩 :

여기
@ManagedBean(name="securityService") 
@RequestScoped 
public class SecurityService { 

    public boolean checkAccessByItemId(int id) { 
     if(id==5) { 
      return false; 
     } else { 
      return true; 
     } 
    } 
} 

내 태그 라이브러리. XML :이 예외를 얻고있다

<facelet-taglib> 
    <namespace>http://www.springframework.org/security/tags</namespace> 
    <tag> 
     <tag-name>authorize</tag-name> 
     <handler class>org.springframework.faces.security.FaceletsAuthorizeTagHandler</handler-class> 
    </tag> 
</facelet-taglib> 

:

org.springframework.expression.spel.SpelParseException: Expression [#{securityService.checkAccessByItemId(item.id)}] @1: EL1043E: Unexpected token. Expected 'identifier' but was 'lcurly({)' 
at org.springframework.expression.spel.standard.InternalSpelExpressionParser.raiseInternalException(InternalSpelExpressionParser.java:1006) 

누구든지 해결책을 알고 있습니까?

+0

스프링 EL이 매개 변수화 된 메소드 호출을 지원하는지 확인 했습니까? – Kukeltje

+0

매개 변수없이 메소드를 호출하면 동일한 오류가 발생합니다. – Timster

+0

이제 오류를 올바르게 읽고 (스프링 보안 문서를 확인했습니다 !!!) EL을 사용할 수 있습니까? https://docs.spring.io/spring-security/site/docs/4.2.x/reference/html/taglibs.html#taglibs-authorize – Kukeltje

답변

0

올바르게 읽을 경우, EL이 지원되지 않는 것 같습니다. (자신의 bean을 '유효성을 검사'하기 위해 호출하려는 경우 어쨌든 authorize 태그를 사용하는 이유는 무엇입니까?) rendered 속성을 outputLabel 그런 다음

+0

예, 렌더링 된 속성은 이 간단한 예를 들어 보겠습니다. 이제는 Managed Bean을 사용하여 동적으로 액세스 또는 네이 사이트 권한을 제어 할 수있는 방법이 있습니다. 그러나 이것이 지원되지 않는 것 같습니다. – Timster

+0

왜 그럴까요? 그것은 승인 태그에 대한 필요성을 무너 뜨릴 것입니다 ... – Kukeltje