[Yanel-commits] rev 54635 -
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client
michi at wyona.com
michi at wyona.com
Fri Nov 12 15:09:17 CET 2010
Author: michi
Date: 2010-11-12 15:09:17 +0100 (Fri, 12 Nov 2010)
New Revision: 54635
Added:
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Item.java
Modified:
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousPolicySetter.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Group.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/User.java
Log:
do not disentangle users and groups
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java 2010-11-12 13:57:52 UTC (rev 54634)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java 2010-11-12 14:09:17 UTC (rev 54635)
@@ -151,7 +151,7 @@
public void onClick(Widget sender) {
final AsynchronousPolicySetter aps = new AsynchronousPolicySetter(savePolicyUrl);
try {
- com.google.gwt.http.client.Request request = aps.sendRequest(policyLBW.getUsers(), policyLBW.getGroups(), policyLBW.getUseInheritedPolicies());
+ com.google.gwt.http.client.Request request = aps.sendRequest(policyLBW.getItems(), policyLBW.getUseInheritedPolicies());
// TODO: Disable button during save (start a timer in order to enable when response has been received)
//saveButton.setEnabled(false);
} catch (Exception e) {
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousPolicySetter.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousPolicySetter.java 2010-11-12 13:57:52 UTC (rev 54634)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousPolicySetter.java 2010-11-12 14:09:17 UTC (rev 54635)
@@ -39,8 +39,56 @@
}
/**
- *
+ * Send XML request containing policy with users and groups and corresponding rights
+ * @param items A list of users and groups
*/
+ public Request sendRequest(java.util.List items, boolean useInheritedPolicies) throws RequestException {
+ StringBuffer data = new StringBuffer("<?xml version=\"1.0\"?>");
+ data.append("<policy xmlns=\"http://www.wyona.org/security/1.0\" use-inherited-policies=\"" + useInheritedPolicies + "\">");
+ if (items != null) {
+ for (int i = 0; i < items.size(); i++) {
+ Item item = (Item) items.get(i);
+ if (items.get(i) instanceof User) {
+ data.append("<user id=\"" + item.getId() + "\">");
+ Right[] rights = item.getRights();
+ if (rights != null) {
+ for (int k = 0; k < rights.length; k++) {
+ data.append("<right id=\"" + rights[k].getId() + "\" permission=\"" + rights[k].getPermission() + "\">" + rights[k].getId() + "</right>");
+ }
+ } else {
+ // TODO: Do not hardcode rights
+ data.append("<right id=\"r\" permission=\"false\">" + "r" + "</right>");
+ data.append("<right id=\"w\" permission=\"false\">" + "w" + "</right>");
+ }
+ data.append("</user>");
+ } else if (items.get(i) instanceof Group) {
+ data.append("<group id=\"" + item.getId() + "\">");
+ Right[] rights = item.getRights();
+ if (rights != null) {
+ for (int k = 0; k < rights.length; k++) {
+ data.append("<right id=\"" + rights[k].getId() + "\" permission=\"" + rights[k].getPermission() + "\">" + rights[k].getId() + "</right>");
+ }
+ } else {
+ // TODO: Do not hardcode rights
+ data.append("<right id=\"r\" permission=\"false\">" + "r" + "</right>");
+ data.append("<right id=\"w\" permission=\"false\">" + "w" + "</right>");
+ }
+ data.append("</group>");
+ } else {
+ Window.alert("ERROR: No items!");
+ }
+ }
+ } else {
+ Window.alert("ERROR: No items!");
+ }
+ data.append("</policy>");
+ return requestBuilder.sendRequest(data.toString(), this);
+ }
+
+ /**
+ * @deprecated Use sendRequest(Item[], boolean) instead
+ */
+/*
public Request sendRequest(User[] users, Group[] groups, boolean useInheritedPolicies) throws RequestException {
StringBuffer data = new StringBuffer("<?xml version=\"1.0\"?>");
data.append("<policy xmlns=\"http://www.wyona.org/security/1.0\" use-inherited-policies=\"" + useInheritedPolicies + "\">");
@@ -79,6 +127,7 @@
data.append("</policy>");
return requestBuilder.sendRequest(data.toString(), this);
}
+*/
/**
*
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Group.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Group.java 2010-11-12 13:57:52 UTC (rev 54634)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Group.java 2010-11-12 14:09:17 UTC (rev 54635)
@@ -18,30 +18,12 @@
/**
*
*/
-public class Group {
+public class Group extends Item {
- private String id;
- private Right[] rights;
-
/**
*
*/
public Group(String id, Right[] rights) {
- this.id = id;
- this.rights = rights;
+ super(id, rights);
}
-
- /**
- *
- */
- public String getId() {
- return id;
- }
-
- /**
- *
- */
- public Right[] getRights() {
- return rights;
- }
}
Added: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Item.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Item.java (rev 0)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Item.java 2010-11-12 14:09:17 UTC (rev 54635)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2010 Wyona
+ *
+ * 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.wyona.security.gwt.accesspolicyeditor.client;
+
+/**
+ *
+ */
+public class Item {
+
+ private String id;
+ private Right[] rights;
+
+ /**
+ *
+ */
+ public Item(String id, Right[] rights) {
+ this.id = id;
+ this.rights = rights;
+ }
+
+ /**
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ *
+ */
+ public Right[] getRights() {
+ return rights;
+ }
+}
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java 2010-11-12 13:57:52 UTC (rev 54634)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java 2010-11-12 14:09:17 UTC (rev 54635)
@@ -408,8 +408,28 @@
}
/**
- *
+ * Get all users and groups from list (including the rights)
*/
+ public java.util.List getItems() {
+ java.util.List items = new java.util.ArrayList();
+ for (int i = 0; i < lb.getItemCount(); i++) {
+ String itemText = lb.getItemText(i);
+ Right[] rights = getRights(itemText);
+ String id = getIdentityWithoutRights(i);
+ if (id.startsWith("u:")) {
+ items.add(new User(id.substring(2).trim(), rights));
+ } else if (id.startsWith("g:")) {
+ items.add(new Group(id.substring(2).trim(), rights));
+ } else {
+ Window.alert("ERROR: Neither user nor group: " + id);
+ }
+ }
+ return items;
+ }
+
+ /**
+ * Get all users from list (including the rights)
+ */
public User[] getUsers() {
Vector users = new Vector();
for (int i = 0; i < lb.getItemCount(); i++) {
@@ -429,7 +449,7 @@
}
/**
- *
+ * Get all users from list (including the rights)
*/
public Group[] getGroups() {
Vector groups = new Vector();
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/User.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/User.java 2010-11-12 13:57:52 UTC (rev 54634)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/User.java 2010-11-12 14:09:17 UTC (rev 54635)
@@ -18,30 +18,12 @@
/**
*
*/
-public class User {
+public class User extends Item {
- private String id;
- private Right[] rights;
-
/**
*
*/
public User(String id, Right[] rights) {
- this.id = id;
- this.rights = rights;
+ super(id, rights);
}
-
- /**
- *
- */
- public String getId() {
- return id;
- }
-
- /**
- *
- */
- public Right[] getRights() {
- return rights;
- }
}
More information about the Yanel-commits
mailing list