portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/security JetspeedDBSecurityService.java JetspeedSecurityService.java
Date Sat, 23 Feb 2002 23:10:16 GMT
taylor      02/02/23 15:10:16

  Modified:    src/java/org/apache/jetspeed/modules/actions
                        CreateNewUserAndConfirm.java JLogoutUser.java
               src/java/org/apache/jetspeed/modules/actions/portlets/security
                        UserUpdateAction.java
               src/java/org/apache/jetspeed/services JetspeedSecurity.java
               src/java/org/apache/jetspeed/services/security
                        JetspeedDBSecurityService.java
                        JetspeedSecurityService.java
  Log:
  - new feature: case-insensitive logon added to JetspeedSecurity service
  
  Revision  Changes    Path
  1.28      +7 -0      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/CreateNewUserAndConfirm.java
  
  Index: CreateNewUserAndConfirm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/CreateNewUserAndConfirm.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- CreateNewUserAndConfirm.java	18 Dec 2001 03:21:27 -0000	1.27
  +++ CreateNewUserAndConfirm.java	23 Feb 2002 23:10:15 -0000	1.28
  @@ -132,6 +132,12 @@
               }
           
               String username = data.getParameters().getString("username", "");
  +
  +            // convert case if configured
  +            username = JetspeedSecurity.convertUserName(username);
  +            pass1 = JetspeedSecurity.convertPassword(pass1);
  +            pass2 = JetspeedSecurity.convertPassword(pass2);
  +
               // make sure the username exists
               if ( username.length() == 0 )
               {
  @@ -139,6 +145,7 @@
                   data.setScreenTemplate("NewAccount");
                   return;
               }            
  +            
               String email = data.getParameters().getString("email", "");
               // make sure the email exists
               if ( email.length() == 0 )
  
  
  
  1.3       +0 -2      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/JLogoutUser.java
  
  Index: JLogoutUser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/JLogoutUser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JLogoutUser.java	23 Feb 2002 02:05:05 -0000	1.2
  +++ JLogoutUser.java	23 Feb 2002 23:10:15 -0000	1.3
  @@ -75,8 +75,6 @@
   
       public void doPerform( RunData data ) throws Exception
       {
  -        System.out.println("Entering action JLogoutUser");
  -
           Log.info("Entering action JLogoutUser");
   
           // if automatic login is enabled, then remove cookies when user logs out
  
  
  
  1.6       +8 -0      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/security/UserUpdateAction.java
  
  Index: UserUpdateAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/security/UserUpdateAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UserUpdateAction.java	23 Feb 2002 02:05:05 -0000	1.5
  +++ UserUpdateAction.java	23 Feb 2002 23:10:16 -0000	1.6
  @@ -236,6 +236,11 @@
               if (password == null)
                   password = "";
               
  +            // convert case if configured
  +            password = JetspeedSecurity.convertPassword(password);
  +            user.setPassword(JetspeedSecurity.convertPassword(user.getPassword()));
  +            user.setUserName(JetspeedSecurity.convertUserName(user.getUserName()));
  +
               Date now = new Date();            
               user.setCreateDate(now);
               user.setLastLogin(now);
  @@ -489,6 +494,9 @@
               //
               rundata.getParameters().setProperties(user);    
               user.setLastAccessDate();
  +
  +            // convert case if configured
  +            user.setPassword(JetspeedSecurity.convertPassword(user.getPassword()));
   
               //
               // update the user in the database
  
  
  
  1.9       +28 -1     jakarta-jetspeed/src/java/org/apache/jetspeed/services/JetspeedSecurity.java
  
  Index: JetspeedSecurity.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/JetspeedSecurity.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JetspeedSecurity.java	5 Sep 2001 05:48:06 -0000	1.8
  +++ JetspeedSecurity.java	23 Feb 2002 23:10:16 -0000	1.9
  @@ -64,6 +64,8 @@
   import org.apache.turbine.util.security.DataBackendException;
   import org.apache.turbine.util.security.EntityExistsException;
   import org.apache.jetspeed.om.profile.ProfileException;
  +import org.apache.turbine.util.security.UnknownEntityException;
  +import org.apache.turbine.util.security.PasswordMismatchException;
   
   import org.apache.jetspeed.portal.Portlet;
   
  @@ -73,7 +75,7 @@
    * 
    * @see org.apache.jetspeed.services.security.JetspeedSecurityService
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
  - * @version $Id: JetspeedSecurity.java,v 1.8 2001/09/05 05:48:06 taylor Exp $
  + * @version $Id: JetspeedSecurity.java,v 1.9 2002/02/23 23:10:16 taylor Exp $
    */
   
   abstract public class JetspeedSecurity extends TurbineSecurity
  @@ -170,6 +172,31 @@
           throws Exception
       {
          ((JetspeedSecurityService)getService()).removeRole(role, data);
  +    }
  +
  +    /**
  +     * @see JetspeedSecurityService#getAuthenticatedUser
  +     */
  +   public static User getAuthenticatedUser(String username, String password)
  +        throws DataBackendException, UnknownEntityException, PasswordMismatchException
  +    {
  +       return ((JetspeedSecurityService)getService()).getAuthenticatedUser(username, password);
  +    }
  +
  +    /**
  +     * @see JetspeedSecurityService#convertUserName
  +     */
  +    public static String convertUserName(String username)
  +    {
  +       return ((JetspeedSecurityService)getService()).convertUserName(username);
  +    }
  +
  +    /**
  +     * @see JetspeedSecurityService#convertPassword
  +     */
  +    public static String convertPassword(String password)
  +    {
  +       return ((JetspeedSecurityService)getService()).convertPassword(password);
       }
   
   }
  
  
  
  1.15      +58 -1     jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/JetspeedDBSecurityService.java
  
  Index: JetspeedDBSecurityService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/JetspeedDBSecurityService.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JetspeedDBSecurityService.java	16 Feb 2002 13:10:21 -0000	1.14
  +++ JetspeedDBSecurityService.java	23 Feb 2002 23:10:16 -0000	1.15
  @@ -70,6 +70,8 @@
   import org.apache.turbine.util.security.AccessControlList;
   import org.apache.turbine.util.security.DataBackendException;
   import org.apache.turbine.util.security.EntityExistsException;
  +import org.apache.turbine.util.security.UnknownEntityException;
  +import org.apache.turbine.util.security.PasswordMismatchException;
   
   import org.apache.jetspeed.om.profile.Profile;
   import org.apache.jetspeed.om.profile.ProfileLocator;
  @@ -91,20 +93,29 @@
    *
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
    * @author <a href="mailto:sgala@hisitech.com">Santiago Gala</a>
  - * @version $Id: JetspeedDBSecurityService.java,v 1.14 2002/02/16 13:10:21 paulsp Exp $
  + * @version $Id: JetspeedDBSecurityService.java,v 1.15 2002/02/23 23:10:16 taylor Exp $
    */
   
   
   public class JetspeedDBSecurityService extends DBSecurityService
                                          implements JetspeedSecurityService
   {
  +
  +    private final static String CONFIG_CASEINSENSITIVE_USERNAME = "caseinsensitive.username";
  +    private final static String CONFIG_CASEINSENSITIVE_PASSWORD = "caseinsensitive.password";
  +    private final static String CONFIG_CASEINSENSITIVE_UPPER = "caseinsensitive.upper";
  +
       private final static String CONFIG_NEWUSER_ROLES     = "newuser.roles";
       private final static String CONFIG_DEFAULT_PERMISSION_LOGGEDIN     = "permission.default.loggedin";
       private final static String CONFIG_DEFAULT_PERMISSION_ANONYMOUS     = "permission.default.anonymous";
       private final static String [] DEFAULT_PERMISSIONS = {""};
       private final static String [] DEFAULT_CONFIG_NEWUSER_ROLES = 
       { "user" };
  +
       String roles[] = null;
  +    boolean caseInsensitiveUsername = false;
  +    boolean caseInsensitivePassword = false;
  +    boolean caseInsensitiveUpper = true;
   
       /**
        * This is the early initialization method called by the 
  @@ -135,6 +146,11 @@
           {
               roles = DEFAULT_CONFIG_NEWUSER_ROLES;
           }
  +
  +        caseInsensitiveUsername = serviceConf.getBoolean(CONFIG_CASEINSENSITIVE_USERNAME,
caseInsensitiveUsername);
  +        caseInsensitivePassword = serviceConf.getBoolean(CONFIG_CASEINSENSITIVE_PASSWORD,
caseInsensitivePassword);
  +        caseInsensitiveUpper = serviceConf.getBoolean(CONFIG_CASEINSENSITIVE_UPPER, caseInsensitiveUpper);
  +
           // initialization done
           setInit(true);
        }
  @@ -415,4 +431,45 @@
           }
           return false;
       }
  +
  +    /**
  +     * Authenticates an user, and constructs an User object to represent him/her.
  +     *
  +     * @param username The user name.
  +     * @param password The user password.
  +     * @return An authenticated Turbine User.
  +     * @throws DataBackendException if there was an error accessing the data backend.
  +     * @throws UnknownEntityException if user account is not present.
  +     * @throws PasswordMismatchException if the supplied password was incorrect.
  +     */
  +    public User getAuthenticatedUser(String username, String password)
  +        throws DataBackendException, UnknownEntityException, PasswordMismatchException
  +    {
  +        username = convertUserName(username);
  +        password = convertPassword(password);
  +
  +        User user = null;
  +
  +        // Authenticate the user and get the object.
  +        return super.getAuthenticatedUser( username, password );
  +    }
  +
  +    public String convertUserName(String username)
  +    {
  +        if (caseInsensitiveUsername)
  +        { 
  +            username = (caseInsensitiveUpper) ? username.toUpperCase() : username.toLowerCase();

  +        } 
  +        return username;
  +    }
  +
  +    public String convertPassword(String password)
  +    {
  +        if (caseInsensitivePassword)
  +        { 
  +            password = (caseInsensitiveUpper) ? password.toUpperCase() : password.toLowerCase();

  +        } 
  +        return password;
  +    }
  +        
   }
  
  
  
  1.6       +10 -2     jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/JetspeedSecurityService.java
  
  Index: JetspeedSecurityService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/JetspeedSecurityService.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JetspeedSecurityService.java	11 Feb 2002 08:05:12 -0000	1.5
  +++ JetspeedSecurityService.java	23 Feb 2002 23:10:16 -0000	1.6
  @@ -60,8 +60,10 @@
   import org.apache.turbine.om.security.Role;
   import org.apache.turbine.om.security.Group;
   import org.apache.turbine.util.RunData;
  -import org.apache.turbine.util.security.DataBackendException;
   import org.apache.turbine.util.security.EntityExistsException;
  +import org.apache.turbine.util.security.DataBackendException;
  +import org.apache.turbine.util.security.UnknownEntityException;
  +import org.apache.turbine.util.security.PasswordMismatchException;
   
   import org.apache.jetspeed.om.profile.Profile;
   import org.apache.jetspeed.om.profile.ProfileException;
  @@ -73,7 +75,7 @@
    * for controlling access to portal resources (portlets, panes).
    *
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
  - * @version $Id: JetspeedSecurityService.java,v 1.5 2002/02/11 08:05:12 taylor Exp $
  + * @version $Id: JetspeedSecurityService.java,v 1.6 2002/02/23 23:10:16 taylor Exp $
    */
   
   
  @@ -100,4 +102,10 @@
       public void removeRole( Role role, RunData data )
           throws Exception;
   
  +    public User getAuthenticatedUser(String username, String password)
  +        throws DataBackendException, UnknownEntityException, PasswordMismatchException;
  +
  +    public String convertUserName(String username);
  +
  +    public String convertPassword(String password);
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>


Mime
View raw message