All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dmfs.dav.rfc3744.WebDavAcl Maven / Gradle / Ivy

/*
 * Copyright (C) 2014 Marten Gajda 
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

package org.dmfs.dav.rfc3744;

import org.dmfs.dav.rfc4918.WebDav;
import org.dmfs.dav.utils.MergeSetObjectBuilder;
import org.dmfs.xmlobjects.ElementDescriptor;
import org.dmfs.xmlobjects.QualifiedName;
import org.dmfs.xmlobjects.builder.AbstractObjectBuilder;
import org.dmfs.xmlobjects.builder.QualifiedNameObjectBuilder;
import org.dmfs.xmlobjects.builder.SetObjectBuilder;
import org.dmfs.xmlobjects.builder.TransientObjectBuilder;
import org.dmfs.xmlobjects.pull.ParserContext;
import org.dmfs.xmlobjects.pull.XmlObjectPullParserException;

import java.net.URI;
import java.util.Set;


/**
 * Names and definitions from Access Control Protocol Extensions to WebDAV, RFC 3744.
 * 

* TODO: add all the missing names and properties. *

*

* TODO: add missing javadoc. *

*/ public final class WebDavAcl { /** * WebDAV ACL uses the {@link WebDav#NAMESPACE} namespace. */ public final static String NAMESPACE = WebDav.NAMESPACE; /** * principal as defined in RFC 3744, section 4 and RFC 3744, appendix A. It accepts any element and stores the {@link QualifiedName}. */ public final static ElementDescriptor PRINCIPAL = ElementDescriptor.register(ResourceTypes.PRINCIPAL, new TransientObjectBuilder(QualifiedNameObjectBuilder.INSTANCE)); /** * Defines new resource types introduced in RFC 3744, section 5.4. */ public final static class ResourceTypes { /** * {@link QualifiedName} of the principal resource-type. */ public final static QualifiedName PRINCIPAL = QualifiedName.get(NAMESPACE, "principal"); } /* --------------------------------------------- Principal elements --------------------------------------------- */ public final static ElementDescriptor PRINCIPAL_ALL = ElementDescriptor.register(QualifiedName.get(NAMESPACE, "all"), new AbstractObjectBuilder() { public URI get(ElementDescriptor descriptor, URI recycle, ParserContext context) throws XmlObjectPullParserException { return PseudoPrincipals.ALL; } ; }); public final static ElementDescriptor PRINCIPAL_AUTHENTICATED = ElementDescriptor.register(QualifiedName.get(NAMESPACE, "authenticated"), new AbstractObjectBuilder() { public URI get(ElementDescriptor descriptor, URI recycle, ParserContext context) throws XmlObjectPullParserException { return PseudoPrincipals.AUTHENTICATED; } ; }); public final static ElementDescriptor PRINCIPAL_UNAUTHENTICATED = ElementDescriptor.register(QualifiedName.get(NAMESPACE, "unauthenticated"), new AbstractObjectBuilder() { public URI get(ElementDescriptor descriptor, URI recycle, ParserContext context) throws XmlObjectPullParserException { return PseudoPrincipals.UNAUTHENTICATED; } ; }); public final static ElementDescriptor PRINCIPAL_SELF = ElementDescriptor.register(QualifiedName.get(NAMESPACE, "self"), new AbstractObjectBuilder() { public URI get(ElementDescriptor descriptor, URI recycle, ParserContext context) throws XmlObjectPullParserException { return PseudoPrincipals.SELF; } ; }); public final static class PseudoPrincipals { /** * This is the pseudo principal all. The actual value of this is not of any relevance and should not be used. */ public final static URI ALL = URI.create("http://dmfs.org/pseudo-principals/all"); /** * This is the pseudo principal authenticated. The actual value of this is not of any relevance and should not be used. */ public final static URI AUTHENTICATED = URI.create("http://dmfs.org/pseudo-principals/authenticated"); /** * This is the pseudo principal unauthenticated. The actual value of this is not of any relevance and should not be used. */ public final static URI UNAUTHENTICATED = URI.create("http://dmfs.org/pseudo-principals/unauthenticated"); /** * This is the pseudo principal self. The actual value of this is not of any relevance and should not be used. */ public final static URI SELF = URI.create("http://dmfs.org/pseudo-principals/self"); } /* --------------------------------------------- Privilege elements --------------------------------------------- */ /** * privilege as defined in RFC 3744, section 5.4 and RFC 3744, appendix A. It accepts any element and stores the {@link QualifiedName}. *

* Note: Some servers return all privileges within one privilege element. According to the specs that's not allowed. To be compatible with * these this element is modeled by a {@link Set} of {@link QualifiedName}s instead of a single {@link QualifiedName}. Elements that have this as child * element must make sure they serialize all privileges separately. *

* TODO: we should revert this eventually */ public final static ElementDescriptor> PRIVILEGE = ElementDescriptor.register(QualifiedName.get(NAMESPACE, "privilege"), new SetObjectBuilder(QualifiedNameObjectBuilder.INSTANCE, false)); public final static ElementDescriptor PRIVILEGE_ALL = ElementDescriptor.registerWithParents(Privileges.ALL, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_BIND = ElementDescriptor.registerWithParents(Privileges.BIND, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_READ = ElementDescriptor.registerWithParents(Privileges.READ, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_READ_ACL = ElementDescriptor.registerWithParents(Privileges.READ_ACL, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_READ_CURRENT_USER_PRIVILEGE_SET = ElementDescriptor.registerWithParents( Privileges.READ_CURRENT_USER_PRIVILEGE_SET, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_WRITE = ElementDescriptor.registerWithParents(Privileges.WRITE, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_WRITE_ACL = ElementDescriptor.registerWithParents(Privileges.WRITE_ACL, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_WRITE_PROPERTIES = ElementDescriptor.registerWithParents(Privileges.WRITE_PROPERTIES, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_WRITE_CONTENT = ElementDescriptor.registerWithParents(Privileges.WRITE_CONTENT, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_UNBIND = ElementDescriptor.registerWithParents(Privileges.UNBIND, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); public final static ElementDescriptor PRIVILEGE_UNLOCK = ElementDescriptor.registerWithParents(Privileges.UNLOCK, QualifiedNameObjectBuilder.INSTANCE, PRIVILEGE); /** * Privileges defined in RFC 3744, Section 3. */ public final static class Privileges { public final static QualifiedName ALL = QualifiedName.get(NAMESPACE, "all"); public final static QualifiedName BIND = QualifiedName.get(NAMESPACE, "bind"); public final static QualifiedName READ = QualifiedName.get(NAMESPACE, "read"); public final static QualifiedName READ_ACL = QualifiedName.get(NAMESPACE, "read-acl"); public final static QualifiedName READ_CURRENT_USER_PRIVILEGE_SET = QualifiedName.get(NAMESPACE, "read-current-user-privilege-set"); public final static QualifiedName WRITE = QualifiedName.get(NAMESPACE, "write"); public final static QualifiedName WRITE_ACL = QualifiedName.get(NAMESPACE, "write-acl"); public final static QualifiedName WRITE_PROPERTIES = QualifiedName.get(NAMESPACE, "write-properties"); public final static QualifiedName WRITE_CONTENT = QualifiedName.get(NAMESPACE, "write-content"); public final static QualifiedName UNBIND = QualifiedName.get(NAMESPACE, "unbind"); public final static QualifiedName UNLOCK = QualifiedName.get(NAMESPACE, "unlock"); /** * No instances allowed. */ private Privileges() { } } /* --------------------------------------------- Property elements --------------------------------------------- */ /* * We use a MergeSetObjectBuilder to merge the privilege sets into one. * * TODO: We should switch back to a simple SetObjectBuilder eventually. */ final static ElementDescriptor> PROP_CURRENT_USER_PRIVILEGE_SET = ElementDescriptor.register( QualifiedName.get(NAMESPACE, "current-user-privilege-set"), new MergeSetObjectBuilder(PRIVILEGE)); final static ElementDescriptor> PROP_PRINCIPAL_COLLECTION_SET = ElementDescriptor.register( QualifiedName.get(NAMESPACE, "principal-collection-set"), new SetObjectBuilder(WebDav.HREF, false)); /** * Properties defined in RFC 3744, Section 4 and RFC 3744, Section 5. */ public final static class Properties { /** * current-user-privilege-set as defined in RFC 3744, section 5.4 and RFC 3744, appendix A. */ public final static ElementDescriptor> CURRENT_USER_PRIVILEGE_SET = WebDavAcl.PROP_CURRENT_USER_PRIVILEGE_SET; /** * principal-collection-set as defined in RFC 3744, section 5.8 and RFC 3744, appendix A */ public final static ElementDescriptor> PRINCIPAL_COLLECTION_SET = WebDavAcl.PROP_PRINCIPAL_COLLECTION_SET; /** * No instances allowed. */ private Properties() { } } /** * No instances allowed. */ private WebDavAcl() { } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy