remm 01/02/19 23:12:25
Modified: src/webdav/server/org/apache/slide/webdav/method
PropFindMethod.java
Log:
- WebDAV ACL support part 1. Supports the live properties.
- Doesn't try to determine the supported privilege set in a smart way. I don't
know yet if it's doable, but I definitely want to wait for the final draft to
implement
that. So right now, it just maps the Slide privilege set to the (more limited)
DAV ACL default privilege set.
- ACL live property isn't supported yet.
- Tested with DAV Explorer, and the properties apparently have the right contents.
Revision Changes Path
1.9 +233 -9
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PropFindMethod.java 2001/02/19 00:23:47 1.8
+++ PropFindMethod.java 2001/02/20 07:12:25 1.9
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.8 2001/02/19 00:23:47 remm Exp $
- * $Revision: 1.8 $
- * $Date: 2001/02/19 00:23:47 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.9 2001/02/20 07:12:25 remm Exp $
+ * $Revision: 1.9 $
+ * $Date: 2001/02/20 07:12:25 $
*
* ====================================================================
*
@@ -135,6 +135,47 @@
+ "</lockentry>";
+ /**
+ * Supported privilege set.
+ */
+ private static final String SUPPORTED_PRIVILEGE_SET =
+ "supported-privilege-set";
+
+
+ /**
+ * Supported privileges.
+ */
+ private static final String SUPPORTED_PRIVILEGES =
+ "<supported-privilege>"
+ + "<privilege><all/></privilege>"
+ + "<abstract/>"
+ + "<description>Any operation</description>"
+ + "<supported-privilege>"
+ + "<privilege><read/></privilege>"
+ + "<description>Read any object</description>"
+ + "</supported-privilege>"
+ + "<supported-privilege>"
+ + "<privilege><write/></privilege>"
+ + "<description>Write any object</description>"
+ + "</supported-privilege>"
+ + "<supported-privilege>"
+ + "<privilege><read-acl/></privilege>"
+ + "<description>Read the ACL</description>"
+ + "</supported-privilege>"
+ + "<supported-privilege>"
+ + "<privilege><write-acl/></privilege>"
+ + "<description>Write the ACL</description>"
+ + "</supported-privilege>"
+ + "</supported-privilege>";
+
+
+ /**
+ * Current user privilege set.
+ */
+ private static final String CURRENT_USER_PRIVILEGE_SET =
+ "current-user-privilege-set";
+
+
// ----------------------------------------------------- Instance Variables
@@ -295,12 +336,12 @@
* @exception WebdavException
*/
protected void executeRequest()
- throws IOException, WebdavException {
+ throws IOException, WebdavException {
resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
- // Loads the associated object from the store.
- String resourceUri = requestUri;
+ // Loads the associated object from the store.
+ String resourceUri = requestUri;
// Get the object from Data.
ObjectNode resource = null;
@@ -400,7 +441,7 @@
*/
protected void parsePropertiesOfObject(ObjectNode object,
XMLPrinter generatedXML)
- throws WebdavException {
+ throws WebdavException {
generatedXML.writeElement(null, "response", XMLPrinter.OPENING);
@@ -517,6 +558,11 @@
generatedXML.writeElement(null, "supportedlock",
XMLPrinter.CLOSING);
+ // WebDAV ACL
+ showSupportedPrivilegeSet(generatedXML);
+ showCurrentUserPrivilegeSet(object, generatedXML);
+ showAcl(object, generatedXML);
+
// Other properties
Enumeration propertyList =
revisionDescriptor.enumerateProperties();
@@ -564,8 +610,7 @@
+ " " + WebdavStatus.getStatusText
(WebdavStatus.SC_OK));
- generatedXML.writeElement(null, "propstat",
- XMLPrinter.OPENING);
+ generatedXML.writeElement(null, "propstat", XMLPrinter.OPENING);
generatedXML.writeElement(null, "prop", XMLPrinter.OPENING);
// Lock information
@@ -575,6 +620,16 @@
generatedXML.writeElement(null, "supportedlock",
XMLPrinter.NO_CONTENT);
+ // WebDAV ACL
+
+ generatedXML.writeElement(null, "owner", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, "supported-privilege-set",
+ XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, "current-user-privilege-set",
+ XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, "acl",
+ XMLPrinter.NO_CONTENT);
+
// Then, add this resource's custom properties
propertyList = revisionDescriptor.enumerateProperties();
@@ -636,6 +691,19 @@
generatedXML.writeText(SUPPORTED_LOCK);
generatedXML.writeElement(null, "supportedlock",
XMLPrinter.CLOSING);
+ } else if ((propertyName.equals(SUPPORTED_PRIVILEGE_SET)) &&
+ (propertyNamespace.equals
+ (NodeProperty.DEFAULT_NAMESPACE))) {
+ // WebDAV ACL
+ showSupportedPrivilegeSet(generatedXML);
+ } else if ((propertyName.equals(CURRENT_USER_PRIVILEGE_SET)) &&
+ (propertyNamespace.equals
+ (NodeProperty.DEFAULT_NAMESPACE))) {
+ showCurrentUserPrivilegeSet(object, generatedXML);
+ } else if ((propertyName.equals("acl")) &&
+ (propertyNamespace.equals
+ (NodeProperty.DEFAULT_NAMESPACE))) {
+ showAcl(object, generatedXML);
} else {
// Search in the custom properties
@@ -889,6 +957,162 @@
generatedXML.writeElement(null, "activelock", XMLPrinter.CLOSING);
generatedXML.writeElement(null, "lockdiscovery", XMLPrinter.CLOSING);
+
+ }
+
+
+ /**
+ * WebDAV ACL DAV:supported-privilege-set property.
+ */
+ private void showSupportedPrivilegeSet(XMLPrinter generatedXML)
+ throws WebdavException {
+
+ generatedXML.writeElement(null, SUPPORTED_PRIVILEGE_SET,
+ XMLPrinter.OPENING);
+
+ // FIXME : Make the genaration dynamic (although it needs only to be
+ // generated once). I suggest waiting for the DAV ACL spec final
+ // version before implementing that.
+ generatedXML.writeText(SUPPORTED_PRIVILEGES);
+
+ generatedXML.writeElement(null, SUPPORTED_PRIVILEGE_SET,
+ XMLPrinter.CLOSING);
+
+ }
+
+
+ /**
+ * WebDAV ACL DAV:current-user-privilege-set property.
+ */
+ private void showCurrentUserPrivilegeSet
+ (ObjectNode object, XMLPrinter generatedXML)
+ throws WebdavException {
+
+ NamespaceConfig config = token.getNamespaceConfig();
+
+ SubjectNode principalNode = null;
+
+ try {
+ principalNode = (SubjectNode) security.getPrincipal(slideToken);
+ } catch (SlideException e) {
+ return;
+ } catch (ClassCastException e) {
+ return;
+ }
+
+ try {
+
+ boolean readObject =
+ security.hasPermission(object, principalNode,
+ config.getReadObjectAction());
+ boolean createObject =
+ security.hasPermission(object, principalNode,
+ config.getCreateObjectAction());
+ boolean removeObject =
+ security.hasPermission(object, principalNode,
+ config.getRemoveObjectAction());
+ boolean grantPermission =
+ security.hasPermission(object, principalNode,
+ config.getGrantPermissionAction());
+ boolean revokePermission =
+ security.hasPermission(object, principalNode,
+ config.getRevokePermissionAction());
+ boolean readPermissions =
+ security.hasPermission(object, principalNode,
+ config.getReadPermissionsAction());
+ boolean lockObject =
+ security.hasPermission(object, principalNode,
+ config.getLockObjectAction());
+ boolean killLock =
+ security.hasPermission(object, principalNode,
+ config.getKillLockAction());
+ boolean readLocks =
+ security.hasPermission(object, principalNode,
+ config.getReadLocksAction());
+ boolean readRevisionMetadata =
+ security.hasPermission(object, principalNode,
+ config.getReadRevisionMetadataAction());
+ boolean createRevisionMetadata = security.hasPermission
+ (object, principalNode,
+ config.getCreateRevisionMetadataAction());
+ boolean modifyRevisionMetadata = security.hasPermission
+ (object, principalNode,
+ config.getModifyRevisionMetadataAction());
+ boolean removeRevisionMetadata = security.hasPermission
+ (object, principalNode,
+ config.getRemoveRevisionMetadataAction());
+ boolean readRevisionContent =
+ security.hasPermission(object, principalNode,
+ config.getReadRevisionContentAction());
+ boolean createRevisionContent = security.hasPermission
+ (object, principalNode,
+ config.getCreateRevisionContentAction());
+ boolean modifyRevisionContent = security.hasPermission
+ (object, principalNode,
+ config.getModifyRevisionContentAction());
+ boolean removeRevisionContent = security.hasPermission
+ (object, principalNode,
+ config.getRemoveRevisionContentAction());
+
+ boolean canRead = readObject && readRevisionMetadata
+ && readRevisionContent;
+ boolean canWrite = createObject && removeObject && lockObject
+ && readLocks && createRevisionMetadata
+ && modifyRevisionMetadata && removeRevisionMetadata
+ && createRevisionContent && modifyRevisionContent
+ && removeRevisionContent;
+ boolean canReadAcl = readPermissions;
+ boolean canWriteAcl = grantPermission && revokePermission;
+ boolean canAll = canRead && canWrite && canReadAcl && canWriteAcl
+ && killLock;
+
+ generatedXML.writeElement(null, CURRENT_USER_PRIVILEGE_SET,
+ XMLPrinter.OPENING);
+
+ if (canRead) {
+ writePrivilege(generatedXML, "read", null);
+ }
+ if (canWrite) {
+ writePrivilege(generatedXML, "write", null);
+ }
+ if (canReadAcl) {
+ writePrivilege(generatedXML, "read-acl", null);
+ }
+ if (canWriteAcl) {
+ writePrivilege(generatedXML, "write-acl", null);
+ }
+ if (canAll) {
+ writePrivilege(generatedXML, "all", null);
+ }
+
+ generatedXML.writeElement(null, CURRENT_USER_PRIVILEGE_SET,
+ XMLPrinter.CLOSING);
+
+ } catch (SlideException e) {
+ return;
+ }
+
+ }
+
+
+ /**
+ * Write a privilege.
+ */
+ private void writePrivilege(XMLPrinter generatedXML, String privilege,
+ String namespace) {
+ generatedXML.writeElement(null, "privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(namespace, privilege, XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, "privilege", XMLPrinter.CLOSING);
+ }
+
+
+ /**
+ * WebDAV ACL DAV:acl property.
+ */
+ private void showAcl(ObjectNode object, XMLPrinter generatedXML)
+ throws WebdavException {
+
+
}