Olá pessoal!
a algumas semanas estou “brigando feio” com o Spring Security na versão 3.0.5.
O login básico funciona sem problemas… mas eu preciso de algo além disso!
Por exemplo, eu tenho o seguinte form que funciona:
<form action="j_spring_security_check" method="post" >
<h:panelGrid columns="2">
<h:outputLabel value="Login" for="j_username" />
<h:inputText id="j_username" required="true" requiredMessage="Informe o login" />
<h:outputLabel value="Senha" for="j_password" />
<h:inputSecret id="j_password" required="true" requiredMessage="Informe a senha" />
</h:panelGrid>
<h:commandButton type="submit" value="Login" />
</form>
Mas eu preciso de algo tipo isso:
<form action="j_spring_security_check" method="post" >
<h:panelGrid columns="2">
<h:outputLabel value="Login" for="j_username" />
<h:inputText id="j_username" required="true" requiredMessage="Informe o login" />
<h:outputLabel value="Senha" for="j_password" />
<h:inputSecret id="j_password" required="true" requiredMessage="Informe a senha" />
<h:outputLabel value="Filial" for="j_filial" />
<h:selectOneMenu id="j_filial" style="width: 200px" value="#{loginBean.codigoFilial}">
<f:selectItems value="#{filialBean.filiais}" />
</h:selectOneMenu>
</h:panelGrid>
<h:commandButton type="submit" value="Login" />
</form>
Ou seja, o usuario precisa selecionar a qual filial o mesmo pertence, o problema está sendo apenas mandar esse codigo da filial para o bean.
Para a validação do j_spring_security_check: eu tenho um LoginBean que implementa o AuthenticationManager do Spring …
nele eu tenho um:
com get e set …
mas o mesmo retorna null!
Imagino que eu tenha que mapear por exemplo um, j_filial ligado a esse codigoFilial no spring-security.xml
mas não sei onde coloco esse atributo no xml!
Segue também o codigo do spring-security.xml
<security:http auto-config="false" use-expressions="true" access-denied-page="/negado.jsf" entry-point-ref="authenticationEntryPoint" >
<security:intercept-url pattern="/adm/**" access="hasRole('ROLE_ADM')"/>
<security:intercept-url pattern="/user/**" access="hasRole('ROLE_USER')"/>
<security:logout invalidate-session="true" logout-success-url="/login.jsf" logout-url="/logout"/>
<security:custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER"/>
</security:http>
<bean id="authenticationFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter" p:authenticationManager-ref="customAuthenticationManager" p:authenticationFailureHandler-ref="customAuthenticationFailureHandler" p:authenticationSuccessHandler-ref="customAuthenticationSuccessHandler" />
<bean id="customAuthenticationManager" class="br.com.amazoniasistemas.login.LoginBean" />
<bean id="customAuthenticationFailureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler" p:defaultFailureUrl="/erro.jsf" />
<bean id="customAuthenticationSuccessHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler" p:defaultTargetUrl="/index.jsf" />
<bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint" p:loginFormUrl="/login.jsf"/>
<security:authentication-manager/>
Grata pela atenção
:roll:

