ate         2005/03/27 14:38:28

  Modified:    components/security/src/java/org/apache/jetspeed/security/impl
                        UserManagerImpl.java
  Log:
  Fixed http://issues.apache.org/jira/browse/JS2-213:  "Adding a User with an 
invalid password creates the user (without password) although an error is 
reported"
  
  Revision  Changes    Path
  1.20      +21 -9     
jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
  
  Index: UserManagerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/UserManagerImpl.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- UserManagerImpl.java      7 Mar 2005 14:05:45 -0000       1.19
  +++ UserManagerImpl.java      27 Mar 2005 22:38:28 -0000      1.20
  @@ -235,9 +235,24 @@
                   atnProviderProxy.addUserPrincipal(userPrincipal);
                   if (password != null)
                   {
  -                    // Set private password credential
  -                    atnProviderProxy.setPassword(username, null, password,
  -                            atnProviderName);
  +                    try
  +                    {
  +                        // Set private password credential
  +                        atnProviderProxy.setPassword(username, null, 
password,atnProviderName);
  +                    }
  +                    catch (SecurityException se1)
  +                    {
  +                        try
  +                        {
  +                            // rollback created user
  +                            
atnProviderProxy.removeUserPrincipal(userPrincipal);
  +                        }
  +                        catch (SecurityException se2)
  +                        {
  +                            log.error("Failed to rollback created user after 
its password turned out to be invalid", se2);
  +                        }
  +                        throw se1;
  +                    }
                   }
                   if (log.isDebugEnabled())
                   {
  @@ -246,10 +261,7 @@
               }
           } catch (SecurityException se)
           {
  -            KeyedMessage msg = 
SecurityException.UNEXPECTED.create("UserManager.addUser",
  -                                                                   
"UserSecurityHandler",
  -                                                                   
se.getMessage());
  -            log.error(msg, se);
  +            log.error(se.getMessage(), se);
   
               // Remove the preferences node.
               try
  @@ -259,7 +271,7 @@
               {
                   bse.printStackTrace();
               }
  -            throw new SecurityException(msg, se);
  +            throw se;
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to