acegiのSecurityContextHolder.getContext()を教えてください.値が空の問題
acegiを使用する場合、ログインしてログインユーザ情報を取得したときに取得した値はnull
でもDEBUGの情報から見ると
-------SecurityContext stored to HttpSession------
------SecurityContextHolder set to new context----
以上、ユーザー情報をセッションに入れるべきですが、どこで問題が発生して値が取れない可能性がありますか?
public TUser getUser()
{
//
SecurityContext ctx = SecurityContextHolder.getContext();
Authentication auth = ctx.getAuthentication();
if(auth.getPrincipal() instanceof UserDetails)
{
user = (TUser)auth.getPrincipal();
//log.debug("
auth.getPrincipal()==============
"+user.getUserid());
}
return user;
}
java.lang.NullPointerException
com.firedragon.struts.base.action.BaseDispatchAction.getUser(BaseDispatchAction.java:125)
でもDEBUGの情報から見ると
[2007-01-17 23:51:32]DEBUG org.springframework.web.context.support.XmlWebApplicationContext(line:215) -Publishing event in context [Root WebApplicationContext]: org.acegisecurity.event.authentication.AuthenticationSuccessEvent[source=org.acegisecurity.providers.UsernamePasswordAuthenticationToken@aaf3d2: Username: com.firedragon.hibernate.model.TUser@ba2b6b[ :=admin, enabled:=true, accountExpired:=true, credentialsExpired:=true, accountLocked:=true, : ,ROLE_11]; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@16d8a64: RemoteIpAddress: 127.0.0.1; SessionId: 8AECD601C138A1E87458F770333028E8; Granted Authorities: ROLE_11]
[2007-01-17 23:51:32]WARN org.acegisecurity.event.authentication.LoggerListener(line:60) -Authentication event AuthenticationSuccessEvent: admin; details: org.acegisecurity.ui.WebAuthenticationDetails@16d8a64: RemoteIpAddress: 127.0.0.1; SessionId: 8AECD601C138A1E87458F770333028E8
[2007-01-17 23:51:32]DEBUG org.acegisecurity.ui.AbstractProcessingFilter(line:392) -Authentication success: org.acegisecurity.providers.UsernamePasswordAuthenticationToken@aaf3d2: Username: com.firedragon.hibernate.model.TUser@ba2b6b[ :=admin, enabled:=true, accountExpired:=true, credentialsExpired:=true, accountLocked:=true, : ,ROLE_11]; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@16d8a64: RemoteIpAddress: 127.0.0.1; SessionId: 8AECD601C138A1E87458F770333028E8; Granted Authorities: ROLE_11
[2007-01-17 23:51:32]DEBUG org.acegisecurity.ui.AbstractProcessingFilter(line:398) -Updated SecurityContextHolder to contain the following Authentication: 'org.acegisecurity.providers.UsernamePasswordAuthenticationToken@aaf3d2: Username: com.firedragon.hibernate.model.TUser@ba2b6b[ :=admin, enabled:=true, accountExpired:=true, credentialsExpired:=true, accountLocked:=true, : ,ROLE_11]; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@16d8a64: RemoteIpAddress: 127.0.0.1; SessionId: 8AECD601C138A1E87458F770333028E8; Granted Authorities: ROLE_11'
[2007-01-17 23:51:32]DEBUG org.acegisecurity.ui.AbstractProcessingFilter(line:416) -Redirecting to target URL from HTTP Session (or default): /News/main.html
[2007-01-17 23:51:32]DEBUG org.springframework.web.context.support.XmlWebApplicationContext(line:215) -Publishing event in context [Root WebApplicationContext]: org.acegisecurity.event.authentication.InteractiveAuthenticationSuccessEvent[source=org.acegisecurity.providers.UsernamePasswordAuthenticationToken@aaf3d2: Username: com.firedragon.hibernate.model.TUser@ba2b6b[ :=admin, enabled:=true, accountExpired:=true, credentialsExpired:=true, accountLocked:=true, : ,ROLE_11]; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@16d8a64: RemoteIpAddress: 127.0.0.1; SessionId: 8AECD601C138A1E87458F770333028E8; Granted Authorities: ROLE_11]
[2007-01-17 23:51:32]WARN org.acegisecurity.event.authentication.LoggerListener(line:60) -Authentication event InteractiveAuthenticationSuccessEvent: admin; details: org.acegisecurity.ui.WebAuthenticationDetails@16d8a64: RemoteIpAddress: 127.0.0.1; SessionId: 8AECD601C138A1E87458F770333028E8
[2007-01-17 23:51:32]DEBUG org.acegisecurity.context.HttpSessionContextIntegrationFilter(line:276)[color=red]--------SecurityContext stored to HttpSession------[/color]: 'org.acegisecurity.context.SecurityContextImpl@aaf3d2: Authentication: org.acegisecurity.providers.UsernamePasswordAuthenticationToken@aaf3d2: Username: com.firedragon.hibernate.model.TUser@ba2b6b[ :=admin, enabled:=true, accountExpired:=true, credentialsExpired:=true, accountLocked:=true, : ,ROLE_11]; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@16d8a64: RemoteIpAddress: 127.0.0.1; SessionId: 8AECD601C138A1E87458F770333028E8; Granted Authorities: ROLE_11'
[2007-01-17 23:51:32]DEBUG org.acegisecurity.context.HttpSessionContextIntegrationFilter(line:285) [color=red]-------SecurityContextHolder set to new context-----[/color], as request processing completed
-------SecurityContext stored to HttpSession------
------SecurityContextHolder set to new context----
以上、ユーザー情報をセッションに入れるべきですが、どこで問題が発生して値が取れない可能性がありますか?