You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by th...@apache.org on 2006/08/18 17:39:27 UTC

svn commit: r432620 - in /lenya/sandbox/ac-restricted-1.4-src: ./ java/org/apache/lenya/ac/ modules-core/ac-impl/java/src/org/apache/lenya/ac/file/ modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/ modules-core/administration/java/src/org/apache/...

Author: thorsten
Date: Fri Aug 18 08:39:23 2006
New Revision: 432620

URL: http://svn.apache.org/viewvc?rev=432620&view=rev
Log:
first steps refactoring the jx template. Adding the method and header to the form. Adding URL rights isnow working fine. Other not yet implemented/tested. Needed to comment one line in a method that I have not yet been able to debug.

Modified:
    lenya/sandbox/ac-restricted-1.4-src/README_AC.txt
    lenya/sandbox/ac-restricted-1.4-src/java/org/apache/lenya/ac/ModifiablePolicy.java
    lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/file/FilePolicyManager.java
    lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/DefaultPolicy.java
    lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/PolicyBuilder.java
    lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/AccessControl.java
    lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/CredentialWrapper.java
    lenya/sandbox/ac-restricted-1.4-src/modules-core/sitemanagement/usecases/tab/ac/ac.jx

Modified: lenya/sandbox/ac-restricted-1.4-src/README_AC.txt
URL: http://svn.apache.org/viewvc/lenya/sandbox/ac-restricted-1.4-src/README_AC.txt?rev=432620&r1=432619&r2=432620&view=diff
==============================================================================
--- lenya/sandbox/ac-restricted-1.4-src/README_AC.txt (original)
+++ lenya/sandbox/ac-restricted-1.4-src/README_AC.txt Fri Aug 18 08:39:23 2006
@@ -47,6 +47,7 @@
 Examples:
 *********
 Like stated above the order of the credential is important. 
+Credentials are builded from policies.
 Imaginge you are trying to access http://localhost:8888/default/introduction.html
 
 The defined policy (with highest priority) would be:
@@ -77,4 +78,6 @@
   </world>
 </policy>
 
-Let all user of the group editor access the page.
\ No newline at end of file
+Let all user of the group editor access the page.
+
+Best practise is to deny access early in a node tree of policies for e.g. WORLD. 
\ No newline at end of file

Modified: lenya/sandbox/ac-restricted-1.4-src/java/org/apache/lenya/ac/ModifiablePolicy.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/ac-restricted-1.4-src/java/org/apache/lenya/ac/ModifiablePolicy.java?rev=432620&r1=432619&r2=432620&view=diff
==============================================================================
--- lenya/sandbox/ac-restricted-1.4-src/java/org/apache/lenya/ac/ModifiablePolicy.java (original)
+++ lenya/sandbox/ac-restricted-1.4-src/java/org/apache/lenya/ac/ModifiablePolicy.java Fri Aug 18 08:39:23 2006
@@ -33,8 +33,9 @@
      * credential is created.
      * @param accreditable An accreditable.
      * @param role A role.
+     * @param method 
      */
-    public void addRole(Accreditable accreditable, Role role);
+    public void addRole(Accreditable accreditable, Role role, String method);
 
     /**
      * Removes a role from this policy for a certain accreditable and a certain role.

Modified: lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/file/FilePolicyManager.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/file/FilePolicyManager.java?rev=432620&r1=432619&r2=432620&view=diff
==============================================================================
--- lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/file/FilePolicyManager.java (original)
+++ lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/file/FilePolicyManager.java Fri Aug 18 08:39:23 2006
@@ -505,7 +505,7 @@
             if (role != null) {
                 String url = USER_ADMIN_URL + ((User) accreditable).getId() + ".html";
                 ModifiablePolicy policy = (ModifiablePolicy) buildSubtreePolicy(manager, url);
-                policy.addRole(accreditable, role);
+               // policy.addRole(accreditable, role);
                 saveSubtreePolicy(url, policy);
             }
         }

Modified: lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/DefaultPolicy.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/DefaultPolicy.java?rev=432620&r1=432619&r2=432620&view=diff
==============================================================================
--- lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/DefaultPolicy.java (original)
+++ lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/DefaultPolicy.java Fri Aug 18 08:39:23 2006
@@ -57,7 +57,7 @@
      * @param accreditable An accreditable.
      * @param role A role.
      */
-    public void addRole(Accreditable accreditable, Role role) {
+    public void addRole(Accreditable accreditable, Role role, String method) {
         assert accreditable != null;
         assert role != null;
 
@@ -66,6 +66,7 @@
             credential = new CredentialImpl(accreditable);
             addCredential(credential);
         }
+        credential.setMethod(method);
         if (!credential.contains(role)) {
             credential.addRole(role);
         }

Modified: lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/PolicyBuilder.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/PolicyBuilder.java?rev=432620&r1=432619&r2=432620&view=diff
==============================================================================
--- lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/PolicyBuilder.java (original)
+++ lenya/sandbox/ac-restricted-1.4-src/modules-core/ac-impl/java/src/org/apache/lenya/ac/impl/PolicyBuilder.java Fri Aug 18 08:39:23 2006
@@ -207,6 +207,7 @@
             for (int j = 0; j < roles.length; j++) {
                 Element roleElement = helper.createElement(ROLE_ELEMENT);
                 roleElement.setAttribute(ID_ATTRIBUTE, roles[j].getId());
+                roleElement.setAttribute(METHOD_ATTRIBUTE, credentials[i].getMethod());
                 accreditableElement.appendChild(roleElement);
             }
             

Modified: lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/AccessControl.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/AccessControl.java?rev=432620&r1=432619&r2=432620&view=diff
==============================================================================
--- lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/AccessControl.java (original)
+++ lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/AccessControl.java Fri Aug 18 08:39:23 2006
@@ -55,6 +55,8 @@
     protected static final String DOCUMENT = "document";
     protected static final String URL_CREDENTIALS = "urlCredentials";
     protected static final String PARENT_CREDENTIALS = "parentCredentials";
+
+    private static final String METHOD = "method";
     private String COMPLETE_AREA = "private.completeArea";
 
     /**
@@ -183,6 +185,7 @@
                     String paramName = operations[j] + "Credential_" + types[i];
                     if (getParameterAsString(paramName) != null) {
                         String roleId = getParameterAsString(ROLE);
+                        String method = getParameterAsString(METHOD);
 
                         String id = getParameterAsString(types[i]);
                         Item item = null;
@@ -200,7 +203,7 @@
                             if (role == null) {
                                 addErrorMessage("role_no_such_role", new String[] { roleId });
                             }
-                            manipulateCredential(item, role, operations[j]);
+                            manipulateCredential(item, role, operations[j],method);
                             setParameter(URL_CREDENTIALS, getURICredentials());
                         }
                         deleteParameter(paramName);
@@ -294,23 +297,24 @@
      * @param item The item to add or delete.
      * @param role The role.
      * @param operation The operation, either {@link #ADD}or {@link #DELETE}.
+     * @param method2 
      * @throws ProcessingException when something went wrong.
      */
-    protected void manipulateCredential(Item item, Role role, String operation)
+    protected void manipulateCredential(Item item, Role role, String operation, String method)
             throws ProcessingException {
 
         try {
-            ModifiablePolicy policy = (ModifiablePolicy) getPolicyManager().buildSubtreePolicy(getAccreditableManager(),
+            ModifiablePolicy policy = (ModifiablePolicy) getPolicyManager().buildURLPolicy(getAccreditableManager(),
                     getPolicyURL());
             Accreditable accreditable = (Accreditable) item;
 
             if (operation.equals(ADD)) {
-                policy.addRole(accreditable, role);
+                policy.addRole(accreditable, role,method);
             } else if (operation.equals(DELETE)) {
                 policy.removeRole(accreditable, role);
             }
 
-            getPolicyManager().saveSubtreePolicy(getPolicyURL(), policy);
+            getPolicyManager().saveURLPolicy(getPolicyURL(), policy);
 
         } catch (Exception e) {
             throw new ProcessingException("Manipulating credential failed: ", e);
@@ -359,8 +363,9 @@
             Credential credential = (Credential) i.next();
             Accreditable accreditable = credential.getAccreditable();
             Role[] roles = credential.getRoles();
+            String method = credential.getMethod();
             for (int j = 0; j < roles.length; j++) {
-                credentials.add(new CredentialWrapper(accreditable, roles[j]));
+                credentials.add(new CredentialWrapper(accreditable, roles[j],method));
             }
         }
         return (CredentialWrapper[]) credentials.toArray(new CredentialWrapper[credentials.size()]);
@@ -381,7 +386,7 @@
             if (onlyUrl) {
                 policies = new ModifiablePolicy[1];
                 AccreditableManager policyManager = getAccreditableManager();
-                policies[0] = (ModifiablePolicy) getPolicyManager().buildSubtreePolicy(policyManager,
+                policies[0] = (ModifiablePolicy) getPolicyManager().buildURLPolicy(policyManager,
                         getPolicyURL());
             } else {
                 String ancestorUrl = "";

Modified: lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/CredentialWrapper.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/CredentialWrapper.java?rev=432620&r1=432619&r2=432620&view=diff
==============================================================================
--- lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/CredentialWrapper.java (original)
+++ lenya/sandbox/ac-restricted-1.4-src/modules-core/administration/java/src/org/apache/lenya/cms/ac/usecases/CredentialWrapper.java Fri Aug 18 08:39:23 2006
@@ -31,6 +31,13 @@
 public class CredentialWrapper {
 
     /**
+     * Returns the method of the Credential
+     * @return A string that is either "deny" or "grant"
+     */
+    public String getMethod() {
+        return method;
+    }
+    /**
      * Returns the accreditable ID.
      * @return A string.
      */
@@ -74,8 +81,9 @@
      * Ctor.
      * @param accreditable The accreditable of the credential to wrap.
      * @param role The role of the credential to wrap.
+     * @param method 
      */
-    public CredentialWrapper(Accreditable accreditable, Role role) {
+    public CredentialWrapper(Accreditable accreditable, Role role, String method) {
         if (accreditable instanceof Item) {
             Item item = (Item) accreditable;
             this.accreditableId = item.getId();
@@ -98,6 +106,7 @@
         }
         this.roleId = role.getId();
         this.roleName = role.getName();
+        this.method = method;
         
     }
     
@@ -110,5 +119,6 @@
     private String accreditableName;
     private String roleId;
     private String roleName;
+    private String method;
 
 }

Modified: lenya/sandbox/ac-restricted-1.4-src/modules-core/sitemanagement/usecases/tab/ac/ac.jx
URL: http://svn.apache.org/viewvc/lenya/sandbox/ac-restricted-1.4-src/modules-core/sitemanagement/usecases/tab/ac/ac.jx?rev=432620&r1=432619&r2=432620&view=diff
==============================================================================
--- lenya/sandbox/ac-restricted-1.4-src/modules-core/sitemanagement/usecases/tab/ac/ac.jx (original)
+++ lenya/sandbox/ac-restricted-1.4-src/modules-core/sitemanagement/usecases/tab/ac/ac.jx Fri Aug 18 08:39:23 2006
@@ -29,26 +29,29 @@
     <div id="contentblock1" class="lenya-tab-sitetree">
       <table class="lenya-table">
         <tr>
-          <td colspan="4">
+          <td colspan="5">
             <jx:import uri="fallback://lenya/usecases/templates/messages.jx"/>
           </td>
         </tr>
         <tr>
-          <th colspan="4">
+          <th colspan="5">
             <jx:import uri="fallback://lenya/modules/sitemanagement/usecases/tab/ac/ssl-form.jx"/>
           </th>
         </tr>
-        <tr><td colspan="4">&#160;</td></tr>
+        <tr><td colspan="5">&#160;</td></tr>
         <tr>
-          <th colspan="2">
-            <i18n:text>Access Object</i18n:text>
+          <th colspan="5">
+            <h1>
+              <i18n:text>Access Object</i18n:text>
+            </h1>
           </th>
-          <th>
-            <jx:if test="${area.equals('authoring')}">
-              <i18n:text>Role</i18n:text>
-            </jx:if>&#160;
-          </th>
-          <th/>
+        </tr>
+        <tr>
+          <th>Type</th>
+          <th>Id</th>
+          <th>Role</th>
+          <th>Method</th>
+          <th>&#160;</th>
         </tr>
         <tr>
           
@@ -71,6 +74,12 @@
               </select>
             </td>
             <td>
+              <select name="method" class="lenya-form-element-narrow">
+                <option value="deny">Deny</option>
+                <option value="grant">Grant</option>
+              </select>
+            </td>
+            <td>
               <input i18n:attr="value" type="submit" name="addCredential_user" value="Add"/>
             </td>
           </form>
@@ -96,6 +105,12 @@
               </select>
             </td>
             <td>
+              <select name="method" class="lenya-form-element-narrow">
+                <option value="deny">Deny</option>
+                <option value="grant">Grant</option>
+              </select>
+            </td>
+            <td>
               <input i18n:attr="value" type="submit" name="addCredential_group" value="Add" />
             </td>
           </form>
@@ -121,18 +136,33 @@
                 </select>
               </td>
               <td>
+                <select name="method" class="lenya-form-element-narrow">
+                  <option value="deny">Deny</option>
+                  <option value="grant">Grant</option>
+                </select>
+              </td>
+              <td>
                 <input i18n:attr="value" type="submit" name="addCredential_ipRange" value="Add"/>
               </td>
             </form>
           </tr>
         </jx:if>
         
-        <tr><td colspan="4">&#160;</td></tr>
+        <tr><td colspan="5">&#160;</td></tr>
         <tr>
-          <th colspan="4">
-            <i18n:text>URL Rights</i18n:text>
+          <th colspan="5">
+            <h1>
+              <i18n:text>URL Rights</i18n:text>
+            </h1>
           </th>
         </tr>
+        <tr>
+          <th>Type</th>
+          <th>Id</th>
+          <th>Role</th>
+          <th>Method</th>
+          <th>&#160;</th>
+        </tr>
         <jx:forEach var="credential" items="${usecase.getParameter('urlCredentials')}">
           <form method="get" id="form-deleteCredential">
             <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
@@ -150,18 +180,28 @@
                 <jx:out value="${credential.getRoleId()}"/>
               </td>
               <td>
+                <input type="hidden" name="method" value="${credential.getMethod()}"/>
+                <jx:out value="${credential.getMethod()}"/>
+              </td>
+              <td>
                 <input type="submit" name="deleteCredential_${credential.getType()}" i18n:attr="value" value="Delete"/>
               </td>
             </tr>
           </form>
         </jx:forEach>
         
-        <tr><td colspan="4">&#160;</td></tr>
+        <tr><td colspan="5">&#160;</td></tr>
         <tr>
-          <th colspan="4">
-            <i18n:text>Inherited Rights</i18n:text>
+          <th colspan="5">
+            <h1><i18n:text>Inherited Rights</i18n:text></h1>
           </th>
         </tr>
+        <tr>
+          <th>Type</th>
+          <th>Id</th>
+          <th>Role</th>
+          <th colspan="2">Method</th>
+        </tr>
         <jx:forEach var="credential" items="${usecase.getParameter('parentCredentials')}">
           <tr>
             <td>
@@ -170,8 +210,11 @@
             <td>
               <jx:out value="${credential.getAccreditableId()}"/>
             </td>
-            <td colspan="2">
+            <td>
               <jx:out value="${credential.getRoleId()}"/>
+            </td>
+            <td colspan="2">
+              <jx:out value="${credential.getMethod()}"/>
             </td>
           </tr>
         </jx:forEach>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org