Author: andreas
Date: Wed May 17 09:21:49 2006
New Revision: 407305
URL: http://svn.apache.org/viewvc?rev=407305&view=rev
Log:
Moved AC usecases back from impl to API, improved AC API for a better
separation between API and impl
Added:
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/CredentialImpl.java
- copied, changed from r407248,
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/Credential.java
lenya/trunk/src/java/org/apache/lenya/ac/Credential.java
lenya/trunk/src/java/org/apache/lenya/ac/InheritingPolicyManager.java
- copied, changed from r407248,
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/InheritingPolicyManager.java
lenya/trunk/src/java/org/apache/lenya/ac/ItemUtil.java
lenya/trunk/src/java/org/apache/lenya/ac/ModifiablePolicy.java
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/
- copied from r407248,
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/usecases/
Removed:
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/Credential.java
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/InheritingPolicyManager.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/usecases/
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddUser.java
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileGroupManager.java
lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileIPRangeManager.java
lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FilePolicyManager.java
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/AbstractItem.java
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/DefaultPolicy.java
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/PolicyBuilder.java
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/URLPolicy.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/usecase/UsecaseAuthorizerImpl.java
lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/PolicyTest.java
lenya/trunk/src/java/org/apache/lenya/ac/Accreditable.java
lenya/trunk/src/java/org/apache/lenya/ac/GroupManager.java
lenya/trunk/src/java/org/apache/lenya/ac/IPRangeManager.java
lenya/trunk/src/java/org/apache/lenya/ac/Policy.java
lenya/trunk/src/java/org/apache/lenya/ac/UserManager.java
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControlUsecase.java
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddGroup.java
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddIPRange.java
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/GroupProfile.java
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/IPRange.java
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/User.java
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileGroupManager.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileGroupManager.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileGroupManager.java
(original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileGroupManager.java
Wed May 17 09:21:49 2006
@@ -81,13 +81,12 @@
}
/**
- * Add a group to this manager
- *
- * @param group the group to be added
- * @throws AccessControlException when the notification failed.
+ * @see org.apache.lenya.ac.GroupManager#add(java.lang.String)
*/
- public void add(Group group) throws AccessControlException {
+ public Group add(String id) throws AccessControlException {
+ Group group = new FileGroup(getConfigurationDirectory(), id);
super.add(group);
+ return group;
}
/**
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileIPRangeManager.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileIPRangeManager.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileIPRangeManager.java
(original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FileIPRangeManager.java
Wed May 17 09:21:49 2006
@@ -91,13 +91,10 @@
return ranges;
}
- /**
- * Add the given IP range
- * @param range IP range that is to be added
- * @throws AccessControlException when the notification failed.
- */
- public void add(IPRange range) throws AccessControlException {
+ public IPRange add(String id) throws AccessControlException {
+ IPRange range = new FileIPRange(getConfigurationDirectory(), id);
super.add(range);
+ return range;
}
/**
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FilePolicyManager.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FilePolicyManager.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FilePolicyManager.java
(original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/ac/file/FilePolicyManager.java
Wed May 17 09:21:49 2006
@@ -42,14 +42,15 @@
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Accreditable;
import org.apache.lenya.ac.AccreditableManager;
+import org.apache.lenya.ac.ModifiablePolicy;
import org.apache.lenya.ac.Policy;
import org.apache.lenya.ac.Role;
import org.apache.lenya.ac.User;
import org.apache.lenya.ac.cache.CachingException;
import org.apache.lenya.ac.cache.SourceCache;
-import org.apache.lenya.ac.impl.Credential;
+import org.apache.lenya.ac.Credential;
import org.apache.lenya.ac.impl.DefaultPolicy;
-import org.apache.lenya.ac.impl.InheritingPolicyManager;
+import org.apache.lenya.ac.InheritingPolicyManager;
import org.apache.lenya.ac.impl.PolicyBuilder;
import org.apache.lenya.ac.impl.RemovedAccreditablePolicyBuilder;
import org.apache.lenya.ac.impl.URLPolicy;
@@ -76,8 +77,7 @@
* @see java.io.FileFilter#accept(java.io.File)
*/
public boolean accept(File file) {
- return file.getName().equals(this.subtree)
- || file.getName().equals(this.url);
+ return file.getName().equals(this.subtree) ||
file.getName().equals(this.url);
}
}
@@ -94,7 +94,7 @@
* Creates a new FilePolicyManager.
*/
public FilePolicyManager() {
- // do nothing
+ // do nothing
}
/**
@@ -119,7 +119,7 @@
* @return A policy.
* @throws AccessControlException when something went wrong.
*/
- public DefaultPolicy buildURLPolicy(AccreditableManager controller, String
url)
+ public Policy buildURLPolicy(AccreditableManager controller, String url)
throws AccessControlException {
return buildPolicy(controller, url, URL_FILENAME);
}
@@ -132,7 +132,7 @@
* @return A policy.
* @throws AccessControlException when something went wrong.
*/
- public DefaultPolicy buildSubtreePolicy(AccreditableManager controller,
String url)
+ public Policy buildSubtreePolicy(AccreditableManager controller, String
url)
throws AccessControlException {
return buildPolicy(controller, url, SUBTREE_FILENAME);
}
@@ -221,7 +221,7 @@
* @param policy The policy to save.
* @throws AccessControlException when something went wrong.
*/
- public void saveURLPolicy(String url, DefaultPolicy policy) throws
AccessControlException {
+ public void saveURLPolicy(String url, Policy policy) throws
AccessControlException {
getLogger().debug("Saving URL policy for URL [" + url + "]");
savePolicy(url, policy, URL_FILENAME);
}
@@ -232,7 +232,7 @@
* @param policy The policy to save.
* @throws AccessControlException when something went wrong.
*/
- public void saveSubtreePolicy(String url, DefaultPolicy policy) throws
AccessControlException {
+ public void saveSubtreePolicy(String url, Policy policy) throws
AccessControlException {
getLogger().debug("Saving subtree policy for URL [" + url + "]");
savePolicy(url, policy, SUBTREE_FILENAME);
}
@@ -244,7 +244,7 @@
* @param filename The file.
* @throws AccessControlException if something goes wrong.
*/
- protected void savePolicy(String url, DefaultPolicy policy, String
filename)
+ protected void savePolicy(String url, Policy policy, String filename)
throws AccessControlException {
File file = getPolicyFile(url, filename);
@@ -257,7 +257,7 @@
* @param file The file.
* @throws AccessControlException when an error occurs.
*/
- protected void savePolicy(DefaultPolicy policy, File file) throws
AccessControlException {
+ protected void savePolicy(Policy policy, File file) throws
AccessControlException {
Document document = PolicyBuilder.savePolicy(policy);
try {
@@ -330,8 +330,8 @@
}
}
- getLogger().debug(
- "Policies directory resolved to [" +
directory.getAbsolutePath() + "]");
+ getLogger().debug("Policies directory resolved to [" +
directory.getAbsolutePath()
+ + "]");
setPoliciesDirectory(directory);
}
@@ -361,10 +361,10 @@
}
/**
- * @see
org.apache.lenya.ac.impl.InheritingPolicyManager#getPolicies(org.apache.lenya.ac.AccreditableManager,
+ * @see
org.apache.lenya.ac.InheritingPolicyManager#getPolicies(org.apache.lenya.ac.AccreditableManager,
* java.lang.String)
*/
- public DefaultPolicy[] getPolicies(AccreditableManager controller, String
url)
+ public Policy[] getPolicies(AccreditableManager controller, String url)
throws AccessControlException {
List policies = new ArrayList();
@@ -372,18 +372,18 @@
Policy policy = buildURLPolicy(controller, url);
policies.add(policy);
- //The live area should be restrictive and will use the policy
belonging to self-or-ancestor
+ // The live area should be restrictive and will use the policy
belonging to self-or-ancestor
if (url.startsWith("/live")) {
while (url.indexOf("/") >= 0) {
- policy = buildSubtreePolicy(controller, url+"/");
+ policy = buildSubtreePolicy(controller, url + "/");
policies.add(policy);
- if(!policy.isEmpty()) {
- url="";
+ if (!policy.isEmpty()) {
+ url = "";
} else {
- url=url.replaceFirst("/[\\w\\-\\.\\_\\~]*$","");
+ url = url.replaceFirst("/[\\w\\-\\.\\_\\~]*$", "");
}
}
- } else {
+ } else {
String[] directories = url.split("/");
url = "";
@@ -420,7 +420,8 @@
protected void removeAccreditable(AccreditableManager manager,
Accreditable accreditable,
File policyDirectory) throws AccessControlException {
- File[] policyFiles = policyDirectory.listFiles(new
SubtreeFileFilter(URL_FILENAME, SUBTREE_FILENAME));
+ File[] policyFiles = policyDirectory.listFiles(new
SubtreeFileFilter(URL_FILENAME,
+ SUBTREE_FILENAME));
try {
RemovedAccreditablePolicyBuilder builder = new
RemovedAccreditablePolicyBuilder(manager);
@@ -430,12 +431,12 @@
if (getLogger().isDebugEnabled()) {
getLogger().debug("Removing roles");
getLogger().debug(" Accreditable: [" + accreditable +
"]");
- getLogger().debug(
- " File: [" +
policyFiles[i].getAbsolutePath() + "]");
+ getLogger().debug(" File: [" +
policyFiles[i].getAbsolutePath()
+ + "]");
}
InputStream stream = new FileInputStream(policyFiles[i]);
- DefaultPolicy policy = builder.buildPolicy(stream);
+ ModifiablePolicy policy = builder.buildPolicy(stream);
policy.removeRoles(accreditable);
savePolicy(policy, policyFiles[i]);
}
@@ -470,7 +471,7 @@
Role role = URLPolicy.getAuthorRole(manager);
if (role != null) {
String url = USER_ADMIN_URL + ((User) accreditable).getId() +
".html";
- DefaultPolicy policy = buildSubtreePolicy(manager, url);
+ DefaultPolicy policy = (DefaultPolicy)
buildSubtreePolicy(manager, url);
Credential credential = policy.getCredential(accreditable);
if (credential != null && credential.contains(role)) {
policy.removeRole(accreditable, role);
@@ -500,7 +501,7 @@
Role role = URLPolicy.getAuthorRole(manager);
if (role != null) {
String url = USER_ADMIN_URL + ((User) accreditable).getId() +
".html";
- DefaultPolicy policy = buildSubtreePolicy(manager, url);
+ ModifiablePolicy policy = (ModifiablePolicy)
buildSubtreePolicy(manager, url);
policy.addRole(accreditable, role);
saveSubtreePolicy(url, policy);
}
Modified: lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/AbstractItem.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/AbstractItem.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/AbstractItem.java
(original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/AbstractItem.java Wed
May 17 09:21:49 2006
@@ -19,6 +19,7 @@
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.lenya.ac.Item;
+import org.apache.lenya.ac.ItemUtil;
/**
* Abstract superclass for all access control objects that can be managed by an
@@ -43,7 +44,7 @@
* @param string The ID.
*/
protected void setId(String string) {
- assert isValidId(string);
+ assert ItemUtil.isValidId(string);
this.id = string;
}
@@ -95,15 +96,6 @@
public void setName(String _name) {
assert _name != null;
this.name = _name;
- }
-
- /**
- * Checks if a string is a valid ID.
- * @param id The string to test.
- * @return A boolean value.
- */
- public static boolean isValidId(String id) {
- return id != null && id.matches("\\w+");
}
/**
Copied: lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/CredentialImpl.java
(from r407248,
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/Credential.java)
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/CredentialImpl.java?p2=lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/CredentialImpl.java&p1=lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/Credential.java&r1=407248&r2=407305&rev=407305&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/Credential.java
(original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/CredentialImpl.java Wed
May 17 09:21:49 2006
@@ -19,18 +19,17 @@
package org.apache.lenya.ac.impl;
-
import java.util.HashSet;
import java.util.Set;
import org.apache.lenya.ac.Accreditable;
+import org.apache.lenya.ac.Credential;
import org.apache.lenya.ac.Role;
-
/**
- * A credential assigns a set of {@link Role}s to an {@link Accreditable}.
+ * Credential implementation.
*/
-public class Credential {
+public class CredentialImpl implements Credential {
private Accreditable accreditable;
private Set roles = new HashSet();
@@ -38,7 +37,7 @@
* Creates a new credential object.
* @param _accreditable The accreditable.
*/
- public Credential(Accreditable _accreditable) {
+ public CredentialImpl(Accreditable _accreditable) {
setAccreditable(_accreditable);
}
@@ -93,7 +92,7 @@
public String toString() {
return "[credential of: " + getAccreditable() + "]";
}
-
+
/**
* Returns if a role is contained.
* @param role A role.
@@ -102,12 +101,12 @@
public boolean contains(Role role) {
return this.roles.contains(role);
}
-
+
/**
* Returns if the credential is empty (contains no roles).
* @return A boolean value.
*/
public boolean isEmpty() {
- return this.roles.isEmpty();
+ return this.roles.isEmpty();
}
}
Modified: lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/DefaultPolicy.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/DefaultPolicy.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/DefaultPolicy.java
(original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/DefaultPolicy.java Wed
May 17 09:21:49 2006
@@ -28,14 +28,15 @@
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Accreditable;
+import org.apache.lenya.ac.Credential;
import org.apache.lenya.ac.Identity;
-import org.apache.lenya.ac.Policy;
+import org.apache.lenya.ac.ModifiablePolicy;
import org.apache.lenya.ac.Role;
/**
* A DefaultPolicy is the own policy of a certain URL (not merged).
*/
-public class DefaultPolicy implements Policy {
+public class DefaultPolicy implements ModifiablePolicy {
private Map accreditableToCredential = new HashMap();
@@ -60,9 +61,9 @@
assert accreditable != null;
assert role != null;
- Credential credential = getCredential(accreditable);
+ CredentialImpl credential = (CredentialImpl)
getCredential(accreditable);
if (credential == null) {
- credential = new Credential(accreditable);
+ credential = new CredentialImpl(accreditable);
addCredential(credential);
}
if (!credential.contains(role)) {
@@ -79,7 +80,7 @@
public void removeRole(Accreditable accreditable, Role role) throws
AccessControlException {
assert accreditable != null;
assert role != null;
- Credential credential = getCredential(accreditable);
+ CredentialImpl credential = (CredentialImpl)
getCredential(accreditable);
if (credential == null) {
throw new AccessControlException("No credential for accreditable
[" + accreditable
+ "] [" + this.accreditableToCredential.keySet().size() +
"]");
Modified: lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/PolicyBuilder.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/PolicyBuilder.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/PolicyBuilder.java
(original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/PolicyBuilder.java Wed
May 17 09:21:49 2006
@@ -25,6 +25,9 @@
import org.apache.lenya.ac.AccessController;
import org.apache.lenya.ac.Accreditable;
import org.apache.lenya.ac.AccreditableManager;
+import org.apache.lenya.ac.Credential;
+import org.apache.lenya.ac.ModifiablePolicy;
+import org.apache.lenya.ac.Policy;
import org.apache.lenya.ac.Role;
import org.apache.lenya.ac.User;
import org.apache.lenya.ac.World;
@@ -75,7 +78,7 @@
* @return A policy.
* @throws AccessControlException when something went wrong.
*/
- public DefaultPolicy buildPolicy(InputStream stream)
+ public ModifiablePolicy buildPolicy(InputStream stream)
throws AccessControlException {
Document document;
@@ -95,7 +98,7 @@
* @return A policy.
* @throws AccessControlException when something went wrong.
*/
- public DefaultPolicy buildPolicy(Document document)
+ public ModifiablePolicy buildPolicy(Document document)
throws AccessControlException {
DefaultPolicy policy = new DefaultPolicy();
@@ -116,7 +119,7 @@
String id = credentialElements[i].getAttribute(ID_ATTRIBUTE);
accreditable =
getAccreditable(credentialElements[i].getLocalName(), id);
- Credential credential = new Credential(accreditable);
+ CredentialImpl credential = new CredentialImpl(accreditable);
Element[] roleElements = helper.getChildren(credentialElements[i],
ROLE_ELEMENT);
@@ -176,7 +179,7 @@
* @return A DOM document.
* @throws AccessControlException when something went wrong.
*/
- public static Document savePolicy(DefaultPolicy policy) throws
AccessControlException {
+ public static Document savePolicy(Policy policy) throws
AccessControlException {
NamespaceHelper helper;
try {
@@ -189,7 +192,7 @@
throw new AccessControlException(e);
}
- Credential[] credentials = policy.getCredentials();
+ Credential[] credentials = ((DefaultPolicy) policy).getCredentials();
Element policyElement = helper.getDocument().getDocumentElement();
for (int i = 0; i < credentials.length; i++) {
Modified: lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/URLPolicy.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/URLPolicy.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/URLPolicy.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/URLPolicy.java Wed May
17 09:21:49 2006
@@ -26,12 +26,13 @@
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.AccreditableManager;
import org.apache.lenya.ac.Identity;
+import org.apache.lenya.ac.InheritingPolicyManager;
import org.apache.lenya.ac.Policy;
import org.apache.lenya.ac.Role;
/**
- * A policy at a certain URL. The final policy is computed by merging the
subtree
- * policies of all ancestor-or-self directories with the URL policy of the
actual URL.
+ * A policy at a certain URL. The final policy is computed by merging the
subtree policies of all
+ * ancestor-or-self directories with the URL policy of the actual URL.
*/
public class URLPolicy implements Policy {
@@ -58,8 +59,8 @@
private Policy[] policies = null;
/**
- * Obtains the policies from the policy manager.
- * This method is expensive and therefore only called when needed.
+ * Obtains the policies from the policy manager. This method is expensive
and therefore only
+ * called when needed.
* @throws AccessControlException when something went wrong.
*/
protected void obtainPolicies() throws AccessControlException {
@@ -116,7 +117,8 @@
* @return A role.
* @throws AccessControlException when something went wrong.
*/
- public static Role getAdministratorRole(AccreditableManager manager)
throws AccessControlException {
+ public static Role getAdministratorRole(AccreditableManager manager)
+ throws AccessControlException {
Role administratorRole = null;
for (int i = 0; i < ADMINISTRATOR_ROLES.length; i++) {
Role role =
manager.getRoleManager().getRole(ADMINISTRATOR_ROLES[i]);
@@ -152,7 +154,7 @@
* @throws AccessControlException when something went wrong.
*/
protected void addRoles(Policy policy, Identity identity, Set roles)
- throws AccessControlException {
+ throws AccessControlException {
roles.addAll(Arrays.asList(policy.getRoles(identity)));
}
@@ -181,8 +183,7 @@
}
/**
- * The URL policy requires SSL protection if one of its
- * member policies requires SSL protection.
+ * The URL policy requires SSL protection if one of its member policies
requires SSL protection.
* @see org.apache.lenya.ac.Policy#isSSLProtected()
*/
public boolean isSSLProtected() throws AccessControlException {
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
---
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java
(original)
+++
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/DocumentPolicyManagerWrapper.java
Wed May 17 09:21:49 2006
@@ -32,11 +32,10 @@
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Accreditable;
import org.apache.lenya.ac.AccreditableManager;
+import org.apache.lenya.ac.InheritingPolicyManager;
import org.apache.lenya.ac.Policy;
import org.apache.lenya.ac.PolicyManager;
import org.apache.lenya.ac.impl.DefaultAccessController;
-import org.apache.lenya.ac.impl.DefaultPolicy;
-import org.apache.lenya.ac.impl.InheritingPolicyManager;
import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
@@ -73,13 +72,12 @@
if (getLogger().isDebugEnabled()) {
getLogger().debug("Resolving policy for webapp URL [" + webappUrl
+ "]");
}
-
-
+
Publication publication = getPublication(webappUrl);
String url = null;
ContextUtility contextUtility = null;
try {
- contextUtility =
(ContextUtility)serviceManager.lookup(ContextUtility.ROLE);
+ contextUtility = (ContextUtility)
serviceManager.lookup(ContextUtility.ROLE);
Session session =
RepositoryUtil.getSession(contextUtility.getRequest(), getLogger());
DocumentIdentityMap map = new DocumentIdentityMap(session,
getServiceManager(),
@@ -164,47 +162,27 @@
this.policyManager = _policyManager;
}
- /**
- * @see
org.apache.lenya.ac.impl.InheritingPolicyManager#buildURLPolicy(org.apache.lenya.ac.AccreditableManager,
- * java.lang.String)
- */
- public DefaultPolicy buildURLPolicy(AccreditableManager controller, String
url)
+ public Policy buildURLPolicy(AccreditableManager controller, String url)
throws AccessControlException {
return getPolicyManager().buildURLPolicy(controller,
getPolicyURL(url));
}
- /**
- * @see
org.apache.lenya.ac.impl.InheritingPolicyManager#buildSubtreePolicy(org.apache.lenya.ac.AccreditableManager,
- * java.lang.String)
- */
- public DefaultPolicy buildSubtreePolicy(AccreditableManager controller,
String url)
+ public Policy buildSubtreePolicy(AccreditableManager controller, String
url)
throws AccessControlException {
return getPolicyManager().buildSubtreePolicy(controller,
getPolicyURL(url));
}
- /**
- * @see
org.apache.lenya.ac.impl.InheritingPolicyManager#getPolicies(org.apache.lenya.ac.AccreditableManager,
- * java.lang.String)
- */
- public DefaultPolicy[] getPolicies(AccreditableManager controller, String
url)
+ public Policy[] getPolicies(AccreditableManager controller, String url)
throws AccessControlException {
return getPolicyManager().getPolicies(controller, getPolicyURL(url));
}
- /**
- * @see
org.apache.lenya.ac.impl.InheritingPolicyManager#saveURLPolicy(java.lang.String,
- * org.apache.lenya.ac.impl.DefaultPolicy)
- */
- public void saveURLPolicy(String url, DefaultPolicy policy) throws
AccessControlException {
+ public void saveURLPolicy(String url, Policy policy) throws
AccessControlException {
getPolicyManager().saveURLPolicy(getPolicyURL(url), policy);
}
- /**
- * @see
org.apache.lenya.ac.impl.InheritingPolicyManager#saveSubtreePolicy(java.lang.String,
- * org.apache.lenya.ac.impl.DefaultPolicy)
- */
- public void saveSubtreePolicy(String url, DefaultPolicy policy) throws
AccessControlException {
+ public void saveSubtreePolicy(String url, Policy policy) throws
AccessControlException {
getPolicyManager().saveSubtreePolicy(getPolicyURL(url), policy);
}
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/usecase/UsecaseAuthorizerImpl.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/usecase/UsecaseAuthorizerImpl.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
---
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/usecase/UsecaseAuthorizerImpl.java
(original)
+++
lenya/trunk/src/impl/java/org/apache/lenya/cms/ac/usecase/UsecaseAuthorizerImpl.java
Wed May 17 09:21:49 2006
@@ -32,7 +32,6 @@
import org.apache.cocoon.environment.Request;
import org.apache.excalibur.source.SourceResolver;
import org.apache.lenya.ac.AccessControlException;
-import org.apache.lenya.ac.Authorizer;
import org.apache.lenya.ac.Role;
import org.apache.lenya.ac.cache.CachingException;
import org.apache.lenya.ac.cache.SourceCache;
@@ -68,6 +67,7 @@
* ...?
*
* @param publication The publication.
+ * @param requestURI The request URI.
* @return A string representing a URI.
*/
protected String getConfigurationURI(Publication publication, String
requestURI) {
Modified: lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/PolicyTest.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/PolicyTest.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/PolicyTest.java
(original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/ac/impl/PolicyTest.java Wed May
17 09:21:49 2006
@@ -24,6 +24,8 @@
import java.util.Set;
import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.Credential;
+import org.apache.lenya.ac.InheritingPolicyManager;
import org.apache.lenya.ac.Policy;
import org.apache.lenya.ac.Role;
import org.apache.lenya.cms.publication.Publication;
@@ -74,14 +76,14 @@
*/
public void testSavePolicy() throws AccessControlException {
InheritingPolicyManager policyManager = (InheritingPolicyManager)
getPolicyManager();
- DefaultPolicy urlPolicy =
policyManager.buildURLPolicy(getAccessController().getAccreditableManager(),
+ DefaultPolicy urlPolicy = (DefaultPolicy)
policyManager.buildURLPolicy(getAccessController().getAccreditableManager(),
URL);
DefaultPolicy newPolicy = new DefaultPolicy();
Credential[] credentials = urlPolicy.getCredentials();
for (int i = 0; i < credentials.length; i++) {
- Credential credential = new
Credential(credentials[i].getAccreditable());
+ CredentialImpl credential = new
CredentialImpl(credentials[i].getAccreditable());
Role[] roles = credentials[i].getRoles();
for (int j = 0; j < roles.length; j++) {
@@ -95,14 +97,14 @@
policyManager.saveURLPolicy(SAVE_URL, newPolicy);
- newPolicy =
policyManager.buildURLPolicy(getAccessController().getAccreditableManager(),
+ newPolicy = (DefaultPolicy)
policyManager.buildURLPolicy(getAccessController().getAccreditableManager(),
SAVE_URL);
assertEquals(urlPolicy.getCredentials().length,
newPolicy.getCredentials().length);
Credential[] newCredentials = newPolicy.getCredentials();
for (int i = 0; i < credentials.length; i++) {
- Credential credential = new
Credential(credentials[i].getAccreditable());
+ Credential credential = new
CredentialImpl(credentials[i].getAccreditable());
Credential newCredential = null;
Modified: lenya/trunk/src/java/org/apache/lenya/ac/Accreditable.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/ac/Accreditable.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/Accreditable.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/ac/Accreditable.java Wed May 17
09:21:49 2006
@@ -22,7 +22,7 @@
/**
* An Accreditable can be accredited with roles on a certain URI
- * using a {@link org.apache.lenya.ac.impl.Credential}.
+ * using a {@link org.apache.lenya.ac.Credential}.
*/
public interface Accreditable {
/**
Added: lenya/trunk/src/java/org/apache/lenya/ac/Credential.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/ac/Credential.java?rev=407305&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/Credential.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/ac/Credential.java Wed May 17
09:21:49 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.ac;
+
+/**
+ * A credential assigns a set of {@link Role}s to an {@link Accreditable}.
+ */
+public interface Credential {
+
+ /**
+ * @return The accreditable this credential applies to.
+ */
+ Accreditable getAccreditable();
+
+ /**
+ * @return The roles of this credential.
+ */
+ Role[] getRoles();
+
+ /**
+ * Returns if the credential contains a certain role.
+ * @param role A role.
+ * @return A boolean value.
+ */
+ boolean contains(Role role);
+
+}
Modified: lenya/trunk/src/java/org/apache/lenya/ac/GroupManager.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/ac/GroupManager.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/GroupManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/ac/GroupManager.java Wed May 17
09:21:49 2006
@@ -31,10 +31,11 @@
/**
* Add a group to this manager.
- * @param group the group to be added.
+ * @param id the ID of the group to be added.
+ * @return A group.
* @throws AccessControlException when the group is already contained.
*/
- void add(Group group) throws AccessControlException;
+ Group add(String id) throws AccessControlException;
/**
* Remove a group from this manager.
Modified: lenya/trunk/src/java/org/apache/lenya/ac/IPRangeManager.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/ac/IPRangeManager.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/IPRangeManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/ac/IPRangeManager.java Wed May 17
09:21:49 2006
@@ -34,10 +34,11 @@
/**
* Add the given IP range
*
- * @param range IP range that is to be added
+ * @param id IP range that is to be added
+ * @return An IP range.
* @throws AccessControlException when the IP range is already contained.
*/
- void add(IPRange range) throws AccessControlException;
+ IPRange add(String id) throws AccessControlException;
/**
* Remove the given IP range
Copied: lenya/trunk/src/java/org/apache/lenya/ac/InheritingPolicyManager.java
(from r407248,
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/InheritingPolicyManager.java)
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/ac/InheritingPolicyManager.java?p2=lenya/trunk/src/java/org/apache/lenya/ac/InheritingPolicyManager.java&p1=lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/InheritingPolicyManager.java&r1=407248&r2=407305&rev=407305&view=diff
==============================================================================
---
lenya/trunk/src/impl/java/org/apache/lenya/ac/impl/InheritingPolicyManager.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/ac/InheritingPolicyManager.java Wed
May 17 09:21:49 2006
@@ -15,7 +15,7 @@
*
*/
-package org.apache.lenya.ac.impl;
+package org.apache.lenya.ac;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.AccreditableManager;
@@ -28,26 +28,26 @@
public interface InheritingPolicyManager extends PolicyManager {
/**
- * Builds the URL policy for a URL from a file.
- * When the file is not present, an empty policy is returned.
+ * Builds the URL policy for a URL from a file. When the file is not
present, an empty policy is
+ * returned.
* @param controller The access controller to use.
* @param url The URL inside the web application.
* @return A policy.
* @throws AccessControlException when something went wrong.
*/
- DefaultPolicy buildURLPolicy(AccreditableManager controller, String url)
- throws AccessControlException;
+ Policy buildURLPolicy(AccreditableManager controller, String url) throws
AccessControlException;
/**
- * Builds a subtree policy from a file. When the file is not present, an
empty policy is returned.
- * @param controller The access controller to use.
- * @param url The URL inside the web application.
- * @return A policy.
- * @throws AccessControlException when something went wrong.
- */
- DefaultPolicy buildSubtreePolicy(AccreditableManager controller, String
url)
- throws AccessControlException;
-
+ * Builds a subtree policy from a file. When the file is not present, an
empty policy is
+ * returned.
+ * @param controller The access controller to use.
+ * @param url The URL inside the web application.
+ * @return A policy.
+ * @throws AccessControlException when something went wrong.
+ */
+ Policy buildSubtreePolicy(AccreditableManager controller, String url)
+ throws AccessControlException;
+
/**
* Returns the existing policies for all URL steps, beginning with the
root policy.
* @param controller The accreditable manager to use.
@@ -55,8 +55,7 @@
* @return An array of policies.
* @throws AccessControlException when something went wrong.
*/
- DefaultPolicy[] getPolicies(AccreditableManager controller, String url)
- throws AccessControlException;
+ Policy[] getPolicies(AccreditableManager controller, String url) throws
AccessControlException;
/**
* Saves a URL policy.
@@ -64,7 +63,7 @@
* @param policy The policy to save.
* @throws AccessControlException when something went wrong.
*/
- void saveURLPolicy(String url, DefaultPolicy policy) throws
AccessControlException;
+ void saveURLPolicy(String url, Policy policy) throws
AccessControlException;
/**
* Saves a Subtree policy.
@@ -72,6 +71,6 @@
* @param policy The policy to save.
* @throws AccessControlException when something went wrong.
*/
- void saveSubtreePolicy(String url, DefaultPolicy policy) throws
AccessControlException;
+ void saveSubtreePolicy(String url, Policy policy) throws
AccessControlException;
}
Added: lenya/trunk/src/java/org/apache/lenya/ac/ItemUtil.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/ac/ItemUtil.java?rev=407305&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/ItemUtil.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/ac/ItemUtil.java Wed May 17 09:21:49
2006
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.ac;
+
+/**
+ * Utility class for access control items.
+ */
+public class ItemUtil {
+
+ /**
+ * Checks if a string is a valid ID.
+ * @param id The string to test.
+ * @return A boolean value.
+ */
+ public static boolean isValidId(String id) {
+ return id != null && id.matches("\\w+");
+ }
+
+}
Added: lenya/trunk/src/java/org/apache/lenya/ac/ModifiablePolicy.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/ac/ModifiablePolicy.java?rev=407305&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/ModifiablePolicy.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/ac/ModifiablePolicy.java Wed May 17
09:21:49 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.ac;
+
+/**
+ * Modifiable policy.
+ */
+public interface ModifiablePolicy extends Policy {
+
+ /**
+ * Sets if this policy requires SSL protection.
+ * @param ssl A boolean value.
+ */
+ void setSSL(boolean ssl);
+
+ /**
+ * Adds a role to this policy for a certain accreditable and a certain
role. If a credenital
+ * exists for the accreditable, the role is added to this credential.
Otherwise, a new
+ * credential is created.
+ * @param accreditable An accreditable.
+ * @param role A role.
+ */
+ public void addRole(Accreditable accreditable, Role role);
+
+ /**
+ * Removes a role from this policy for a certain accreditable and a
certain role.
+ * @param accreditable An accreditable.
+ * @param role A role.
+ * @throws AccessControlException if the accreditable-role pair is not
contained.
+ */
+ public void removeRole(Accreditable accreditable, Role role) throws
AccessControlException;
+
+ /**
+ * Removes all roles from this policy for a certain accreditable.
+ * @param accreditable An accreditable.
+ * @throws AccessControlException if the accreditable-role pair is not
contained.
+ */
+ void removeRoles(Accreditable accreditable) throws AccessControlException;
+
+ /**
+ * @return The credentials of this policy.
+ */
+ Credential[] getCredentials();
+}
Modified: lenya/trunk/src/java/org/apache/lenya/ac/Policy.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/ac/Policy.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/Policy.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/ac/Policy.java Wed May 17 09:21:49
2006
@@ -46,4 +46,5 @@
* @throws AccessControlException when something went wrong.
*/
boolean isEmpty() throws AccessControlException;
+
}
Modified: lenya/trunk/src/java/org/apache/lenya/ac/UserManager.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/ac/UserManager.java?rev=407305&r1=407304&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/UserManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/ac/UserManager.java Wed May 17
09:21:49 2006
@@ -40,7 +40,7 @@
/**
* Add the given user
*
- * @param user User that is to be added
+ * @param user A user.
* @throws AccessControlException when the user is already contained.
*/
void add(User user) throws AccessControlException;
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java?rev=407305&r1=407248&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java
Wed May 17 09:21:49 2006
@@ -37,10 +37,9 @@
import org.apache.lenya.ac.Policy;
import org.apache.lenya.ac.Role;
import org.apache.lenya.ac.User;
-import org.apache.lenya.ac.impl.Credential;
-import org.apache.lenya.ac.impl.DefaultAccessController;
-import org.apache.lenya.ac.impl.DefaultPolicy;
-import org.apache.lenya.ac.impl.InheritingPolicyManager;
+import org.apache.lenya.ac.Credential;
+import org.apache.lenya.ac.ModifiablePolicy;
+import org.apache.lenya.ac.InheritingPolicyManager;
/**
* Usecase to display the AccessControl tab in the site area for a document.
This is a mix-in class
@@ -288,7 +287,7 @@
*/
protected void setSSLProtected(boolean ssl) throws ProcessingException {
try {
- DefaultPolicy policy =
getPolicyManager().buildSubtreePolicy(getAccreditableManager(),
+ ModifiablePolicy policy = (ModifiablePolicy)
getPolicyManager().buildSubtreePolicy(getAccreditableManager(),
getPolicyURL());
policy.setSSL(ssl);
getPolicyManager().saveSubtreePolicy(getPolicyURL(), policy);
@@ -298,12 +297,11 @@
}
protected InheritingPolicyManager getPolicyManager() {
- return (InheritingPolicyManager) ((DefaultAccessController)
getAccessController())
- .getPolicyManager();
+ return (InheritingPolicyManager)
getAccessController().getPolicyManager();
}
protected AccreditableManager getAccreditableManager() {
- return ((DefaultAccessController)
getAccessController()).getAccreditableManager();
+ return getAccessController().getAccreditableManager();
}
/**
@@ -317,7 +315,7 @@
throws ProcessingException {
try {
- DefaultPolicy policy =
getPolicyManager().buildSubtreePolicy(getAccreditableManager(),
+ ModifiablePolicy policy = (ModifiablePolicy)
getPolicyManager().buildSubtreePolicy(getAccreditableManager(),
getPolicyURL());
Accreditable accreditable = (Accreditable) item;
@@ -364,7 +362,7 @@
List credentials = new ArrayList();
- DefaultPolicy policies[] = getPolicies(urlOnly);
+ ModifiablePolicy policies[] = getPolicies(urlOnly);
List policyCredentials = new ArrayList();
for (int i = 0; i < policies.length; i++) {
Credential[] creds = policies[i].getCredentials();
@@ -390,15 +388,16 @@
* @return An array of DefaultPolicy objects.
* @throws ProcessingException when something went wrong.
*/
- protected DefaultPolicy[] getPolicies(boolean onlyUrl) throws
ProcessingException {
+ protected ModifiablePolicy[] getPolicies(boolean onlyUrl) throws
ProcessingException {
- DefaultPolicy[] policies;
+ ModifiablePolicy[] policies;
try {
if (onlyUrl) {
- policies = new DefaultPolicy[1];
+ policies = new ModifiablePolicy[1];
AccreditableManager policyManager = getAccreditableManager();
- policies[0] =
getPolicyManager().buildSubtreePolicy(policyManager, getPolicyURL());
+ policies[0] = (ModifiablePolicy)
getPolicyManager().buildSubtreePolicy(policyManager,
+ getPolicyURL());
} else {
String ancestorUrl = "";
@@ -411,7 +410,12 @@
if (lastSlashIndex != -1) {
ancestorUrl = currentUrl.substring(0, lastSlashIndex);
}
- policies =
getPolicyManager().getPolicies(getAccreditableManager(), ancestorUrl);
+ Policy[] pArray =
getPolicyManager().getPolicies(getAccreditableManager(),
+ ancestorUrl);
+ policies = new ModifiablePolicy[pArray.length];
+ for (int i = 0; i < pArray.length; i++) {
+ policies[i] = (ModifiablePolicy) pArray[i];
+ }
}
} catch (AccessControlException e) {
throw new ProcessingException(e);
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControlUsecase.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControlUsecase.java?rev=407305&r1=407248&r2=407305&view=diff
==============================================================================
---
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControlUsecase.java
(original)
+++
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControlUsecase.java
Wed May 17 09:21:49 2006
@@ -24,7 +24,6 @@
import org.apache.lenya.ac.IPRangeManager;
import org.apache.lenya.ac.RoleManager;
import org.apache.lenya.ac.UserManager;
-import org.apache.lenya.ac.impl.DefaultAccessController;
import org.apache.lenya.cms.usecase.AbstractUsecase;
/**
@@ -40,7 +39,7 @@
public AccessControlUsecase() {
super();
}
-
+
private UserManager userManager;
private GroupManager groupManager;
private IPRangeManager ipRangeManager;
@@ -48,29 +47,27 @@
private AccessController accessController;
/**
- * Initializes the accreditable managers.
- * FIXME: This method resolves the AccessController, it has to be released
after it is used!
+ * Initializes the accreditable managers. FIXME: This method resolves the
AccessController, it
+ * has to be released after it is used!
*/
protected void initializeAccessController() {
super.doInitialize();
-
+
if (getLogger().isDebugEnabled())
getLogger().debug("initializeAccessController() called");
this.accessController = null;
ServiceSelector selector = null;
AccessControllerResolver resolver = null;
-
+
try {
- selector = (ServiceSelector)
this.manager.lookup(AccessControllerResolver.ROLE + "Selector");
- resolver =
- (AccessControllerResolver) selector.select(
- AccessControllerResolver.DEFAULT_RESOLVER);
+ selector = (ServiceSelector)
this.manager.lookup(AccessControllerResolver.ROLE
+ + "Selector");
+ resolver = (AccessControllerResolver)
selector.select(AccessControllerResolver.DEFAULT_RESOLVER);
this.accessController =
resolver.resolveAccessController(getSourceURL());
- AccreditableManager accreditableManager =
- ((DefaultAccessController)
this.accessController).getAccreditableManager();
+ AccreditableManager accreditableManager =
this.accessController.getAccreditableManager();
this.userManager = accreditableManager.getUserManager();
this.groupManager = accreditableManager.getGroupManager();
@@ -89,8 +86,7 @@
}
}
-
-
+
/**
* @return Returns the groupManager.
*/
@@ -100,7 +96,7 @@
}
return this.groupManager;
}
-
+
/**
* @return Returns the ipRangeManager.
*/
@@ -110,7 +106,7 @@
}
return this.ipRangeManager;
}
-
+
/**
* @return Returns the roleManager.
*/
@@ -120,19 +116,19 @@
}
return this.roleManager;
}
-
+
/**
* @return Returns the userManager.
*/
protected UserManager getUserManager() {
if (this.userManager == null) {
if (getLogger().isDebugEnabled())
- getLogger().debug("getUserManager() accessed, is null, so
calling initializeAccessController");
+ getLogger().debug("getUserManager() accessed, is null, so
calling initializeAccessController");
initializeAccessController();
}
return this.userManager;
}
-
+
/**
* @return Returns the accessController.
*/
Modified: lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddGroup.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddGroup.java?rev=407305&r1=407248&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddGroup.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddGroup.java Wed May
17 09:21:49 2006
@@ -16,12 +16,8 @@
*/
package org.apache.lenya.cms.ac.usecases;
-import java.io.File;
-
import org.apache.lenya.ac.Group;
-import org.apache.lenya.ac.file.FileGroup;
-import org.apache.lenya.ac.file.FileGroupManager;
-import org.apache.lenya.ac.impl.AbstractItem;
+import org.apache.lenya.ac.ItemUtil;
import org.apache.lenya.cms.usecase.UsecaseException;
/**
@@ -52,7 +48,7 @@
addErrorMessage("This group already exists.");
}
- if (!AbstractItem.isValidId(groupId)) {
+ if (!ItemUtil.isValidId(groupId)) {
addErrorMessage("This is not a valid group ID.");
}
@@ -68,13 +64,11 @@
String name = getParameterAsString(GroupProfile.NAME);
String description = getParameterAsString(GroupProfile.DESCRIPTION);
- File configDir = ((FileGroupManager)
getGroupManager()).getConfigurationDirectory();
- Group group = new FileGroup(configDir, id);
+ Group group = getGroupManager().add(id);
group.setName(name);
group.setDescription(description);
group.save();
- getGroupManager().add(group);
setExitParameter(GroupProfile.ID, id);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddIPRange.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddIPRange.java?rev=407305&r1=407248&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddIPRange.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AddIPRange.java Wed
May 17 09:21:49 2006
@@ -19,16 +19,13 @@
package org.apache.lenya.cms.ac.usecases;
-import java.io.File;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.lenya.ac.IPRange;
-import org.apache.lenya.ac.file.FileIPRange;
-import org.apache.lenya.ac.file.FileIPRangeManager;
-import org.apache.lenya.ac.impl.AbstractItem;
+import org.apache.lenya.ac.ItemUtil;
import org.apache.lenya.cms.ac.usecases.IPRangeProfile.Part;
/**
@@ -48,7 +45,7 @@
addErrorMessage("This IP range already exists.");
}
- if (!AbstractItem.isValidId(id)) {
+ if (!ItemUtil.isValidId(id)) {
addErrorMessage("This is not a valid IP range ID.");
}
@@ -59,13 +56,12 @@
* @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
*/
protected void doExecute() throws Exception {
- File configDir = ((FileIPRangeManager)
getIpRangeManager()).getConfigurationDirectory();
String id = getParameterAsString(IPRangeProfile.ID);
String name = getParameterAsString(IPRangeProfile.NAME);
String description = getParameterAsString(IPRangeProfile.DESCRIPTION);
- IPRange ipRange = new FileIPRange(configDir, id);
+ IPRange ipRange = getIpRangeManager().add(id);
ContainerUtil.enableLogging(ipRange, getLogger());
ipRange.setName(name);
@@ -92,7 +88,6 @@
ipRange.setSubnetMask(subnetMask.getAddress());
ipRange.save();
- getIpRangeManager().add(ipRange);
setExitParameter(IPRangeProfile.ID, id);
}
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/GroupProfile.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/GroupProfile.java?rev=407305&r1=407248&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/GroupProfile.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/GroupProfile.java Wed
May 17 09:21:49 2006
@@ -21,7 +21,7 @@
/**
* Usecase to change the profile of a group.
*
- * @version $Id:$
+ * @version $Id$
*/
public class GroupProfile extends AccessControlUsecase {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/IPRange.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/IPRange.java?rev=407305&r1=407248&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/IPRange.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/IPRange.java Wed May
17 09:21:49 2006
@@ -19,7 +19,7 @@
/**
* Show information about an IP range.
*
- * @version $Id:$
+ * @version $Id$
*/
public class IPRange extends AccessControlUsecase {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/User.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/User.java?rev=407305&r1=407248&r2=407305&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/User.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/User.java Wed May 17
09:21:49 2006
@@ -19,7 +19,7 @@
/**
* Display user information.
*
- * @version $Id:$
+ * @version $Id$
*/
public class User extends AccessControlUsecase {
|