관리 메뉴

IT.FARMER

Spring security Session name 은 어느곳에? 본문

Spring/Spring Security

Spring security Session name 은 어느곳에?

아이티.파머 2016. 9. 12. 14:08
반응형


스프링 시큐리티를 사용하여 로그인 모듈생성시, 시큐리티에서는 세션 이름을 무엇으로 만들까 확인하고 싶다.

실제 세션을 만들어주는 SecurityContextPersistenceFilter 필터 안에 HttpSessionSecurityContextRepository 에 들어 있다.

좀더 자세한 필터 내역을 확인 하시려면, 필터도 여러개가 있고, 각 동작하는 필터마다 의미가 다르기때문에 필터에 관한 내역으로 검색해 보길 권합니다.




 /////////////////////////////////////////////////////////////////////////

// 세션 상세 정보 확인

/////////////////////////////////////////////////////////////////////////

HttpSession session = request.getSession();

Enumeration<?> attributeNames = session.getAttributeNames();

while (attributeNames.hasMoreElements()) {

String name = (String) attributeNames.nextElement();

if (name.equals("SPRING_SECURITY_CONTEXT")) {

SecurityContext value = (SecurityContext) session.getAttribute(name);

Authentication authentication = value.getAuthentication();

User principal = (User) authentication.getPrincipal();

WebAuthenticationDetails details = (WebAuthenticationDetails) authentication.getDetails();

String username = authentication.getName();

String password = (String) authentication.getCredentials();

logger.debug(" \n\n\n ");

logger.debug("///////////////////////////////////////////////////////////////////");

logger.debug("////////////////////SPRING_SECURITY_CONTEXT ///////////////////////");

logger.debug("///////////////////////////////////////////////////////////////////");

logger.debug("name = " + name + " , value = " + value.toString());

logger.debug("authentication : " + authentication.toString());

logger.debug("principal : " + principal);

logger.debug("details : " + details.toString());

logger.debug("username : " + username);

logger.debug("password : " + password);

logger.debug(" \n\n\n ");

}

}

반응형