tags:

views:

266

answers:

2

Hi,

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 overrided 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?)

Thanks in advance,

+1  A: 

Why you don't want implement it in Seam way?

cetnar
+1  A: 

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();
Cristian Boariu
Sory, but that was my answer - you did it in Seam way, exaclty what I sugested.
cetnar