mcardle 2005/09/06 16:03:22 CEST
Modified files:
core/src/java/org/jahia/services/esi JesiObject.java
Log:
* adds support for the aclGroup fragment attribute to share fragments between
users with the same group permissions
Revision Changes Path
1.5 +69 -4
jahia/core/src/java/org/jahia/services/esi/JesiObject.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/JesiObject.java.diff?r1=1.4&r2=1.5&f=h
Index: JesiObject.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/JesiObject.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JesiObject.java 30 Aug 2005 15:40:12 -0000 1.4
+++ JesiObject.java 6 Sep 2005 14:03:22 -0000 1.5
@@ -1,8 +1,14 @@
package org.jahia.services.esi;
+import org.jahia.services.acl.JahiaBaseACL;
+import org.jahia.services.acl.JahiaACLException;
+import org.jahia.registries.ServicesRegistry;
+
import java.net.URL;
import java.net.MalformedURLException;
import java.util.HashMap;
+import java.util.Vector;
+import java.util.Enumeration;
public abstract class JesiObject {
@@ -17,6 +23,8 @@
public HashMap ctnlists = new HashMap();
public HashMap pages = new HashMap();
+ public Vector aclUserNames = new Vector();
+
public String header = null;
public int siteID = -1;
@@ -38,20 +46,21 @@
public String mode = null;//CAREFUL: sometimes doesn't appear, but still
make sure associated fragments are invalidated
public String pid = null;
public String site = null;//CAREFUL: sometimes doesn't appear, but still
make sure associated fragments are invalidated
-
+ public String aclGroup = null;
JesiObject() {
}
//TODO : Replace strings like "user" and "group" with Jahia constants
call
- public String getHeader() {
- return header;
- }
public void setHeader(String header) {
this.header = header;
}
+ public void addHeader(String header) {
+ this.header = header;
+ }
+
/**
* parse various components from the current URL, such as host, path,
query params etc...
*
@@ -59,6 +68,8 @@
*/
public void parseUrl(final String theURL) {
+ //TODO:use java.net.URL instead
+
URL Url = null;
try {
Url = new URL(theURL);
@@ -270,6 +281,60 @@
}
}
+
+ /**
+ * adds the current username(s) associated with given ACL (for a given
contentObject) with the current Fragment
+ * so that we know all the special user-specific permissions for any
content contained
+ * in this Fragment. So that when the requesting user wants this
fragment and his name appears in the
+ * user-specific permissions for this fragment, we generate a unique
fragment key for him.
+ *
+ * @param acl
+ */
+ public void addAclUserNames(JahiaBaseACL acl) {
+ if (getObjType().equals("Fragment")) { //TODO: get rid of this when
we support template aclGroup attributes
+ try {
+ Vector allUsersWithSpecialRights = acl.getUsernameList(null);
+ Enumeration userListEnum =
allUsersWithSpecialRights.elements();
+ while (userListEnum.hasMoreElements()) {
+ String username = (String) userListEnum.nextElement();
+ if (!aclUserNames.contains(username))
+ {
+ aclUserNames.add(username);
+ logger.info("Added AclUserName ["+username+"] to
"+getObjDetails());
+ /**
+ * the following invalidates all instances of the
current template skeleton (i.e. for all users/groups)
+ * as they might still be pointing to a aclGroup
attributed fragment which they shouldn't. For example,
+ * now that we have discovered that there is a
specific ACL for user A barring him from displaying content X,
+ * we want to make sure that user A's template
skeleton is invalidated so that
+ * it will a new version of its aclGroup fragment
which doesn't contain content X. Otherwise
+ * the old aclGroup fragment, containing content X,
will be displayed to user A since his template skeleton
+ * still points to the aclGroup fragment with
aclGroup parameter key determined only by his group membership.
+ *
+ */
+
ServicesRegistry.getInstance().getEsiService().aclGroupTemplateRequiresInvalidation();
+ }
+ else
+ logger.info("AclUserName ["+username+"] already in
"+getObjDetails());
+ }
+
+ } catch (JahiaACLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ /**
+ * check to see if the current user has special (i.e. non-group but
user-specific) permissions over content contained
+ * within this JesiObject
+ */
+ public boolean containsAclUserName(String username) {
+ if (aclUserNames.contains(username)) {
+ logger.info("The requesting user ["+username+"] has specific
permissions over content contained in this "+getObjDetails());
+ return true;
+ }
+ else
+ return false;
+ }
+
/**
* returns JesiObject Type descriptor e.g. fragment or template
*