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 Mon, 02 Jul 2001 07:40:52 GMT
taylor      01/07/02 00:40:52

  Modified:    src/java/org/apache/jetspeed/services JetspeedSecurity.java
                        Profiler.java
               src/java/org/apache/jetspeed/services/profiler
                        JetspeedProfilerService.java ProfilerService.java
               src/java/org/apache/jetspeed/services/resources
                        JetspeedResources.java
               src/java/org/apache/jetspeed/services/security
                        JetspeedDBSecurityService.java
                        JetspeedSecurityService.java
  Log:
  - implemented method JetspeedSecurity.removeUser
  - implemented method Profiler.removeUserProfile
  - modified Profiler.createUserProfile to accept User object instead of userName string
  
  Revision  Changes    Path
  1.4       +13 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JetspeedSecurity.java	2001/06/28 08:51:55	1.3
  +++ JetspeedSecurity.java	2001/07/02 07:40:42	1.4
  @@ -71,7 +71,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.3 2001/06/28 08:51:55 taylor Exp $
  + * @version $Id: JetspeedSecurity.java,v 1.4 2001/07/02 07:40:42 taylor Exp $
    */
   
   abstract public class JetspeedSecurity extends TurbineSecurity
  @@ -109,9 +109,21 @@
          return ((JetspeedSecurityService)getService()).checkPermission(user, action, portlet);
       }
   
  +    /**
  +     * @see JetspeedSecurityService#addUser
  +     */
      public static void addUser( User user, String password, RunData data )
           throws Exception
       {
          ((JetspeedSecurityService)getService()).addUser(user, password, data);
  +    }
  +
  +    /**
  +     * @see JetspeedSecurityService#removeUser
  +     */
  +   public static void removeUser( User user, RunData data )
  +        throws Exception
  +    {
  +       ((JetspeedSecurityService)getService()).removeUser(user, data);
       }
   }
  
  
  
  1.7       +15 -5     jakarta-jetspeed/src/java/org/apache/jetspeed/services/Profiler.java
  
  Index: Profiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/Profiler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Profiler.java	2001/06/09 15:37:31	1.6
  +++ Profiler.java	2001/07/02 07:40:43	1.7
  @@ -60,6 +60,7 @@
   import org.apache.turbine.services.TurbineServices;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.DynamicURI;
  +import org.apache.turbine.om.security.User;
   import org.apache.jetspeed.capability.CapabilityMap;
   import org.apache.jetspeed.util.MimeType;
   import java.io.IOException;
  @@ -71,7 +72,7 @@
    * @see org.apache.jetspeed.services.profiler.Profiler
    * @see org.apache.jetspeed.services.profiler.ProfilerService
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
  - * @version $Id: Profiler.java,v 1.6 2001/06/09 15:37:31 raphael Exp $
  + * @version $Id: Profiler.java,v 1.7 2001/07/02 07:40:43 taylor Exp $
    */
   public class Profiler
   {
  @@ -134,19 +135,28 @@
       /**
        * @see ProfilerService#createUserProfile
        */
  -    public static Profile createUserProfile(RunData rundata, String userName)
  +    public static Profile createUserProfile(RunData rundata, User user)
           throws IOException, ProfileException
       {
  -        return getService().createUserProfile( rundata, userName );
  +        return getService().createUserProfile( rundata, user );
       }
   
       /**
        * @see ProfilerService#createUserProfile
        */
  -    public static Profile createUserProfile(RunData rundata, String userName, MimeType
mt)
  +    public static Profile createUserProfile(RunData rundata, User user, MimeType mt)
           throws IOException, ProfileException
       {
  -        return getService().createUserProfile( rundata, userName, mt );
  +        return getService().createUserProfile( rundata, user, mt );
  +    }
  +
  +    /**
  +     * @see ProfilerService#removeUserProfile
  +     */
  +    public static void removeUserProfile(RunData rundata, User user)
  +        throws IOException, ProfileException
  +    {
  +        getService().removeUserProfile( rundata, user );
       }
   
       /**
  
  
  
  1.8       +81 -50    jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java
  
  Index: JetspeedProfilerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JetspeedProfilerService.java	2001/06/19 15:20:31	1.7
  +++ JetspeedProfilerService.java	2001/07/02 07:40:45	1.8
  @@ -66,6 +66,7 @@
   import org.apache.jetspeed.om.newregistry.RegistryException;
   import org.apache.jetspeed.om.newregistry.MediaTypeEntry;
   import org.apache.jetspeed.util.FileCopy;
  +import org.apache.jetspeed.util.DirectoryUtils;
   
   //turbine stuff
   import org.apache.turbine.util.Log;
  @@ -110,7 +111,7 @@
    *
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
    * @author <a href="mailto:sgala@hisitech.com">Santiago Gala</a>
  - * @version $Id: JetspeedProfilerService.java,v 1.7 2001/06/19 15:20:31 taylor Exp $
  + * @version $Id: JetspeedProfilerService.java,v 1.8 2001/07/02 07:40:45 taylor Exp $
    */
   
   public class JetspeedProfilerService  extends TurbineBaseService
  @@ -352,71 +353,85 @@
           return profile;
       }
   
  -    public Profile createUserProfile(RunData rundata, String userName)
  +    public Profile createUserProfile(RunData rundata, User user)
           throws IOException, ProfileException
       {
  -        return createUserProfile(rundata, userName, null);
  +        return createUserProfile(rundata, user, null);
       }
   
       /**
        *  create a user profile and its resources (psml) for a new user
        *
        * @param rundata the rundata object for the current request
  -     * @param userName the new user to create
  +     * @param newUser the new user to create
        * @throws IOException when the filecopy fails
        * @return a new Profile object
        */
  -    public Profile createUserProfile(RunData rundata, String userName, MimeType mimeType)
  +    public Profile createUserProfile(RunData rundata, User newUser, MimeType mimeType)
           throws IOException, ProfileException
       {
  -        CapabilityMap cm;
  -        if (null == mimeType)
  -            cm = CapabilityMapFactory.getCapabilityMap( rundata );
  -        else
  -            cm = CapabilityMapFactory.getCapabilityMap(mimeType.toString());
  -
  -        // FIXME: this needs to be handled better for users/groups/roles
  -        rundata.getParameters().add(TEMP_USER, userName);
  -        //Profile profile = getResourceURL(rundata, cm, false);
  -        // get the media type from the capability map or rundata
  -        String mediaType = getMediaType(rundata, cm);
  +        User currentUser = rundata.getUser();
           BaseProfile profile = new BaseProfile();
  -        // get the target profile
  -        String path = getPath(rundata, mediaType, profile);
  -        String resource = getResource(rundata, profile);
  -        String finalPath = root + path + resource;
  -        String realPath = TurbineServlet.getRealPath(finalPath);
  -        File file = new File(realPath);
  -        if (!file.exists())
  +
  +        try
           {
  -            // copy from first psml resource found in fallback path
  -            Profile sourceProfile = getResourceURL(rundata, cm, true);
  -            String  sourceURL = sourceProfile.getURL();
  -            String sourceReal = null;
  -            try
  -            {
  -                sourceReal = new URL(sourceURL).getFile();
  -            }
  -            catch (MalformedURLException e)
  +            rundata.setUser(newUser);
  +
  +            CapabilityMap cm;
  +            if (null == mimeType)
  +                cm = CapabilityMapFactory.getCapabilityMap( rundata );
  +            else
  +                cm = CapabilityMapFactory.getCapabilityMap(mimeType.toString());
  +    
  +            // FIXME: this needs to be handled better for users/groups/roles
  +            // rundata.getParameters().add(TEMP_USER, userName);
  +
  +            String mediaType = getMediaType(rundata, cm);
  +
  +            // get the target profile
  +            String path = getPath(rundata, mediaType, profile);
  +            String resource = getResource(rundata, profile);
  +            String finalPath = root + path + resource;
  +            String realPath = TurbineServlet.getRealPath(finalPath);
  +            File file = new File(realPath);
  +            if (!file.exists())
               {
  -                if (sourceURL.startsWith("file:"))
  -                    sourceReal = sourceURL.substring(5);
  -                else
  -                    sourceReal = sourceURL;
  +                // copy from first psml resource found in fallback path
  +                Profile sourceProfile = getResourceURL(rundata, cm, true);
  +                String  sourceURL = sourceProfile.getURL();
  +                String sourceReal = null;
  +                try
  +                {
  +                    sourceReal = new URL(sourceURL).getFile();
  +                }
  +                catch (MalformedURLException e)
  +                {
  +                    if (sourceURL.startsWith("file:"))
  +                        sourceReal = sourceURL.substring(5);
  +                    else
  +                        sourceReal = sourceURL;
  +                }
  +    
  +                // make the directories and then copy it
  +                String parent = file.getParent();
  +                File filePath = new File(parent);
  +                filePath.mkdirs();
  +                FileCopy.copy( sourceReal, realPath );
               }
  -
  -            // make the directories and then copy it
  -            String parent = file.getParent();
  -            File filePath = new File(parent);
  -            filePath.mkdirs();
  -            FileCopy.copy( sourceReal, realPath );
  -        }
  -        URL url = TurbineServlet.getResource( finalPath );
  -        if (url != null)
  -            profile.setURL(url.toString());
  -        else
  -            profile.setURL(finalPath);
  -        this.setSessionProfile(rundata, profile);
  +            URL url = TurbineServlet.getResource( finalPath );
  +            if (url != null)
  +                profile.setURL(url.toString());
  +            else
  +                profile.setURL(finalPath);
  +            this.setSessionProfile(rundata, profile);     
  +        }
  +        catch (Exception e)
  +        {
  +        }
  +        finally
  +        {
  +            rundata.setUser(currentUser);
  +        }
           return profile;
       }
   
  @@ -627,7 +642,6 @@
           // search for language specific resources at each level
           if (useLanguage && rundata != null) {
               //String language = rundata.getRequest().getHeader("Accept-Language");
  -            //System.out.println("**** Language = " + language );
               Locale locale = (Locale)rundata.getUser().getTemp("locale");
               if (locale == null)
               {
  @@ -1164,4 +1178,21 @@
           return (new File(templateKey).exists());
       }
   
  +   /**
  +     *  Removes a user profile and all of its resources (psml) for a given user.
  +     *
  +     * @param rundata the rundata object for the current request
  +     * @param user the new user to create
  +     */
  +    public void removeUserProfile(RunData rundata, User user)
  +        throws IOException, ProfileException
  +    {
  +         StringBuffer path = new StringBuffer(root);
  +         path.append(PATH_USER);
  +         path.append(user.getUserName());
  +
  +        String finalPath = path.toString();
  +        String realPath = TurbineServlet.getRealPath(finalPath);
  +        DirectoryUtils.rmdir(realPath);
  +   }
   }
  
  
  
  1.6       +16 -5     jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfilerService.java
  
  Index: ProfilerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfilerService.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ProfilerService.java	2001/06/09 15:37:33	1.5
  +++ ProfilerService.java	2001/07/02 07:40:46	1.6
  @@ -57,6 +57,7 @@
   import org.apache.jetspeed.om.profile.*;
   import org.apache.jetspeed.services.Profiler;
   import org.apache.jetspeed.capability.CapabilityMap;
  +import org.apache.turbine.om.security.User;
   import org.apache.turbine.services.Service;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.DynamicURI;
  @@ -68,7 +69,7 @@
    * 
    * @see org.apache.jetspeed.om.profile.Profile
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
  - * @version $Id: ProfilerService.java,v 1.5 2001/06/09 15:37:33 raphael Exp $
  + * @version $Id: ProfilerService.java,v 1.6 2001/07/02 07:40:46 taylor Exp $
    */
   
   public interface ProfilerService extends Service
  @@ -127,10 +128,10 @@
        *  create a user profile and its resources (psml) for a new user
        *
        * @param rundata the rundata object for the current request
  -     * @param userName the new user to create
  +     * @param user the new user to create
        * @return a new Profile object
        */
  -    public Profile createUserProfile(RunData rundata, String userName)
  +    public Profile createUserProfile(RunData rundata, User user)
           throws IOException, ProfileException;
   
       /**
  @@ -138,10 +139,20 @@
        *  for a specific mimetype
        *
        * @param rundata the rundata object for the current request
  -     * @param userName the new user to create
  +     * @param user the new user to create
  +     * @param mt the specific mimeType to create a profile for
        * @return a new Profile object
        */
  -    public Profile createUserProfile(RunData rundata, String userName, MimeType mt)
  +    public Profile createUserProfile(RunData rundata, User user, MimeType mt)
  +        throws IOException, ProfileException;
  +
  +   /**
  +     *  Removes a user profile and all of its resources (psml) for a given user.
  +     *
  +     * @param rundata the rundata object for the current request
  +     * @param user the new user to be removed
  +     */
  +    public void removeUserProfile(RunData rundata, User user)
           throws IOException, ProfileException;
   
        /**
  
  
  
  1.7       +8 -1      jakarta-jetspeed/src/java/org/apache/jetspeed/services/resources/JetspeedResources.java
  
  Index: JetspeedResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/resources/JetspeedResources.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JetspeedResources.java	2001/05/27 15:34:37	1.6
  +++ JetspeedResources.java	2001/07/02 07:40:48	1.7
  @@ -64,7 +64,7 @@
    * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
    * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
    * @author <a href="mailto:tom@PIsoftware.com">Tom Adams</a>
  - * @version $Id: JetspeedResources.java,v 1.6 2001/05/27 15:34:37 raphael Exp $
  + * @version $Id: JetspeedResources.java,v 1.7 2001/07/02 07:40:48 taylor Exp $
    */
   public class JetspeedResources extends TurbineResources {
   
  @@ -137,5 +137,12 @@
   
       // this is the value that is stored in the database for confirmed users
       public static final String CONFIRM_VALUE = "CONFIRMED";
  +
  +    // parameter names for the Jetspeed path framework elements    
  +    public static final String PATH_PORTLET_KEY = "portlet";
  +    public static final String PATH_ACTION_KEY = "action";
  +    public static final String PATH_SCREEN_KEY = "screen";
  +    public static final String PATH_TEMPLATE_KEY = "template";
  +    public static final String PATH_PANEL_KEY = "select-panel";        
   
   }
  
  
  
  1.5       +30 -2     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JetspeedDBSecurityService.java	2001/06/28 08:52:01	1.4
  +++ JetspeedDBSecurityService.java	2001/07/02 07:40:50	1.5
  @@ -75,7 +75,7 @@
    *
    * @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.4 2001/06/28 08:52:01 taylor Exp $
  + * @version $Id: JetspeedDBSecurityService.java,v 1.5 2001/07/02 07:40:50 taylor Exp $
    */
   
   
  @@ -161,6 +161,17 @@
           return true;
       }
   
  +   /**
  +     * Adds a user to the backend database.
  +     * Adds the default user role for this user.
  +     * Creates a default user profile in the PSML directory.
  +     * 
  +     * @param user The Turbine User object to be added to the database.
  +     * @param password The user's password.
  +     * @param rundata The request rundata.
  +     * @exception Can throw database exceptions or profiler exceptions
  +     *            
  +     */ 
       public void addUser( User user, String password, RunData data )
           throws Exception
       {
  @@ -169,7 +180,24 @@
           grant(user, getGroup(JETSPEED_GROUP), getRole(JETSPEED_ROLE_USER));
   
           user.setHasLoggedIn(new Boolean (true));        
  -        Profiler.createUserProfile(data, user.getUserName());
  +        
  +        Profiler.createUserProfile(data, user);
  +    }
  +
  +   /**
  +     * Removes user from the backend database.
  +     * Removes the user's profile in the PSML directory.
  +     * 
  +     * @param user The Turbine User object to be added to the database.
  +     * @param rundata The request rundata.
  +     * @exception Can throw database exceptions or profiler exceptions
  +     *            
  +     */ 
  +    public void removeUser( User user, RunData data ) 
  +        throws Exception
  +    {
  +        removeUser(user);
   
  +        Profiler.removeUserProfile(data, user);
       }
   }
  
  
  
  1.3       +4 -1      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedSecurityService.java	2001/06/28 08:52:05	1.2
  +++ JetspeedSecurityService.java	2001/07/02 07:40:50	1.3
  @@ -71,7 +71,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.2 2001/06/28 08:52:05 taylor Exp $
  + * @version $Id: JetspeedSecurityService.java,v 1.3 2001/07/02 07:40:50 taylor Exp $
    */
   
   
  @@ -80,4 +80,7 @@
      public void addUser( User user, String password, RunData data )
           throws Exception;
    
  +    public void removeUser( User user, RunData data ) 
  +        throws Exception;
  +
   }
  
  
  

---------------------------------------------------------------------
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