Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.jboss.resource.security;
 
 
 import java.util.Map;
 
 import  javax.resource.spi.security.PasswordCredential;
 
 import  org.jboss.logging.Logger;
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.

Author(s):
Scott.Stark@jboss.org
David Jencks
Version:
$Revision: 71545 $
See also:
org.jboss.security.SimpleGroup
org.jboss.security.SimplePrincipal
 
 
 @SuppressWarnings("unchecked")
 {
    private String principalName;
    private String userName;
    private String password;
 
    private static final Logger log = Logger.getLogger(ConfiguredIdentityLoginModule.class);
    private boolean trace = .isTraceEnabled();
 
 
    {
    }
 
    public void initialize(Subject subjectCallbackHandler handlerMap sharedStateMap options)
    {
       super.initialize(subjecthandlersharedStateoptions);
        = (Stringoptions.get("principal");
       if == null )
       {
          throw new IllegalArgumentException("Must supply a principal name!");
       }
        = (Stringoptions.get("userName");
       if == null )
       {
          throw new IllegalArgumentException("Must supply a user name!");
       }
        = (Stringoptions.get("password");
       if == null )
       {
          .warn("Creating LoginModule with no configured password!");
           = "";
       }
       if()
          .trace("got principal: " +  + ", username: " +  + ", password: " + );
 
    }
 
    public boolean login() throws LoginException
    {
       if()
          .trace("login called");
       ifsuper.login() == true )
          return true;
 
      Principal principal = new SimplePrincipal();
      SubjectActions.addPrincipals(subject, principal);
      // Put the principal name into the sharedState map
      sharedState.put("javax.security.auth.login.name");
      PasswordCredential cred = new PasswordCredential(.toCharArray());
      cred.setManagedConnectionFactory(getMcf());
      SubjectActions.addCredentials(subject, cred);
      super. = true;
      return true;
   }
   protected Principal getIdentity()
   {
      if()
         .trace("getIdentity called");
      Principal principal = new SimplePrincipal();
      return principal;
   }

   
This method simply returns an empty array of Groups which means that no role based permissions are assigned.
   protected Group[] getRoleSets() throws LoginException
   {
      if()
         .trace("getRoleSets called");
      return new Group[] {};
   }
   
New to GrepCode? Check out our FAQ X