[Yanel-commits] rev 48323 -
public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi
guillaume at wyona.com
guillaume at wyona.com
Fri Mar 26 16:18:04 CET 2010
Author: guillaume
Date: 2010-03-26 16:18:04 +0100 (Fri, 26 Mar 2010)
New Revision: 48323
Modified:
public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi/UserManagerResource.java
Log:
Implemented API to delete a policy (non-recursively for now).
Modified: public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi/UserManagerResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi/UserManagerResource.java 2010-03-26 15:14:10 UTC (rev 48322)
+++ public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi/UserManagerResource.java 2010-03-26 15:18:04 UTC (rev 48323)
@@ -10,6 +10,7 @@
import org.wyona.security.core.api.Group;
import org.wyona.security.core.api.GroupManager;
import org.wyona.security.core.api.Item;
+import org.wyona.security.core.api.PolicyManager;
import org.wyona.security.core.api.User;
import org.wyona.security.core.api.UserManager;
@@ -29,9 +30,7 @@
private static Logger log = Logger.getLogger(UserManagerResource.class);
- /**
- *
- */
+ @Override
protected InputStream getContentXML(String viewId) {
if (log.isDebugEnabled()) {
log.debug("requested viewId: " + viewId);
@@ -50,6 +49,11 @@
sb.append(getUserAsXML(getEnvironment().getRequest().getParameter("id")));
} else if (usecase.equals("getgroups")) {
sb.append(getGroupsAsXML());
+ } else if (usecase.equals("deletepolicy")) {
+ String path = getParameterAsString("path");
+ String recursivelyText = getParameterAsString("deep");
+ boolean recursively = "1".equals(recursivelyText);
+ deletePolicy(path, recursively);
} else {
sb.append("<no-such-yanel-usecase-implemented>" + usecase + "</no-such-yanel-usecase-implemented>");
}
@@ -65,9 +69,7 @@
return new ByteArrayInputStream(sb.toString().getBytes());
}
- /**
- *
- */
+ @Override
public boolean exists() {
log.warn("TODO: Implementation not finished yet!");
return true;
@@ -119,6 +121,18 @@
}
/**
+ * Deletes a specific policy.
+ * @param id the policy ID
+ */
+ private void deletePolicy(String path, boolean recursively) throws Exception {
+ PolicyManager pm = getRealm().getPolicyManager();
+ if (recursively) {
+ log.warn("Recursively deletion of policies not yet implemented, only policy "+path+" will be deleted.");
+ }
+ pm.removePolicy(path);
+ }
+
+ /**
* Get all users
*/
private StringBuilder getUsersAsXML() throws Exception {
More information about the Yanel-commits
mailing list