Announcement Announcement Module
Collapse
No announcement yet.
<authz:authentication operation="fullName"/> doesn't work 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="fullName"/> doesn't work

    Hi all,
    - if I'm not logged on, this code in jsp page "USER: <authz:authentication operation="fullName"/>" printed as "USER:".
    System.out.println(request.isUserInRole("ROLE_ADMI N")); - prints false

    - if I'm logged on as ROLE_ADMIN - it's not shown at all. I don't get any errors.
    System.out.println(request.isUserInRole("ROLE_ADMI N")); - prints true

    why <authz:authentication operation="fullName"/> doesn't print a name?

    my config:

    <bean id="filterChainProxy"
    class="org.acegisecurity.util.FilterChainProxy">
    <property name="filterInvocationDefinitionSource">
    <value>
    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    PATTERN_TYPE_APACHE_ANT
    /**=httpSessionContextIntegrationFilter,authenticat ionProcessingFilter,securityContextHolderAwareRequ estFilter,exceptionTranslationFilter,filterSecurit yInterceptor
    </value>
    </property>
    </bean>

    <bean id="httpSessionContextIntegrationFilter"
    class="org.acegisecurity.context.HttpSessionContex tIntegrationFilter" />

    <bean id="authenticationProcessingFilter"
    class="org.acegisecurity.ui.webapp.AuthenticationP rocessingFilter">
    <property name="authenticationManager">
    <ref local="providerManager"/>
    </property>

    <property name="defaultTargetUrl">
    <value>/</value>
    </property>

    <property name="filterProcessesUrl">
    <value>/j_acegi_security_check</value>
    </property>

    <property name="authenticationFailureUrl">
    <value>/login.html?login_error=1</value>
    </property>
    </bean>

    <bean id="securityContextHolderAwareRequestFilter" class="org.acegisecurity.wrapper.SecurityContextHo lderAwareRequestFilter"/>


    <bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFi lter">
    <property name="authenticationEntryPoint">
    <bean class="org.acegisecurity.ui.webapp.AuthenticationP rocessingFilterEntryPoint">
    <property name="loginFormUrl" value="/login.html"/>
    <property name="forceHttps" value="false"/>
    </bean>
    </property>
    </bean>

    <bean id="filterSecurityInterceptor"
    class="org.acegisecurity.intercept.web.FilterSecur ityInterceptor">
    <property name="authenticationManager">
    <ref local="providerManager" />
    </property>

    <property name="accessDecisionManager">
    <ref local="httpRequestAccessDecisionManager" />
    </property>

    <property name="objectDefinitionSource">
    <value>
    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    PATTERN_TYPE_APACHE_ANT
    /admin/*=ROLE_ADMIN
    </value>
    </property>
    </bean>

    <bean id="providerManager"
    class="org.acegisecurity.providers.ProviderManager ">
    <property name="providers">
    <list><ref local="daoAuthenticationProvider" /></list>
    </property>
    </bean>

    <bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenti cationProvider">
    <property name="userDetailsService">
    <ref local="jdbcDaoImpl" />
    </property>
    </bean>

    <bean id="httpRequestAccessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased">
    <property name="allowIfAllAbstainDecisions" value="false"/>
    <property name="decisionVoters">
    <list>
    <bean class="org.acegisecurity.vote.RoleVoter">
    <property name="rolePrefix" value=""/>
    </bean>
    </list>
    </property>
    </bean>


    <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName">
    <value>org.postgresql.Driver</value>
    </property>
    <property name="url">
    <value>jdbcostgresql://localhost:5432/db</value>
    </property>
    <property name="username">
    <value>postgres</value>
    </property>
    <property name="password">
    <value>password</value>
    </property>
    </bean>

    <bean id="jdbcDaoImpl" class="org.acegisecurity.userdetails.jdbc.JdbcDaoI mpl">
    <property name="dataSource"><ref bean="dataSource"/></property>
    </bean>




    thanks!

  • #2
    that's funny.
    - if I do this in jsp page:
    SecurityContext context = SecurityContextHolder.getContext();
    Authentication auth = context.getAuthentication();
    if (auth.getPrincipal() instanceof UserDetails) {
    out.write(((UserDetails)auth.getPrincipal()).getUs ername() );
    }
    It prints my name when I'm admin and doesn't print when I'm anonymous.

    - if I use <authz:authentication operation="getUsername"/> -
    it prints my name when I'm anonymous and prints nothing when I'm admin.


    I feel like I'm missing something really simple.
    thanks.

    Comment

    Working...
    X