taylor 02/02/11 00:05:12
Modified: src/java/org/apache/jetspeed/services/profiler
JetspeedProfilerService.java
src/java/org/apache/jetspeed/services/security
JetspeedDBSecurityService.java
JetspeedSecurityService.java
Log:
- New Profiler feature: Role-based PSML. If the profiler fails to find
a profile for a user, it then searches all the roles for that user for the profile.
- New Profiler feature: When creating new users, the default
template (user account) is now configurable in the JR.p. Setting this to empty will
not create any PSML entries, and then role-based PSML will be used (if enabled).
- New Profiler feature: Configurable media types for new users.
The JR.p configures which media types profiles are cloned from the template account
when a new user is created. List the media types with commas as delimiters.
- New JetspeedSecurity feature: Configurable roles to assign to a new user.
The roles that are assigned to a new user are configurable via the JR.p. List the
roles
with commas as delimiters.
Revision Changes Path
1.22 +45 -24
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.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- JetspeedProfilerService.java 10 Feb 2002 08:00:12 -0000 1.21
+++ JetspeedProfilerService.java 11 Feb 2002 08:05:12 -0000 1.22
@@ -114,7 +114,6 @@
import org.apache.jetspeed.util.FileCopy;
import org.apache.jetspeed.util.DirectoryUtils;
-
/**
* <p>This is an implementation of the <code>Profiler</code> interface.
*
@@ -134,7 +133,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a>
- * @version $Id: JetspeedProfilerService.java,v 1.21 2002/02/10 08:00:12 taylor Exp
$
+ * @version $Id: JetspeedProfilerService.java,v 1.22 2002/02/11 08:05:12 taylor Exp
$
*/
public class JetspeedProfilerService extends TurbineBaseService
@@ -142,18 +141,23 @@
{
// configuration keys
- private final static String CONFIG_RESOURCE_DEFAULT = ".resource.default";
- private final static String CONFIG_RESOURCE_EXT = ".resource.ext";
- private final static String CONFIG_SECURITY = ".security";
- private final static String CONFIG_LANGUAGE = ".language";
- private final static String CONFIG_ROLE_FALLBACK = ".rolefallback";
-
+ private final static String CONFIG_RESOURCE_DEFAULT = "resource.default";
+ private final static String CONFIG_RESOURCE_EXT = "resource.ext";
+ private final static String CONFIG_SECURITY = "security";
+ private final static String CONFIG_LANGUAGE = "language";
+ private final static String CONFIG_ROLE_FALLBACK = "rolefallback";
+ private final static String CONFIG_NEWUSER_TEMPLATE = "newuser.template";
+ private final static String CONFIG_NEWUSER_MEDIA = "newuser.media_types";
+
// default configuration values
private final static String DEFAULT_CONFIG_RESOURCE_DEFAULT = "default";
private final static String DEFAULT_CONFIG_RESOURCE_EXT = ".psml";
private final static boolean DEFAULT_CONFIG_SECURITY = false;
private final static boolean DEFAULT_CONFIG_LANGUAGE = true;
private final static boolean DEFAULT_CONFIG_ROLE_FALLBACK = true;
+ private final static String DEFAULT_CONFIG_NEWUSER_TEMPLATE = null;
+ private final static String [] DEFAULT_CONFIG_NEWUSER_MEDIA =
+ { "html", "wml" };
private final static String PATH_EXTENSION_DELIMITER = ".";
// messages
@@ -167,11 +171,12 @@
String resourceExt; // the default extension for a resource
// MODIFIED: A. Kempf
- String parentAccount = null; // the parent account which is used to create
profiles
+ String newUserTemplate = DEFAULT_CONFIG_NEWUSER_TEMPLATE;
- boolean useSecurity = true; // use security features
+ boolean useSecurity = false; // use security features
boolean useLanguage = true; // use extended language mapping features
boolean useRoleFallback = true;
+ String mediaTypes[] = null;
// lookup a media type based on mime-type
private Map mediaMap = null;
@@ -187,17 +192,24 @@
public Profile createProfile(RunData data, Profile profile)
throws ProfileException
{
- Profile dummy = null;
-
-
- if (parentAccount == null)
- parentAccount = new String ("turbine");
+ Profile current = null;
+ String mediaType = getMediaType(data,
((JetspeedRunData)data).getCapability());
- createProfile (data, profile, "wml", parentAccount);
- dummy = createProfile (data, profile, "html", parentAccount);
-
-
- return dummy;
+ // if template is null then use role-based psml
+ if (newUserTemplate == null)
+ return current;
+
+ if (mediaTypes != null)
+ {
+ Profile dummy;
+ for (int ix=0; ix < mediaTypes.length; ix++)
+ {
+ dummy = createProfile(data, profile, mediaTypes[ix],
newUserTemplate);
+ if (mediaTypes[ix].equalsIgnoreCase(mediaType))
+ current = dummy;
+ }
+ }
+ return current;
}
// --------------------------------------------------------------------------
@@ -671,12 +683,8 @@
ResourceService serviceConf =
((TurbineServices)TurbineServices.getInstance())
.getResources(ProfilerService.SERVICE_NAME);
-
- resourceDefault = serviceConf.getString( CONFIG_RESOURCE_DEFAULT );
- resourceDefault = serviceConf.getString(
"services.Profiler.resource.default" );
resourceDefault = serviceConf.getString( CONFIG_RESOURCE_DEFAULT,
DEFAULT_CONFIG_RESOURCE_DEFAULT );
-
resourceExt = serviceConf.getString( CONFIG_RESOURCE_EXT,
DEFAULT_CONFIG_RESOURCE_EXT );
if (-1 == resourceExt.indexOf(PATH_EXTENSION_DELIMITER))
resourceExt = PATH_EXTENSION_DELIMITER + resourceExt;
@@ -686,6 +694,19 @@
useRoleFallback = serviceConf.getBoolean( CONFIG_ROLE_FALLBACK,
DEFAULT_CONFIG_ROLE_FALLBACK );
+ newUserTemplate = serviceConf.getString( CONFIG_NEWUSER_TEMPLATE,
DEFAULT_CONFIG_NEWUSER_TEMPLATE );
+
+ try
+ {
+ mediaTypes = serviceConf.getStringArray(CONFIG_NEWUSER_MEDIA);
+ }
+ catch (Exception e)
+ {}
+
+ if (null == mediaTypes || mediaTypes.length == 0)
+ {
+ mediaTypes = DEFAULT_CONFIG_NEWUSER_MEDIA;
+ }
}
/**
1.13 +60 -5
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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- JetspeedDBSecurityService.java 29 Nov 2001 13:47:18 -0000 1.12
+++ JetspeedDBSecurityService.java 11 Feb 2002 08:05:12 -0000 1.13
@@ -79,19 +79,64 @@
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.services.PsmlManager;
+import org.apache.turbine.services.TurbineServices;
+import org.apache.turbine.services.InitializationException;
+import javax.servlet.ServletConfig;
+import org.apache.turbine.services.resources.ResourceService;
+import org.apache.turbine.util.Log;
+
/**
* <p>This is an implementation of the <code>JetspeedSecurityService</code>
interface.
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a>
- * @version $Id: JetspeedDBSecurityService.java,v 1.12 2001/11/29 13:47:18 kimptoc
Exp $
+ * @version $Id: JetspeedDBSecurityService.java,v 1.13 2002/02/11 08:05:12 taylor
Exp $
*/
public class JetspeedDBSecurityService extends DBSecurityService
implements JetspeedSecurityService
{
+ private final static String CONFIG_NEWUSER_ROLES = "newuser.roles";
+ private final static String [] DEFAULT_CONFIG_NEWUSER_ROLES =
+ { "user" };
+ String roles[] = null;
+
+ /**
+ * This is the early initialization method called by the
+ * Turbine <code>Service</code> framework
+ * @param conf The <code>ServletConfig</code>
+ * @exception throws a <code>InitializationException</code> if the service
+ * fails to initialize
+ */
+ public synchronized void init(ServletConfig conf) throws
InitializationException
+ {
+ // already initialized
+ if (getInit()) return;
+
+ super.init(conf);
+
+ // get configuration parameters from Jetspeed Resources
+ ResourceService serviceConf =
((TurbineServices)TurbineServices.getInstance())
+
.getResources(JetspeedSecurityService.SERVICE_NAME);
+
+ try
+ {
+ roles = serviceConf.getStringArray(CONFIG_NEWUSER_ROLES);
+ }
+ catch (Exception e)
+ {}
+
+ if (null == roles || roles.length == 0)
+ {
+ roles = DEFAULT_CONFIG_NEWUSER_ROLES;
+ }
+ // initialization done
+ setInit(true);
+ }
+
+
/**
* given a user, checks if a user has access to a given portlet for the given
action
*
@@ -213,10 +258,20 @@
{
addUser(user, password);
- grant(user,
- getGroup(JetspeedSecurity.JETSPEED_GROUP),
- getRole(JetspeedSecurity.JETSPEED_ROLE_USER));
-
+ for (int ix = 0; ix < roles.length; ix++)
+ {
+ try
+ {
+ grant(user,
+ getGroup(JetspeedSecurity.JETSPEED_GROUP),
+ getRole(roles[ix]));
+// getRole(JetspeedSecurity.JETSPEED_ROLE_USER));
+ }
+ catch(Exception e)
+ {
+ Log.error("Could not grant role: " + roles[ix] + " to user " +
user.getUserName(), e);
+ }
+ }
try
{
Profile profile = new BaseProfile();
1.5 +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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JetspeedSecurityService.java 30 Jul 2001 06:45:16 -0000 1.4
+++ JetspeedSecurityService.java 11 Feb 2002 08:05:12 -0000 1.5
@@ -73,12 +73,15 @@
* for controlling access to portal resources (portlets, panes).
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
- * @version $Id: JetspeedSecurityService.java,v 1.4 2001/07/30 06:45:16 taylor Exp $
+ * @version $Id: JetspeedSecurityService.java,v 1.5 2002/02/11 08:05:12 taylor Exp $
*/
public interface JetspeedSecurityService extends SecurityService, AccessControl
{
+ /** The name of this service */
+ public String SERVICE_NAME = "JetspeedSecurity";
+
public void addUser( User user, String password, RunData data )
throws Exception;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>