I think in the end I had to make changes in my LoginModule for it to work. This is my
complete login module.
Hope it helps
Alex
/*
| * SimpleLoginModule.java
| *
| * Created on 24 June 2005, 10:45
| *
| */
| package com.thunderhead.backend.security;
| import java.io.IOException;
| import java.security.acl.Group;
| import java.util.Map;
| import javax.security.auth.Subject;
| import javax.security.auth.callback.Callback;
| import javax.security.auth.callback.CallbackHandler;
| import javax.security.auth.callback.NameCallback;
| import javax.security.auth.callback.PasswordCallback;
| import javax.security.auth.callback.UnsupportedCallbackException;
| import javax.security.auth.login.LoginException;
| import javax.security.auth.spi.LoginModule;
|
| /**
| *
| * <p>Copyright: Copyright (c) 2007</p>
| * <p>Company: Thunderhead</p>
| * @author ahartner
| * @version 1
| */
| public class SimpleLoginModule implements LoginModule {
| private Subject m_subject;
| private CallbackHandler m_callbackHandler;
| private String m_userid;
| private String m_password;
|
| /**
| * Creates a new instance of SimpleLoginModule
| */
| public SimpleLoginModule() {
| }
|
| public boolean abort() throws LoginException {
| return true;
| }
|
| public boolean commit() throws LoginException {
| JAASUser user = new JAASUser(1,m_userid);
|
| Group grp = new JAASGroup("Roles");
| grp.addMember(new JAASRole("friend"));
| grp.addMember(new JAASRole("friends"));
|
| m_subject.getPrincipals().add(user);
| m_subject.getPrincipals().add(grp);
| return true;
| }
|
| public void initialize(Subject subject, CallbackHandler callbackHandler, Map state,
Map options) {
| m_subject = subject;
| m_callbackHandler=callbackHandler;
| }
|
| public boolean login() throws LoginException {
| NameCallback nameCallback = new NameCallback("User Name");
| PasswordCallback passwordCallback = new PasswordCallback("User
Password", false);
| Callback[] callbacks = new Callback[2];
| callbacks[0] = nameCallback;
| callbacks[1] = passwordCallback;
| try {
| m_callbackHandler.handle(callbacks);
| } catch (UnsupportedCallbackException ex) {
| ex.printStackTrace();
| } catch (IOException ex) {
| ex.printStackTrace();
| }
| try {
| if (nameCallback.getName() != null) {
| m_userid = nameCallback.getName();
| }
| if (passwordCallback.getPassword() != null) {
| m_password = new String(passwordCallback.getPassword());
| }
| passwordCallback.clearPassword();
| } catch (Exception e) {
| e.printStackTrace();
| }
| if (!m_userid.equals("user") ||
!m_password.equals("password"))
| {
| return false;
| }
| else
| {
| return true;
| }
| }
|
| public boolean logout() throws LoginException {
| m_subject.getPrincipals().clear();
| return true;
| }
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110914#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...