[jboss-user] [JBoss Portal] - Re: Custom JAAS login module

cgrahl do-not-reply at jboss.com
Wed Sep 19 08:15:29 EDT 2007


Hello,

I changed my code as below:

  | public class TestLoginModule extends AbstractServerLoginModule {
  | 
  | 	private String username = null;
  | 
  | 	private Principal identity;
  | 
  | 	private Object password;
  | 
  | 
  | 	public boolean login() throws LoginException {
  | 		System.out.println("login()");
  | 		NameCallback namecallback = new NameCallback("Enter username");
  | 		PasswordCallback passwordcallback = new PasswordCallback("Enter password", false);
  | 
  | 		try {
  | 			callbackHandler.handle(new Callback[] { namecallback, passwordcallback });
  | 
  | 			username = namecallback.getName();
  | 			password = new String(passwordcallback.getPassword());
  | 
  | 			System.out.println("Username: " + username + " password: " + password);
  | 
  | 		    identity = new SimplePrincipal(username);
  | 			loginOk = true;
  | 			System.out.println("criou a identidade");
  | 			return true;
  | 		} catch (UnsupportedCallbackException e) {
  | 		} catch (java.io.IOException e) {
  | 		}
  | 		return false;
  | 
  | 	}
  | 
  | 	
  | @Override
  | 	protected Principal getIdentity() {
  | 		System.out.println("getIdentity()");
  | 		return identity;
  | 	}
  | 
  | @Override
  | 	protected Group[] getRoleSets() throws LoginException {
  | 		System.out.println("getRolesSets()");
  | 		Group rolesGroup = new SimpleGroup("Roles");
  | 		rolesGroup.addMember(new SimplePrincipal("Authenticated"));
  | 		rolesGroup.addMember(new SimplePrincipal("Administrators"));
  | 		rolesGroup.addMember(new SimplePrincipal("Users"));
  | 		rolesGroup.addMember(identity);
  | 
  | 		return new Group[] { rolesGroup };
  | 	}
  | 
  | 
  | }

Now I can authenticate Ok. But my admin/admin user is not on the admin role. How can i set that? As you can see above, i tried to set the "Administrators" role to the logged user, but it not worked. How to solve that?

Thank you in advance

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086034#4086034

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4086034



More information about the jboss-user mailing list