Cristian Boariu
Cristian Boariu

Reputation: 9621

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

Upvotes: 2

Views: 1399

Answers (2)

Cristian Boariu
Cristian Boariu

Reputation: 9621

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();

Upvotes: 3

cetnar
cetnar

Reputation: 9415

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

Upvotes: 0

Related Questions