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;
A Certificate Login Module that gets its role information from a database. This module is the functional equivelant of the DatabaseServerLoginModule minus the usersQuery.

Author(s):
Jason Essington
Scott.Stark@jboss.org
Version:
$Revision: 73520 $
See also:
DatabaseServerLoginModule
{
   
The JNDI name of the DataSource to use
   private String dsJndiName;
   
The sql query to obtain the user roles
   private String rolesQuery = "select Role, RoleGroup from Roles where PrincipalID=?";
   
Whether to suspend resume transactions during database operations
   protected boolean suspendResume = true;

   

Parameters:
options - dsJndiName: The name of the DataSource of the database containing the Principals, Roles tables rolesQuery: The prepared statement query, equivalent to: "select Role, RoleGroup from Roles where PrincipalID=?"
   public void initialize(Subject subjectCallbackHandler callbackHandler,
      Map<String,?> sharedStateMap<String,?> options)
   {
      super.initialize(subjectcallbackHandlersharedStateoptions);
       = (Stringoptions.get("dsJndiName");
      if == null )
          = "java:/DefaultDS";
      
      Object tmp = options.get("rolesQuery");
      iftmp != null )
          = tmp.toString();
      tmp = options.get("suspendResume");
      iftmp != null )
          = Boolean.valueOf(tmp.toString()).booleanValue();
      if (.isTraceEnabled())
      {
         .trace("DatabaseServerLoginModule, dsJndiName="+);
         .trace("rolesQuery="+);
         .trace("suspendResume="+);
      }
   }

   
   protected Group[] getRoleSets() throws LoginException
   {
      String username = getUsername();
      Group[] roleSets = Util.getRoleSets(usernamethis);
      return roleSets;
   }
   
New to GrepCode? Check out our FAQ X