Announcement Announcement Module
Collapse
No announcement yet.
Capture ACEGI_SECURITY_FORM_USERNAME_KEY Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Capture ACEGI_SECURITY_FORM_USERNAME_KEY

    I hope this is an easy problem to solve.

    From my login form, I simply want to capture the previously entered user name when the login attempt fails. In the Acegi samples source code, I found the following code:

    ...
    <tr>
    <td>User:</td>
    <td><input type='text' name='j_username'
    <c:if test="${not empty param.login_error}">
    value='<%= session.getAttribute(AuthenticationProcessingFilte r.ACEGI_SECURITY_FORM_USERNAME_KEY) %>'
    </c:if>>
    </td>
    </tr>
    ...

    I'm not retrieving the session attribute, however, because the call is always returning null. Up this point, I have no initialization code except for what's in the below security.xml file. I'm wondering if I'm going after the wrong session attribute or if there is some other way to retrive the previously entered user name?

    Thanks!

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>

    <!-- = = = = = = = SECURITY FILTERS = = = = = = = -->

    <bean id="securityEnforcementFilter"
    class="net.sf.acegisecurity.intercept.web.Security EnforcementFilter">
    <property name="filterSecurityInterceptor">
    <ref bean="filterInvocationInterceptor"/>
    </property>
    <property name="authenticationEntryPoint">
    <ref bean="authenticationEntryPoint"/>
    </property>
    </bean>

    <bean id="authenticationProcessingFilter"
    class="net.sf.acegisecurity.ui.webapp.Authenticati onProcessingFilter">
    <property name="filterProcessesUrl">
    <value>/j_acegi_security_check</value>
    </property>
    <property name="authenticationFailureUrl">
    <value>/logon.htm?failed=true</value>
    </property>
    <property name="defaultTargetUrl">
    <value>/home.htm</value>
    </property>
    <property name="authenticationManager">
    <ref bean="authenticationManager"/>
    </property>
    </bean>

    <bean id="autoIntegrationFilter"
    class="net.sf.acegisecurity.ui.AutoIntegrationFilt er"/>

    <bean id="authenticationEntryPoint"
    class="net.sf.acegisecurity.ui.webapp.Authenticati onProcessingFilterEntryPoint">
    <property name="loginFormUrl">
    <value>/logon.htm</value>
    </property>
    </bean>

    <!-- = = = = = = = = SECURITY INTERCEPTOR = = = = = = = = -->

    <bean id="filterInvocationInterceptor"
    class="net.sf.acegisecurity.intercept.web.FilterSe curityInterceptor">
    <property name="authenticationManager">
    <ref bean="authenticationManager"/>
    </property>
    <property name="accessDecisionManager">
    <ref bean="accessDecisionManager"/>
    </property>

    <property name="objectDefinitionSource">
    <value>
    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    \A/admin/.*\Z=ROLE_STUDENT,ROLE_INSTRUCTOR
    \A/project/.*\Z=ROLE_INSTRUCTOR
    </value>
    </property>
    </bean>

    <!-- = = = = = = = = AUTHENTICATION = = = = = = = -->

    <bean id="authenticationManager"
    class="net.sf.acegisecurity.providers.ProviderMana ger">
    <property name="providers">
    <list>
    <ref bean="daoAuthenticationProvider"/>
    </list>
    </property>
    </bean>

    <bean id="daoAuthenticationProvider"
    class="net.sf.acegisecurity.providers.dao.DaoAuthe nticationProvider">
    <property name="authenticationDao">
    <ref bean="authenticationDao"/>
    </property>
    </bean>

    <bean id="authenticationDao"
    class="net.sf.acegisecurity.providers.dao.jdbc.Jdb cDaoImpl">
    <property name="dataSource">
    <ref bean="dataSource"/>
    </property>
    <property name="usersByUsernameQuery">
    <value>select jbp_users.jbp_uname,
    jbp_users.jbp_password,
    'true'
    from jbp_users
    where jbp_users.jbp_uname = ?
    </value>
    </property>
    <property name="authoritiesByUsernameQuery">
    <value> select jbp_users.jbp_uname,
    jbp_roles.jbp_name
    from jbp_users
    inner join jbp_role_membership on (jbp_role_membership.jbp_uid = jbp_users.jbp_uid)
    inner join jbp_roles on (jbp_roles.jbp_rid = jbp_role_membership.jbp_rid)
    where jbp_users.jbp_uname = ?
    </value>
    </property>
    </bean>

    <!-- = = = = = = = = ACCESS CONTROL = = = = = = = -->

    <bean id="accessDecisionManager"
    class="net.sf.acegisecurity.vote.AffirmativeBased" >
    <property name="allowIfAllAbstainDecisions"><value>false</value></property>
    <property name="decisionVoters">
    <list>
    <ref bean="roleVoter"/>
    </list>
    </property>
    </bean>

    <bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>

    </beans>

  • #2
    You are using the wrong key,
    Correct key is

    AuthenticationProcessingFilter.ACEGI_SECURITY_LAST _USERNAME_KEY

    Comment


    • #3
      What version of acegi are you running? I'm currently using 0.8.2, but I was also looking for a 0.9.0 Snapshot .jar; couldn't find it.

      Thanks...

      Re...

      An error occurred at line: 104 in the jsp file: /WEB-INF/jsp/logon.jsp
      Generated servlet error:
      AuthenticationProcessingFilter.ACEGI_SECURITY_LAST _USERNAME_KEY cannot be resolved

      Comment


      • #4
        Not only was I using the wrong constant, but an older version of Acegi was hiding out in my /lib directory that didn't contain the ...-0.8.2.jar file name. Thanks for the help.

        Comment

        Working...
        X