juergen 2002/10/01 23:30:00
Modified: src/share/org/apache/slide/common SlideTokenWrapper.java
SlideTokenImpl.java SlideToken.java
Log:
improved performance by caching allready checked permissions for the current method
call in the SlideToken. (eckehard)
Revision Changes Path
1.4 +22 -3
jakarta-slide/src/share/org/apache/slide/common/SlideTokenWrapper.java
Index: SlideTokenWrapper.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/SlideTokenWrapper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SlideTokenWrapper.java 25 Apr 2002 21:15:10 -0000 1.3
+++ SlideTokenWrapper.java 2 Oct 2002 06:30:00 -0000 1.4
@@ -67,6 +67,8 @@
import java.util.Hashtable;
import java.util.Enumeration;
import org.apache.slide.authenticate.CredentialsToken;
+import org.apache.slide.structure.ObjectNode;
+import org.apache.slide.structure.ActionNode;
/**
* Slide token class.
@@ -264,5 +266,22 @@
return wrappedToken.getParameterNames();
}
+ /**
+ * allows to cache the result of a permission check
+ *
+ * @return true if successful added to cache, false else
+ */
+ public void cachePermission(ObjectNode object, ActionNode action, boolean
permission){
+ wrappedToken.cachePermission(object, action, permission);
+ }
+ /**
+ * checks if the permission cache contains an entry for the ObjectNode and
+ * ActionNode combination.
+ *
+ * @return true if granted, false if denied, null if nothing in the cache.
+ */
+ public Boolean checkPermissionCache(ObjectNode object, ActionNode action){
+ return wrappedToken.checkPermissionCache(object, action);
+ }
}
1.4 +29 -3
jakarta-slide/src/share/org/apache/slide/common/SlideTokenImpl.java
Index: SlideTokenImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/SlideTokenImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SlideTokenImpl.java 25 Apr 2002 21:15:10 -0000 1.3
+++ SlideTokenImpl.java 2 Oct 2002 06:30:00 -0000 1.4
@@ -67,6 +67,8 @@
import java.util.Hashtable;
import java.util.Enumeration;
import org.apache.slide.authenticate.CredentialsToken;
+import org.apache.slide.structure.ObjectNode;
+import org.apache.slide.structure.ActionNode;
/**
* Slide token class.
@@ -151,6 +153,10 @@
*/
private Hashtable parameters = new Hashtable();
+ /**
+ * permission cache
+ */
+ private Hashtable permissionCache = new Hashtable();
// ------------------------------------------------------------- Properties
@@ -313,5 +319,25 @@
return parameters.keys();
}
+ /**
+ * allows to cache the result of a permission check
+ *
+ * @return true if successful added to cache, false else
+ */
+ public void cachePermission(ObjectNode object, ActionNode action, boolean
permission){
+ String key = new String (object.getUri()+ action.getUri());
+ Boolean perm = new Boolean(permission);
+ permissionCache.put(key,perm);
+ }
+ /**
+ * checks if the permission cache contains an entry for the ObjectNode and
+ * ActionNode combination.
+ *
+ * @return true if granted, false if denied, null if nothing in the cache.
+ */
+ public Boolean checkPermissionCache(ObjectNode object, ActionNode action){
+ String key = new String (object.getUri()+ action.getUri());
+ return (Boolean) permissionCache.get(key);
+ }
}
1.10 +17 -4 jakarta-slide/src/share/org/apache/slide/common/SlideToken.java
Index: SlideToken.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/SlideToken.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SlideToken.java 25 Apr 2002 21:15:10 -0000 1.9
+++ SlideToken.java 2 Oct 2002 06:30:00 -0000 1.10
@@ -67,6 +67,8 @@
import java.util.Hashtable;
import java.util.Enumeration;
import org.apache.slide.authenticate.CredentialsToken;
+import org.apache.slide.structure.ObjectNode;
+import org.apache.slide.structure.ActionNode;
/**
* The SlideToken interface identifies the current acting principal and its
@@ -227,6 +229,17 @@
*/
public Enumeration getParameterNames() ;
+ /**
+ * allows to cache the result of a permission check
+ */
+ public void cachePermission(ObjectNode object, ActionNode action, boolean
permission);
+ /**
+ * checks if the permission cache contains an entry for the ObjectNode and
+ * ActionNode combination.
+ *
+ * @return true if granted, false if denied, null if nothing in the cache.
+ */
+ public Boolean checkPermissionCache(ObjectNode object, ActionNode action);
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>