basic authenticator in SEAM
I want to do a basic authenticator handler in SEAM.
I put this in components.xml
:
<web:authentication-filter url-pattern="/test/resource/rest/*" auth-type="basic"/>
I have also put in web.xml
the filter:
<servlet>
<servlet-name>Rest Servlet</servlet-name>
<servlet-class>test.BasicAuthenticationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Rest Servlet</servlet-name>
<url-pattern>/test/resource/rest/*</url-pattern>
</servlet-mapping>
I have created a BasicAuthenticationServlet
class like:
public class BasicAuthenticationServlet extends AuthenticationFilter {
public void doFilter(final HttpServletRequest request,
final HttpServletResponse response, FilterChain chain){
//some code here
}
chain.doFilter(request, response){
//some code here
}
}
so I have overridden the 开发者_运维知识库doFilter
method.
Now, I do not understand why it is not working? I DID NOT find any code example for basic auth. in SEAM, all over the internet (I mean code including the filter and the class; so probably I miss something in my code?)
I 've implemented it using
<web:authentication-filter url-pattern="*.seam" auth-type="basic"/>
<security:identity authenticate-method="#{authenticator.authenticate}"/>
and not servlets.
And in authenticate method take the user and pass like this:
final String username = identity.getCredentials().getUsername();
final String password = identity.getCredentials().getPassword();
Why you don't want implement it in Seam way?
精彩评论