[JAAS + Tomcat 7] Não funciona

pessoal!

seguindo o Tutorial de JAAS do GUJ, criei meus Principals e LoginModule

[code]package br.com.empresa.core.login;

import java.security.Principal;

public class Role implements Principal {
private String name;
// …
}[/code]

[code]package br.com.empresa.core.login;

import java.security.Principal;
import java.util.*;

public class User implements Principal {
private String name;
private Set<Role> roles;
// …
}[/code]

[code]package br.com.empresa.core.login;

import java.io.IOException;
import java.util.Map;

import javax.security.auth.Subject;
import javax.security.auth.callback.*;
import javax.security.auth.login.LoginException;

import org.tempuri.*;

public class LoginModule implements javax.security.auth.spi.LoginModule {
private Subject subject;
private CallbackHandler callbackHandler;
private Map sharedState;
private Map options;
private boolean debug;
private User user;
private boolean autenticated = false;
private boolean commited = false;

@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map&lt;String, ?&gt; sharedState, Map&lt;String, ?&gt; options) {
    debug = &quot;true&quot;.equals((String) options.get(&quot;debug&quot;));

    if (debug)
        System.out.println(&quot;LoginModule.initialize&quot;);
    this.subject = subject;
    this.callbackHandler = callbackHandler;
    this.sharedState = sharedState;
    this.options = options;

    if (debug)
        System.out.println(&quot;LoginModule.initialize:debug=&quot; + debug);
}

@Override
public boolean login() throws LoginException {
    if (debug)
        System.out.println(&quot;LoginModule.login&quot;);

    if (callbackHandler == null) {
        throw new LoginException(&quot;Error: no CallbackHandler available to garner authentication information from the user&quot;);
    }
    Callback[] callbacks = new Callback[2];
    callbacks[0] = new NameCallback(&quot;nomeUsuario&quot;);
    callbacks[1] = new PasswordCallback(&quot;senha&quot;, false);

    try {
        String system = (String) options.get(&quot;system&quot;);

        if (debug)
            System.out.println(&quot;LoginModule.initialize:system=&quot; + system);
        callbackHandler.handle(callbacks);
        String user = ((NameCallback) callbacks[0]).getName();

        if (debug)
            System.out.println(&quot;LoginModule.login:user=&quot; + user);
        String password = new String(((PasswordCallback) callbacks[1]).getPassword());

        if (debug)
            System.out.println(&quot;LoginModule.login:password=&quot; + password);
        ((PasswordCallback) callbacks[1]).clearPassword();

        // um serviço que autentica no AD e consulta as permissões do usuário
        Usuario u = new Login(system, &quot;empresa\\&quot; + user, password).getUser();

        if (!&quot;&quot;.equals(u.getLogin())) {
            this.user = new User(user);

            for (Sistema s : u.getSistema()) {
                this.user.addRole(new Role(s.getCodigo()));

                if (debug)
                    System.out.println(&quot;LoginModule.login:system=&quot; + s.getCodigo());

                for (Perfil p : s.getPerfil()) {
                    this.user.addRole(new Role(p.getNome()));

                    if (debug)
                        System.out.println(&quot;LoginModule.login:profile=&quot; + p.getNome());
                }
            }
            sharedState.put(&quot;javax.security.auth.principal&quot;, this.user);
            sharedState.put(&quot;javax.security.auth.roles&quot;, this.user.getRoles());
            autenticated = true;

            if (debug)
                System.out.println(&quot;LoginModule.login:athenticated=true&quot;);
        } else {
            throw new LoginException(&quot;Warning: Invalid user or password&quot;);
        }
    } catch (IOException e) {
        throw new LoginException(e.toString());
    } catch (UnsupportedCallbackException e) {
        throw new LoginException(&quot;Error: &quot; + e.getCallback() + &quot; not available to garner authentication information from the user&quot;);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    if (debug)
        System.out.println(&quot;LoginModule.login:loged=true&quot;);
    return true;
}

@Override
public boolean commit() throws LoginException {
    if (debug)
        System.out.println(&quot;LoginModule.commit&quot;);

    if (user != null && !subject.getPrincipals().contains(user)) {
        subject.getPrincipals().add(user);
        subject.getPrincipals().addAll(user.getRoles());
    }
    commited = true;

    if (debug)
        System.out.println(&quot;LoginModule.commit:commited=true&quot;);
    return true;
}

@Override
public boolean abort() throws LoginException {
    if (debug)
        System.out.println(&quot;LoginModule.abort&quot;);

    if (!autenticated) {
        if (debug)
            System.out.println(&quot;LoginModule.abort:aborted=false&quot;);
        return false;
    } else {
        if (debug)
            autenticated = false;

        if (commited) {
            logout();
        }
    }
    subject = null;
    callbackHandler = null;
    sharedState = null;

    if (debug)
        System.out.println(&quot;LoginModule.abort:aborted=true&quot;);
    return true;
}

@Override
public boolean logout() throws LoginException {
    if (debug)
        System.out.println(&quot;LoginModule.logout&quot;);
    subject.getPrincipals().removeAll(user.getRoles());
    subject.getPrincipals().remove(user);

    if (debug)
        System.out.println(&quot;LoginModule.logout:loged=false&quot;);
    return true;
}

}[/code]
gerei o jar (empresa-core-version) e coloquei o arquivo no diretório {catalina_home}/lib

depois criei o arquivo jaas.conf

modulo { br.com.empresa.core.login.LoginModule required debug=true system=&quot;SISTEMA&quot;; };
e o coloquei no diretório {catalina_home}/conf

então, configurei o JVM arguments do servidor no Eclipse dando duplo clique no servidor, clicando no link "Open launch configuration", selecionando a aba "Arguments" e no campo "Vm arguments" digitando -Djava.security.auth.login.config="diretorioDeInstalaçãoDoTomcat\conf\jaas.conf"

aí configurei o web.xml da aplicação

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt; &lt;!-- ... --&gt; &lt;login-config&gt; &lt;auth-method&gt;FORM&lt;/auth-method&gt; &lt;realm-name&gt;default&lt;/realm-name&gt; &lt;form-login-config&gt; &lt;form-login-page&gt;/login.xhtml&lt;/form-login-page&gt; &lt;form-error-page&gt;/login-fail.xhtml&lt;/form-error-page&gt; &lt;/form-login-config&gt; &lt;/login-config&gt; &lt;!-- ... --&gt; &lt;security-constraint&gt; &lt;web-resource-collection&gt; &lt;web-resource-name&gt;modulo&lt;/web-resource-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/web-resource-collection&gt; &lt;auth-constraint&gt; &lt;role-name&gt;MODULO&lt;/role-name&gt; &lt;/auth-constraint&gt; &lt;/security-constraint&gt; &lt;security-role&gt; &lt;role-name&gt;MODULO&lt;/role-name&gt; &lt;/security-role&gt; &lt;!-- ... --&gt; &lt;/web-app&gt;
e finalmente meu formulário de login

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;!-- ... --&gt; &lt;form action="j_security_check" method="post"&gt; &lt;label for="j_username"&gt;Nome de usuário&lt;/label&gt;<br /> &lt;input name="j_username" type="text" /&gt;<br /> &lt;label for="j_password"&gt;Senha&lt;/label&gt;<br /> &lt;input name="j_password" type="password" /&gt;<br /><br /> &lt;input type="submit" value="Entrar" /&gt; &lt;/form&gt; &lt;!-- ... --&gt; &lt;/html&gt;

mas nada acontece. sou redirecionado para a tela de login-fail e não imprime nada no console.

alguém sabe o que posso estar fazendo errado?

obrigado a todos.

pessoal.

estou o dia todo pesquisando e ainda não encontrei solução.

ninguém tem uma sugestão?

obrigado novamente.