2012-03-26 3 views
0

JCR 저장소에 연결하기 전에 로그인시 인증이 이미 발생한 Spring 어플리케이션에 Modeshape을 통합하려고합니다. 이이 작동 , 점에서 나는Modeshape AuthenticationProvider 구성

session = repository.login(); 

그러나이 작업 공간 레벨 액세스 제어 (문서 섹션 6.5)에 대한 내가 원하는 사용자 정의 AuthenticationProvider에 우회 것으로 보인다 사용하여 참조를 얻을 수 있습니다. 여기 내 설정이다 :

<configuration xmlns:...> 

<mode:repositories> 
    <mode:repository jcr:name="my_repo" mode:source="my_source"> 

     <mode:authenticationProviders> 
      <mode:authenticationProvider 
         jcr:name="customAuthProvider" 
       mode:classname="com.myapp.CustomSecurityContext" /> 
     </mode:authenticationProviders> 

    </mode:repository> 
</mode:repositories> 

<mode:sources jcr:primaryType="nt:unstructured"> 
    <mode:source jcr:name="my_source" .... 
    </mode:sources> 
</configuration> 

CustomSecurityContext는 인스턴스화되지 않습니다 (이 봄 주석이 있지만 호출되지 도착 결코 (POJO) 생성자는 어떤 아이디어가 무엇이 잘못 될 수 내가 함께 도망

@Configurable (preConstruction = true) 
public class CustomSecurityContext implements SecurityContext, AuthorizationProvider { 

    @Autowired 
    private ServletCredentials servletCredentials; 

    @Autowired 
    CustomUserDetailsManager userDetailsManager; 

    @Autowired 
    WorkspaceRole workspaceRole; 

    private static final Logger log = LogUtil.getLogger(); 

    public CustomSecurityContext() { 
     System.out.println(" ******** THIS NEVER GETS CALLED ********"); 
    } 

    @Override 
    public String getUserName() { 
     HttpServletRequest request = servletCredentials.getRequest(); 

     if (request != null) { 
      return request.getUserPrincipal().getName(); 
     } 

     log.warn("HttpServletRequest is null, defaulting to getUserName() = null"); 
     return null; 
    } 

    @Override 
    public boolean hasRole(String roleName) { 

     int idUser = userDetailsManager.getIdUser(); 

     if (idUser == userDetailsManager.getSystemUserID()) { 
      // The system itself can work with all workspaces 
      return true; 
     } 

     if (roleName == null) { 
      log.warn("roleName is null when calling hasRole, returning false"); 
      return false; 
     } 

     return workspaceRole.hasRole(idUser, roleName); 
    } 

    @Override 
    public void logout() { 
     log.debug("Calling logout"); // Not applicable as the session credentials are managed by Spring. 

    } 

    @Override 
    public boolean hasPermission(ExecutionContext context, String repositoryName, String repositorySourceName, String workspaceName, Path path, String... actions) { 

     log.info("Checking hasPermission for repository '" + repositoryName + "', workspace '" + workspaceName + ", path: '" + path); 

     if (actions != null) { 
      for (String action : actions) { 
       log.info("Action : " + action); 
      } 
     } 
     return true; // TODO:... 
    } 
} 

답변

1

당신.? 구성 (또는 <mode:authenticationProviders> 조각을 사용하여 테스트 케이스에서 최소한이 구성), 코드 (버전 2.8.0.Final)를 디버깅하고 ModeShape가 클래스를 인스턴스화하려고 시도하는지 확인합니다. 어떤 이유로 든 인스턴스화가 실패하면 모든 Throwables를 잡으려고 할 때), ModeShape는 에러 메세지를 씁니다. 로그에 :

Unable to initialize authentication provider "com.myapp.CustomSecurityContext" for repository "my_repo": <whatever the reason is> 

보이지 않습니까? 그렇지 않으면 로그가 제대로 기록되는지 확인하십시오. 또한 도움을 받으려면 토론 포럼에서 언제든지 연락하십시오.

+0

메시지를 전혀 보지 못함 - 스레드를 계속하기 위해 modeshape dicsussions로 돌리기 ... – user1016765

관련 문제