pnever 2003/11/21 03:39:07
Modified: src/share/org/apache/slide/security ACLSecurityImpl.java
Log:
Fixed start-up problems.
Revision Changes Path
1.3 +44 -41
jakarta-slide/src/share/org/apache/slide/security/ACLSecurityImpl.java
Index: ACLSecurityImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/security/ACLSecurityImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ACLSecurityImpl.java 14 Nov 2003 16:17:01 -0000 1.2
+++ ACLSecurityImpl.java 21 Nov 2003 11:39:07 -0000 1.3
@@ -79,12 +79,13 @@
import org.apache.slide.content.NodeRevisionNumber;
import org.apache.slide.content.RevisionDescriptorNotFoundException;
import org.apache.slide.security.SecurityImpl;
+import org.apache.slide.store.Store;
import org.apache.slide.structure.ActionNode;
import org.apache.slide.structure.ObjectNode;
import org.apache.slide.structure.ObjectNotFoundException;
import org.apache.slide.structure.SubjectNode;
-import org.apache.slide.util.logger.Logger;
import org.apache.slide.util.XMLValue;
+import org.apache.slide.util.logger.Logger;
import org.jdom.JDOMException;
/**
@@ -118,11 +119,33 @@
public void init(Namespace namespace, NamespaceConfig namespaceConfig) {
super.init(namespace, namespaceConfig);
logger = namespace.getLogger();
-
+ loadActionsCache(namespace, namespaceConfig);
+ }
+
+ private void loadActionsCache(Namespace namespace, NamespaceConfig
namespaceConfig) {
try {
- loadActionsCache(namespace, namespaceConfig);
-
- // logging
+ actionsCache = new HashMap();
+ String actionsPath = namespaceConfig.getActionsPath();
+ Uri actionsPathUri = namespace.getUri(actionsPath);
+ ObjectNode actionsPathNode =
actionsPathUri.getStore().retrieveObject(actionsPathUri);
+ Enumeration actions = actionsPathNode.enumerateChildren();
+ while (actions.hasMoreElements()) {
+ ActionNode aNode = new ActionNode((String)actions.nextElement());
+ Set aClosure = new HashSet();
+ aClosure.add(aNode);
+ aClosure.addAll(getActionMembers(aNode));
+ actionsCache.put(aNode, aClosure);
+ }
+ Iterator keys = actionsCache.keySet().iterator();
+ while (keys.hasNext()) {
+ ActionNode aNode = (ActionNode)keys.next();
+ Set aClosure = (Set)actionsCache.get(aNode);
+ actionsCache.put(aNode, buildClosure(aClosure));
+ }
+ // log success
+ if (logger.isEnabled(LOG_CHANNEL, Logger.INFO)) {
+ logger.log("Actions cache loaded successfully", LOG_CHANNEL,
Logger.INFO);
+ }
if (logger.isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
logger.log("\n@@@ Actions Cache", LOG_CHANNEL, Logger.DEBUG);
Iterator i = actionsCache.entrySet().iterator();
@@ -131,35 +154,8 @@
}
}
}
- catch (ObjectNotFoundException e) {
- // server start-up phase - ignore silently
- }
- catch (SlideException e) {
- e.printStackTrace();
- }
- catch (JDOMException e) {
- e.printStackTrace();
- }
- }
-
- private void loadActionsCache(Namespace namespace, NamespaceConfig
namespaceConfig) throws SlideException, JDOMException {
- actionsCache = new HashMap();
- String actionsPath = namespaceConfig.getActionsPath();
- Uri actionsPathUri = namespace.getUri(actionsPath);
- ObjectNode actionsPathNode =
actionsPathUri.getStore().retrieveObject(actionsPathUri);
- Enumeration actions = actionsPathNode.enumerateChildren();
- while (actions.hasMoreElements()) {
- ActionNode aNode = new ActionNode((String)actions.nextElement());
- Set aClosure = new HashSet();
- aClosure.add(aNode);
- aClosure.addAll(getActionMembers(aNode));
- actionsCache.put(aNode, aClosure);
- }
- Iterator keys = actionsCache.keySet().iterator();
- while (keys.hasNext()) {
- ActionNode aNode = (ActionNode)keys.next();
- Set aClosure = (Set)actionsCache.get(aNode);
- actionsCache.put(aNode, buildClosure(aClosure));
+ catch (Throwable e) {
+ actionsCache = null;
}
}
@@ -261,7 +257,7 @@
private boolean match(SlideToken token, ObjectNode objectNode, SubjectNode
subjectNode, ActionNode actionNode, NodePermission permission) throws
ServiceAccessException {
boolean result = true;
- result = matchAction(actionNode, permission.getActionNode()) &&
matchSubject(token, objectNode, subjectNode, permission.getSubjectNode());
+ result = matchAction(token, actionNode, permission.getActionNode()) &&
matchSubject(token, objectNode, subjectNode, permission.getSubjectNode());
// logging
if (logger.isEnabled(LOG_CHANNEL, Logger.DEBUG)) {
logger.log(" permission="+permission+", match="+result, LOG_CHANNEL,
Logger.DEBUG);
@@ -269,12 +265,19 @@
return result;
}
- private boolean matchAction(ActionNode checkAction, ActionNode permAction) {
+ private boolean matchAction(SlideToken token, ActionNode checkAction,
ActionNode permAction) throws ServiceAccessException {
if (permAction == ActionNode.ALL) {
return true;
}
else {
- return ((Set)actionsCache.get(permAction)).contains(checkAction);
+ if (actionsCache != null) {
+ return ((Set)actionsCache.get(permAction)).contains(checkAction);
+ }
+ else {
+ Uri u = namespace.getUri(token, checkAction.getUri());
+ Store s = u.getStore();
+ throw new ServiceAccessException(s, "Actions cache not loaded");
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]