I am still having this issue. Can someone please help me out?
Here is my actualy query in my applicationContext-security.xml
Code:
<bean id="userDetailsService"
class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
<property name="dataSource" ref="dataSource"/>
<property name="usersByUsernameQuery">
<value>
SELECT username as username, password, 'true'
FROM app_user
WHERE username=?
</value>
</property>
<property name="authoritiesByUsernameQuery">
<value>
SELECT username as username, role.name as authority
FROM app_user, role, user_role
WHERE user_role.user_id = app_user.id
AND user_role.role_id = role.id
AND app_user.username = ?
</value>
</property>
</bean>
Now when I login with a successful login, here is the logs that are produced:
Code:
[myproject] DEBUG [http-8080-Processor23] JdbcTemplate.query(636) | Executing prepared SQL query
[myproject] DEBUG [http-8080-Processor23] JdbcTemplate.execute(571) | Executing prepared SQL statement [
SELECT username as username, password, 'true'
FROM app_user
WHERE username=?
]
[myproject] DEBUG [http-8080-Processor23] DataSourceUtils.doGetConnection(112) | Fetching JDBC Connection from DataSource
[myproject] DEBUG [http-8080-Processor23] StatementCreatorUtils.setParameterValueInternal(203) | Setting SQL statement parameter value: column index 1, parameter value [mickknutson], value class [java.lang.String], SQL type 12
[myproject] DEBUG [http-8080-Processor23] DataSourceUtils.doReleaseConnection(312) | Returning JDBC Connection to DataSource
[myproject] DEBUG [http-8080-Processor23] JdbcTemplate.query(636) | Executing prepared SQL query
[myproject] DEBUG [http-8080-Processor23] JdbcTemplate.execute(571) | Executing prepared SQL statement [
SELECT username as username, role.name as authority
FROM app_user, role, user_role
WHERE user_role.user_id = app_user.id
AND user_role.role_id = role.id
AND app_user.username = ?
]
[myproject] DEBUG [http-8080-Processor23] DataSourceUtils.doGetConnection(112) | Fetching JDBC Connection from DataSource
[myproject] DEBUG [http-8080-Processor23] StatementCreatorUtils.setParameterValueInternal(203) | Setting SQL statement parameter value: column index 1, parameter value [mickknutson], value class [java.lang.String], SQL type 12
[myproject] DEBUG [http-8080-Processor23] DataSourceUtils.doReleaseConnection(312) | Returning JDBC Connection to DataSource
[myproject] DEBUG [http-8080-Processor23] XmlWebApplicationContext.publishEvent(273) | Publishing event in context [org.springframework.web.context.support.XmlWebApplicationContext@15dc37d]: org.acegisecurity.event.authentication.AuthenticationSuccessEvent[source=org.acegisecurity.providers.UsernamePasswordAuthenticationToken@4abe1b76: Username: org.acegisecurity.userdetails.User@f14ac400: Username: mickknutson; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@fffed504: RemoteIpAddress: 127.0.0.1; SessionId: 82CE142E9D2F10278E4787E745B23705; Granted Authorities: ROLE_USER]
[myproject] DEBUG [http-8080-Processor23] XmlWebApplicationContext.publishEvent(273) | Publishing event in context [org.springframework.web.context.support.XmlWebApplicationContext@15dc37d]: org.acegisecurity.event.authentication.InteractiveAuthenticationSuccessEvent[source=org.acegisecurity.providers.UsernamePasswordAuthenticationToken@4abe1b76: Username: org.acegisecurity.userdetails.User@f14ac400: Username: mickknutson; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@fffed504: RemoteIpAddress: 127.0.0.1; SessionId: 82CE142E9D2F10278E4787E745B23705; Granted Authorities: ROLE_USER]
[myproject] DEBUG [http-8080-Processor23] RequestContextListener.requestDestroyed(88) | Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@31e2ad
[myproject] DEBUG [http-8080-Processor23] RequestContextListener.requestInitialized(68) | Bound request context to thread: org.apache.catalina.connector.RequestFacade@31e2ad
[myproject] DEBUG [http-8080-Processor23] DefaultListableBeanFactory.doGetBean(213) | Returning cached instance of singleton bean 'httpSessionIntegrationFilter'
[myproject] DEBUG [http-8080-Processor23] DefaultListableBeanFactory.doGetBean(213) | Returning cached instance of singleton bean 'logoutFilter'
[myproject] DEBUG [http-8080-Processor23] DefaultListableBeanFactory.doGetBean(213) | Returning cached instance of singleton bean 'authenticationProcessingFilter'
[myproject] DEBUG [http-8080-Processor23] DefaultListableBeanFactory.doGetBean(213) | Returning cached instance of singleton bean 'securityContextHolderAwareRequestFilter'
[myproject] DEBUG [http-8080-Processor23] DefaultListableBeanFactory.doGetBean(213) | Returning cached instance of singleton bean 'rememberMeProcessingFilter'
[myproject] DEBUG [http-8080-Processor23] DefaultListableBeanFactory.doGetBean(213) | Returning cached instance of singleton bean 'anonymousProcessingFilter'
[myproject] DEBUG [http-8080-Processor23] DefaultListableBeanFactory.doGetBean(213) | Returning cached instance of singleton bean 'exceptionTranslationFilter'
[myproject] DEBUG [http-8080-Processor23] DefaultListableBeanFactory.doGetBean(213) | Returning cached instance of singleton bean 'filterSecurityInterceptor'
[myproject] DEBUG [http-8080-Processor23] XmlWebApplicationContext.publishEvent(273) | Publishing event in context [org.springframework.web.context.support.XmlWebApplicationContext@15dc37d]: org.acegisecurity.event.authorization.PublicInvocationEvent[source=FilterInvocation: URL: /index.html]
[myproject] DEBUG [http-8080-Processor23] RequestContextListener.requestDestroyed(88) | Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@31e2ad
Issue #1 seems to be that ROLE_USER gets set, and prints <p>Welcome ROLE_USER</p> in the section below as expected., but <authz:authentication operation="username"/> does not print any data at all as expected.
Code:
<acegijsf:authorize ifAnyGranted="ROLE_USER">
<p>Welcome ROLE_USER</p>
</acegijsf:authorize>
<acegijsf:authorize ifNotGranted="ROLE_ANONYMOUS">
<p>Welcome <authz:authentication operation="username"/></p>
<p><a href="/view/member/user.html">Your Account</a></p>
<span><a href="j_acegi_logout">Logoff</a></span>
</acegijsf:authorize>