You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/07/29 19:23:18 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/ac2 DefaultAccessController.java PolicyAuthorizer.java AccessController.java
andreas 2003/07/29 10:23:18
Modified: src/java/org/apache/lenya/cms/cocoon/acting
DelegatingAuthorizerAction.java
src/java/org/apache/lenya/cms/ac2
DefaultAccessController.java PolicyAuthorizer.java
AccessController.java
Log:
moved machine setup to access controller
Revision Changes Path
1.12 +2 -35 cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/DelegatingAuthorizerAction.java
Index: DelegatingAuthorizerAction.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/DelegatingAuthorizerAction.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DelegatingAuthorizerAction.java 29 Jul 2003 14:27:41 -0000 1.11
+++ DelegatingAuthorizerAction.java 29 Jul 2003 17:23:18 -0000 1.12
@@ -64,7 +64,6 @@
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.cms.ac.AccessControlException;
-import org.apache.lenya.cms.ac.Machine;
import org.apache.lenya.cms.ac2.Identity;
import org.apache.lenya.util.Stack;
@@ -120,7 +119,7 @@
Request request = ObjectModelHelper.getRequest(objectModel);
- initializeIdentity(request);
+ getAccessController().setupIdentity(request);
setHistory(request);
boolean authorized = authorize(request);
@@ -161,36 +160,4 @@
}
- /**
- * Checks if the session contains an identity that is not null and belongs
- * to the used access controller.
- * @param session The current session.
- * @return A boolean value.
- * @throws AccessControlException when something went wrong.
- */
- protected boolean hasValidIdentity(Session session) throws AccessControlException {
- boolean valid = true;
- Identity identity = (Identity) session.getAttribute(Identity.class.getName());
- if (identity == null || !getAccessController().ownsIdenity(identity)) {
- valid = false;
- }
- return valid;
- }
-
- /**
- * Initializes the identity, adding the current machine.
- * @param request The request.
- * @throws AccessControlException when something went wrong.
- */
- protected void initializeIdentity(Request request) throws AccessControlException {
- Session session = request.getSession(true);
- if (!hasValidIdentity(session)) {
- Identity identity = new Identity();
- String remoteAddress = request.getRemoteAddr();
- Machine machine = new Machine(remoteAddress);
- identity.addIdentifiable(machine);
- session.setAttribute(Identity.class.getName(), identity);
- }
- }
-
}
1.8 +42 -1 cocoon-lenya/src/java/org/apache/lenya/cms/ac2/DefaultAccessController.java
Index: DefaultAccessController.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/ac2/DefaultAccessController.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultAccessController.java 24 Jul 2003 18:36:37 -0000 1.7
+++ DefaultAccessController.java 29 Jul 2003 17:23:18 -0000 1.8
@@ -56,6 +56,7 @@
package org.apache.lenya.cms.ac2;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.apache.avalon.framework.activity.Disposable;
@@ -71,6 +72,8 @@
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
import org.apache.lenya.cms.ac.AccessControlException;
+import org.apache.lenya.cms.ac.IPRange;
+import org.apache.lenya.cms.ac.Machine;
/**
* @author andreas
@@ -346,4 +349,42 @@
return identity.belongsTo(getAccreditableManager());
}
+ /**
+ * @see org.apache.lenya.cms.ac2.AccessController#setupIdentity(org.apache.cocoon.environment.Request)
+ */
+ public void setupIdentity(Request request) throws AccessControlException {
+ Session session = request.getSession(true);
+ if (!hasValidIdentity(session)) {
+ Identity identity = new Identity();
+ String remoteAddress = request.getRemoteAddr();
+
+ Machine machine = new Machine(remoteAddress);
+ for (Iterator i = accreditableManager.getIPRangeManager().getIPRanges(); i.hasNext(); ) {
+ IPRange range = (IPRange) i.next();
+ if (range.contains(machine)) {
+ machine.addIPRange(range);
+ }
+ }
+
+ identity.addIdentifiable(machine);
+ session.setAttribute(Identity.class.getName(), identity);
+ }
+ }
+
+ /**
+ * Checks if the session contains an identity that is not null and belongs
+ * to the used access controller.
+ * @param session The current session.
+ * @return A boolean value.
+ * @throws AccessControlException when something went wrong.
+ */
+ protected boolean hasValidIdentity(Session session) throws AccessControlException {
+ boolean valid = true;
+ Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+ if (identity == null || !ownsIdenity(identity)) {
+ valid = false;
+ }
+ return valid;
+ }
+
}
1.12 +1 -9 cocoon-lenya/src/java/org/apache/lenya/cms/ac2/PolicyAuthorizer.java
Index: PolicyAuthorizer.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/ac2/PolicyAuthorizer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- PolicyAuthorizer.java 29 Jul 2003 14:26:13 -0000 1.11
+++ PolicyAuthorizer.java 29 Jul 2003 17:23:18 -0000 1.12
@@ -133,14 +133,6 @@
String url = requestUri.substring(context.length());
- Machine machine = identity.getMachine();
- for (Iterator i = accreditableManager.getIPRangeManager().getIPRanges(); i.hasNext(); ) {
- IPRange range = (IPRange) i.next();
- if (range.contains(machine)) {
- machine.addIPRange(range);
- }
- }
-
Policy policy = policyManager.getPolicy(accreditableManager, url);
Role[] roles = policy.getRoles(identity);
1.10 +9 -2 cocoon-lenya/src/java/org/apache/lenya/cms/ac2/AccessController.java
Index: AccessController.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/ac2/AccessController.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AccessController.java 17 Jul 2003 16:24:19 -0000 1.9
+++ AccessController.java 29 Jul 2003 17:23:18 -0000 1.10
@@ -93,6 +93,13 @@
* @return A boolean value.
* @throws AccessControlException when something went wrong.
*/
- boolean ownsIdenity(Identity identity) throws AccessControlException;
+ //boolean ownsIdenity(Identity identity) throws AccessControlException;
+
+ /**
+ * Initializes the identity for this access controller.
+ * @param request The request that contains the identity information.
+ * @throws AccessControlException when something went wrong.
+ */
+ void setupIdentity(Request request) throws AccessControlException;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org