의 null 내가 가지고 나는 다음과 같은 코드를 사용하여 서버에 대해 인증하기 위해 노력하고있어봄 보안 - sessionId가 인증
@Override
public void onAuthenticationSuccess(HttpServletRequest request
, HttpServletResponse response, Authentication authentication)
throws IOException, ServletException {
String sessionId = ((WebAuthenticationDetails) authentication
.getDetails()).getSessionId();
}
다음과 같은 기능 :
HttpClient client = new HttpClient();
CommonsClientHttpRequestFactory commons
= new CommonsClientHttpRequestFactory(client);
RestTemplate template = new RestTemplate(commons);
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>()
map.add("j_username", "11");
map.add("j_password", "22");
Object result2 = template.postForObject(
"http://localhost:8080/APP/j_spring_security_check", map,Object.class);
것입니다, 자격 증명은 합법적 인 나는 onSuccess를 입력하지만 위의 코드를 사용할 때마다 sessionId가 null입니다.
내가 양식을 통해 인증 할 때 세션 ID가 생성됩니다. 내가 설정할 때
<security:http create-session="always" />
실제로 작동합니다. 그러나 나는 이것이 매회마다 세션을 열고 정말로 비효율적이라고 생각합니다.
왜 세션 ID가 java post 요청에서 null이고 양식이 아닌지 어떤 생각입니까? 어떻게 수정해야합니까?
감사합니다.
분명히 필터 체인이 보이지 않고 'create-session = "always"'을 사용하지 않으면 세션이 생성되지 않습니다. – Urbanleg