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/modules/actions CreateNewUserAndConfirm.java
Date Tue, 19 Jun 2001 16:34:42 GMT
taylor      01/06/19 09:34:41

  Modified:    src/java/org/apache/jetspeed/modules/actions
                        CreateNewUserAndConfirm.java
  Log:
  - updated CreateNewUserAndConfirm action to use TurbineSecurity instead of old Village db
  - this should fix the bug in Oracle, where the sequence id is not being automatically created.
  - anyone who has Oracle installed, please test. I currently don't have Oracle on a connected
machine.
  - tested successfully on Hypersonic SQL.
  
  Revision  Changes    Path
  1.16      +57 -74    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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CreateNewUserAndConfirm.java	2001/06/04 07:21:10	1.15
  +++ CreateNewUserAndConfirm.java	2001/06/19 16:34:38	1.16
  @@ -55,36 +55,36 @@
   package org.apache.jetspeed.modules.actions;
    
   
  -// JDK Stuff
  -import java.sql.Connection;
  -import java.util.Vector;
  -import javax.servlet.RequestDispatcher;
  +// java.util
  +import java.util.Date;
   
  -// External Stuff
  +// turbine.modules
   import org.apache.turbine.modules.Action;
   import org.apache.turbine.modules.ActionLoader;
  +
  +// resources
   import org.apache.turbine.services.localization.Localization;
   import org.apache.turbine.services.resources.TurbineResources;
  -import org.apache.turbine.services.db.TurbineDB;
  +import org.apache.jetspeed.services.resources.JetspeedResources;
  +
  +// templates
  +import org.apache.turbine.services.template.TurbineTemplate;
  +
  +// turbine.util
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.GenerateUniqueId;
  -import org.apache.turbine.util.db.Criteria;
  -import org.apache.turbine.util.db.pool.DBConnection;
  -import org.apache.turbine.util.db.map.TurbineMapBuilder;
  -import org.apache.turbine.om.peer.BasePeer;
  +import org.apache.turbine.util.StringUtils;
  +
  +// turbine.om
   import org.apache.turbine.om.security.User;
  -import org.apache.turbine.om.security.peer.TurbineUserPeer;
  -import org.apache.turbine.om.security.TurbineUser;
  -import com.workingdogs.village.TableDataSet;
  -import com.workingdogs.village.Record;
  +
  +// profiler
   import org.apache.jetspeed.services.Profiler;
  -import org.apache.jetspeed.services.resources.JetspeedResources;
  -import org.apache.turbine.util.security.TurbineSecurityException;
  -import org.apache.turbine.services.security.TurbineSecurity;
  +
  +// security
  +import org.apache.jetspeed.services.JetspeedSecurity;
   import org.apache.turbine.util.security.AccessControlList;
  -import org.apache.turbine.util.DynamicURI;
  -import org.apache.turbine.util.StringUtils;
   
   /**
       This action validates the form input from the NewAccount Screen. 
  @@ -105,7 +105,6 @@
   {
       public void doPerform( RunData data ) throws Exception
       {
  -        TurbineMapBuilder mapBuilder = (TurbineMapBuilder) BasePeer.getMapBuilder();
   
           String submit = "submit1";
           String str = (String) data.getUser().getTemp ( submit, "asdfasdf" );
  @@ -113,7 +112,7 @@
               .equalsIgnoreCase( data.getParameters().getString(submit, "")) )
           {
               data.getUser().removeTemp(submit);
  -            data.setScreenTemplate( TurbineResources.getString("screen.homepage") );
  +            data.setScreenTemplate( TurbineTemplate.getDefaultScreen() );
               return;            
           }
           
  @@ -147,45 +146,35 @@
   
           String CHNAME = "Choose another name.";
         
  -        // Make sure that the user doesn't already exist
  -        // and that the username is not the CHNAME string
  -        Criteria testcrit = new Criteria();
  -        testcrit.add ( TurbineUserPeer.getColumnName(mapBuilder.getUsername()), username
);
  -        Vector output = TurbineUserPeer.doSelect(testcrit);
  -
  -        // if the username does not already exist, then we are all good!
  -        if ((output == null || output.size() == 0) && ! username.equalsIgnoreCase(CHNAME))
  -        {
  -            // get a connection to the db
  -            DBConnection db = TurbineDB.getConnection();
  -            Connection connection = db.getConnection();
  -
  -            // execute the query
  -            TableDataSet tds = new TableDataSet( connection, TurbineUserPeer.getTableName()
);
  -            try
  +        try
  +        {
  +            if (!JetspeedSecurity.accountExists(username))
               {
  +                Date now = new Date();
  +
  +                User user = JetspeedSecurity.getUserInstance();                
  +                
  +                user.setUserName( username );   
  +                user.setPassword ( pass1 );
  +                //er.setModifiedDate(now);
  +                user.setCreateDate(now);
  +                user.setLastLogin(new Date(0));
  +                user.setFirstName( data.getParameters().getString("firstname") );
  +                user.setLastName( data.getParameters().getString("lastname") );
  +                user.setEmail( data.getParameters().getString("email") );             
          
  +
                   // create a unique confirmation string for the new user
                   String confirmValue = GenerateUniqueId.getIdentifier();
  -
  -                // add the string to the user's perm storage
  -                User user = data.getUser();
  -                if (user != null) 
  -                    user.setPerm(User.CONFIRM_VALUE, confirmValue);
  -                // add the user's details to the database
  -                Record rec = tds.addRecord();
  -                String password = data.getParameters().getString("password");
  -                rec.setValue ( mapBuilder.getPassword(), password );
  -                rec.setValue ( mapBuilder.getUsername(), username );
  -                rec.setValue ( mapBuilder.getFirstName(), data.getParameters().getString("firstname")
);
  -                rec.setValue ( mapBuilder.getLastName(), data.getParameters().getString("lastname")
);
  -                rec.setValue ( mapBuilder.getEmail(), data.getParameters().getString("email")
);
  -                rec.setValue ( mapBuilder.getCreated(), new java.util.Date() );
  +    
                   // allow for disabling of email for configurations without a mail server
                   boolean enableMail = JetspeedResources.getBoolean("confirm.email.enable",
false);
                   if (false == enableMail)
                       confirmValue = JetspeedResources.CONFIRM_VALUE;
  -                rec.setValue ( mapBuilder.getConfirmValue(), confirmValue );
  -                rec.save();
  +    
  +                user.setConfirmed( confirmValue );
  +
  +                JetspeedSecurity.addUser(user, pass1);
  +
                   data.setMessage(Localization.getString("CREATENEWUSERANDCONFIRM_CREATE"));
                   if (enableMail)
                   {
  @@ -194,29 +183,24 @@
                   }
                   else
                   {
  -                    bypassConfirmMail(data, username, password);
  +                    bypassConfirmMail(data, username, pass1);
                   }
   
  -            }
  -            catch (Exception e)
  -            {
  -              data.setMessage(e.toString());
  -              data.setStackTrace(StringUtils.stackTrace(e), e);
  -              data.setScreenTemplate("Error.vm");
               }
  -            finally
  +            else // username exists. show the screen again.
               {
  -                if ( tds != null ) tds.close();
  -                TurbineDB.releaseConnection(db);
  +                data.setMessage(Localization.getString("CREATENEWUSERANDCONFIRM_CHOOSENEWNAME"));
  +                data.setScreenTemplate("NewAccount.vm");
  +                // set the username to be the CHNAME string so that it is 
  +                // clear that this needs to be replaced
  +                data.getParameters().add("username", CHNAME);
               }
           }
  -        else // username exists. show the screen again.
  +        catch (Exception e)
           {
  -            data.setMessage(Localization.getString("CREATENEWUSERANDCONFIRM_CHOOSENEWNAME"));
  -            data.setScreenTemplate("NewAccount.vm");
  -            // set the username to be the CHNAME string so that it is 
  -            // clear that this needs to be replaced
  -            data.getParameters().add("username", CHNAME);
  +          data.setMessage(e.toString());
  +          data.setStackTrace(StringUtils.stackTrace(e), e);
  +          data.setScreenTemplate("Error.vm");
           }
       }
   
  @@ -229,12 +213,12 @@
        * @param password The user's password.
        */
       private void bypassConfirmMail(RunData data, String username, String password)
  -    {
  +    {        
           User usr = null;
           try
           {
             // Authenticate the user and get the object.
  -          usr = TurbineSecurity.getAuthenticatedUser( username, password );
  +          usr = JetspeedSecurity.getAuthenticatedUser( username, password );
   
             // Store the user object.
             data.setUser(usr);
  @@ -248,7 +232,7 @@
             AccessControlList acl = data.getACL();
             if ( acl == null )
             {
  -              acl = TurbineSecurity.getACL( data.getUser() );
  +              acl = JetspeedSecurity.getACL( data.getUser() );
                 data.getSession().setAttribute( AccessControlList.SESSION_KEY,
                                             (Object)acl );
             }
  @@ -266,8 +250,7 @@
                  }
              }
             // bring logged on user to homepage with internal redirect
  -          String homepage = TurbineResources.getString("screen.homepage");
  -          data.setScreenTemplate(homepage);
  +          data.setScreenTemplate(TurbineTemplate.getDefaultScreen());
             data.setMessage(TurbineResources.getString("login.welcome"));
           }
           catch ( Exception e )
  
  
  

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


Mime
View raw message