Announcement Announcement Module
Collapse
No announcement yet.
<authz:authentication operation="username"/> not returning value Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <authz:authentication operation="username"/> not returning value

    I am getting my user authenticated here:

    Code:
    [myproject] DEBUG [http-8080-Processor24] XmlWebApplicationContext.publishEvent(273) | Publishing event in context [[email protected]15dc37d]: org.acegisecurity.event.authentication.InteractiveAuthenticationSuccessEvent[source=[email protected]2ee9329: Username: org.acegisecurity.userdetails.User@db3aea00: Username: mickknutson; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER, ROLE_ADMIN; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@fffdaa08: RemoteIpAddress: 127.0.0.1; SessionId: 5EF31A5791632F48E20C969E5AA4C8AF; Granted Authorities: ROLE_USER, ROLE_ADMIN]
    Strange thing is, this is what was in the view-source of my page:
    Code:
    Welcome <authz:authentication operation="username"></authz:authentication>
    It only prints Welcome

    But in my facelets page:

    Code:
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:ui="http://java.sun.com/jsf/facelets"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:authz="http://acegisecurity.org/authz"       
                xmlns:acegijsf="http://sourceforge.net/projects/jsf-comp/acegijsf"
            >
    
        <div id="header">
            <h1><a href="#">BASE Logic</a></h1>
            <h2>
                <acegijsf:authorize ifNotGranted="ROLE_ANONYMOUS">
                    <a href="#">Your account</a> | <a href="j_acegi_logout">Logoff</a>
                    Welcome <authz:authentication operation="username"/>
                </acegijsf:authorize>
    Can anyone help me?

  • #2
    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 [[email protected]15dc37d]: org.acegisecurity.event.authentication.AuthenticationSuccessEvent[source=[email protected]abe1b76: 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=[email protected]abe1b76: 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 [[email protected]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>
    Last edited by mickknutson; May 3rd, 2008, 01:50 PM.

    Comment


    • #3
      I actually can't get anything from the UserDetails object;

      Welcome []
      password []
      AccountNonExpired []
      AccountNonLocked []
      CredentialsNonExpired []
      Enabled []



      from:
      Code:
                              <p>Welcome [<authz:authentication operation="username"/>]</p>
                              <p>password [<authz:authentication operation="password"/>]</p>
                              <p>AccountNonExpired [<authz:authentication operation="AccountNonExpired"/>]</p>
                              <p>AccountNonLocked [<authz:authentication operation="AccountNonLocked"/>]</p>
                              <p>CredentialsNonExpired [<authz:authentication operation="CredentialsNonExpired"/>]</p>
                              <p>Enabled [<authz:authentication operation="Enabled"/>]</p>

      Comment

      Working...
      X