Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt 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.security.auth.spi;
 
 import java.util.Map;
 
Certificate Login Module that uses a properties file to store role information. This works just like the UsersRolesLoginModule, only without the users.properties file. In fact, all the role handling code was borrowed directly from that class.

Author(s):
Jason Essington
Scott.Stark@jboss.org
Version:
$Revision: 73520 $
See also:
BaseCertLoginModule
 
 public class CertRolesLoginModule extends BaseCertLoginModule
 {
   
The name of the default properties resource containing user/roles
 
    private String defaultRolesRsrcName = "defaultRoles.properties";
   
The name of the properties resource containing user/roles
 
    private String rolesRsrcName = "roles.properties";
   
The roles.properties mappings
 
    private Properties roles;
   
The character used to seperate the role group name from the username e.g., '.' in jduke.CallerPrincipal=...
 
    private char roleGroupSeperator = '.';
   
Logging trace flag
 
    private boolean trace;

   
Initialize this LoginModule.

Parameters:
options - the login module option map. Supported options include: rolesProperties: The name of the properties resource containing user/roles the default is "roles.properties". roleGroupSeperator: The character used to seperate the role group name from the username e.g., '.' in jduke.CallerPrincipal=... . The default = '.'. defaultRolesProperties=string: The name of the properties resource containing the username to roles mappings that will be used as the defaults Properties passed to the usersProperties Properties. This defaults to defaultRoles.properties.
 
    public void initialize(Subject subjectCallbackHandler callbackHandler,
       Map<String,?> sharedStateMap<String,?> options)
    {
       super.initialize(subjectcallbackHandlersharedStateoptions);
        = .isTraceEnabled();
       if )
          .trace("enter: initialize(Subject, CallbackHandler, Map, Map)");
 
       try
       {
          String option = (Stringoptions.get("rolesProperties");
          if (option != null)
              = option;
          option = (Stringoptions.get("defaultRolesProperties");
          if (option != null)
              = option;
          option = (Stringoptions.get("roleGroupSeperator");
          ifoption != null )
              = option.charAt(0);
          // Load the properties file that contains the list of users and passwords
          loadRoles();
       }
       catch (Exception e)
      {
         // Note that although this exception isn't passed on, users or roles will be null
         // so that any call to login will throw a LoginException.
         super..error("Failed to load users/passwords/role files"e);
      }
      if )
         .trace("exit: initialize(Subject, CallbackHandler, Map, Map)");
   }
   public boolean login() throws LoginException
   {
      if )
         .trace("enter: login()");
      if ( == null)
         throw new LoginException("Missing roles.properties file.");
      boolean wasSuccessful = super.login();
      if )
         .trace("exit: login()");
      return wasSuccessful;
   }

   
This method is pretty much straight from the UsersRolesLoginModule.

   protected Group[] getRoleSets() throws LoginException
   {
      if )
         .trace("enter: getRoleSets()");
      String targetUser = getUsername();
      Group[] roleSets = Util.getRoleSets(targetUserthis);
      if )
         .trace("exit: getRoleSets()");
      return roleSets;
   }
   private void loadRoles() throws IOException
   {
   }
New to GrepCode? Check out our FAQ X