FileDocCategorySizeDatePackage
ConfiguredIdentityLoginModule.javaAPI DocJBoss 4.2.14233Fri Jul 13 21:01:18 BST 2007org.jboss.resource.security

ConfiguredIdentityLoginModule

public class ConfiguredIdentityLoginModule extends AbstractPasswordCredentialLoginModule
A simple login module that simply associates the principal specified in the module options with any subject authenticated against the module. The type of Principal class used is org.jboss.security.SimplePrincipal.

If no principal option is specified a principal with the name of 'guest' is used.

see
org.jboss.security.SimpleGroup
see
org.jboss.security.SimplePrincipal
author
Scott.Stark@jboss.org
author
David Jencks
version
$Revision: 57189 $

Fields Summary
private String
principalName
private String
userName
private String
password
private static final Logger
log
Constructors Summary
public ConfiguredIdentityLoginModule()



    
   
   
Methods Summary
protected java.security.PrincipalgetIdentity()

      log.trace("getIdentity called");
      Principal principal = new SimplePrincipal(principalName);
      return principal;
   
protected java.security.acl.Group[]getRoleSets()
This method simply returns an empty array of Groups which means that no role based permissions are assigned.

      log.trace("getRoleSets called");
      return new Group[] {};
   
public voidinitialize(javax.security.auth.Subject subject, javax.security.auth.callback.CallbackHandler handler, java.util.Map sharedState, java.util.Map options)

      super.initialize(subject, handler, sharedState, options);
      principalName = (String) options.get("principal");
      if( principalName == null )
      {
         throw new IllegalArgumentException("Must supply a principal name!");
      }
      userName = (String) options.get("userName");
      if( userName == null )
      {
         throw new IllegalArgumentException("Must supply a user name!");
      }
      password = (String) options.get("password");
      if( password == null )
      {
         log.warn("Creating LoginModule with no configured password!");
         password = "";
      }
      log.trace("got principal: " + principalName + ", username: " + userName + ", password: " + password);

   
public booleanlogin()

      log.trace("login called");
      if( super.login() == true )
         return true;

      Principal principal = new SimplePrincipal(principalName);
      SubjectActions.addPrincipals(subject, principal);
      // Put the principal name into the sharedState map
      sharedState.put("javax.security.auth.login.name", principalName);
      PasswordCredential cred = new PasswordCredential(userName, password.toCharArray());
      cred.setManagedConnectionFactory(getMcf());
      SubjectActions.addCredentials(subject, cred);
      super.loginOk = true;
      return true;