You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@apache.org on 2001/05/04 05:32:20 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib Privilege.java Constants.java Ace.java
remm 01/05/03 20:32:20
Added: src/webdav/client/src/org/apache/webdav/lib Privilege.java
Constants.java Ace.java
Log:
- Add two helper class for WebDAV access control protocol support :
- Ace is a Java representation of the Ace element (which is a child element
of the Acl property)
- Privilege represents the privileges which can be associated with an Ace
Revision Changes Path
1.1 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Privilege.java
Index: Privilege.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Privilege.java,v 1.1 2001/05/04 03:32:20 remm Exp $
* $Revision: 1.1 $
* $Date: 2001/05/04 03:32:20 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib;
import java.util.Vector;
import java.util.Enumeration;
/**
* This interface models a DAV ACE privilege.
*
* @author Remy Maucherat
* @version $Revision: 1.1 $
*/
public class Privilege {
// -------------------------------------------------------------- Constants
// Standard WebDAV ACP privileges
public static final Privilege ALL =
new Privilege(Constants.DAV, "all", null);
public static final Privilege READ =
new Privilege(Constants.DAV, "read", null);
public static final Privilege WRITE =
new Privilege(Constants.DAV, "write", null);
public static final Privilege READ_ACL =
new Privilege(Constants.DAV, "read-acl", null);
public static final Privilege WRITE_ACL =
new Privilege(Constants.DAV, "write-acl", null);
// TODO: Add the Slide specific privileges ?
// ----------------------------------------------------------- Constructors
public Privilege(String namespace, String name, String parameter) {
this.namespace = namespace;
this.name = name;
this.parameter = parameter;
}
// ----------------------------------------------------- Instance Variables
/**
* Custom privilege namespace.
*/
protected String namespace;
/**
* Custom privilege element name.
*/
protected String name;
/**
* Additional parameter (usually, an URI).
*/
protected String parameter;
// ------------------------------------------------------------- Properties
/**
* Namespace accessor.
*/
public String getNamespace() {
return namespace;
}
/**
* Name accessor.
*/
public String getName() {
return name;
}
/**
* Parameter accessor.
*/
public String getParameter() {
return parameter;
}
// --------------------------------------------------------- Public Methods
/**
* Equals.
*/
public boolean equals(Object obj) {
if ((obj == null) || (obj instanceof Privilege)) {
return false;
} else {
if (this == obj)
return true;
Privilege privilege = (Privilege) obj;
if ((namespace.equals(privilege.getNamespace()))
&& (name.equals(privilege.getName()))) {
if (parameter == null) {
if (privilege.getParameter() == null)
return true;
} else {
if (privilege.getParameter() != null)
return (parameter.equals(privilege.getParameter()));
}
}
}
return false;
}
}
1.1 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Constants.java
Index: Constants.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Constants.java,v 1.1 2001/05/04 03:32:20 remm Exp $
* $Revision: 1.1 $
* $Date: 2001/05/04 03:32:20 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib;
/**
* Constants used by the WebDAV client library.
*
* @author Remy Maucherat
* @version $Revision: 1.1 $
*/
public class Constants {
// -------------------------------------------------------------- Constants
public static final String DAV = "DAV:";
public static final String SLIDE = "http://jakarta.apache.org/slide/";
}
1.1 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Ace.java
Index: Ace.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Ace.java,v 1.1 2001/05/04 03:32:20 remm Exp $
* $Revision: 1.1 $
* $Date: 2001/05/04 03:32:20 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib;
import java.util.Vector;
import java.util.Enumeration;
/**
* This interface models a DAV Access control entry.
*
* @author Remy Maucherat
* @version $Revision: 1.1 $
*/
public class Ace {
// ----------------------------------------------------------- Constructors
public Ace(String principal) {
this.principal = principal;
}
public Ace(String principal, boolean negative, boolean protectedAce,
boolean inherited) {
this(principal);
this.negative = negative;
this.protectedAce = protectedAce;
this.inherited = inherited;
}
// ----------------------------------------------------- Instance Variables
/**
* Principal.
*/
protected String principal;
/**
* Negative (deny) flag.
*/
protected boolean negative = false;
/**
* Privileges this ACE grants or denies.
*/
protected Vector privileges = new Vector();
/**
* Protected.
*/
protected boolean protectedAce = false;
/**
* Inherited.
*/
protected boolean inherited = false;
// ------------------------------------------------------------- Properties
/**
* Principal accessor.
*/
public String getPrincipal() {
return principal;
}
/**
* Principal mutator.
*/
public void setPrincipal(String principal) {
this.principal = principal;
}
/**
* Negative accessor.
*/
public boolean isNegative() {
return (negative);
}
/**
* Negative mutator.
*/
public void setNegative(boolean negative) {
this.negative = negative;
}
/**
* Protected accessor.
*/
public boolean isProtected() {
return (protectedAce);
}
/**
* Protected mutator.
*/
public void setProtected(boolean protectedAce) {
this.protectedAce = protectedAce;
}
/**
* Inherited accessor.
*/
public boolean isInherited() {
return (inherited);
}
/**
* Inherited mutator.
*/
public void setInherited(boolean inherited) {
this.inherited = inherited;
}
/**
* Enumerate privileges.
*/
public Enumeration enumeratePrivileges() {
return privileges.elements();
}
/**
* Add privilege.
*/
public void addPrivilege(Privilege privilege) {
privileges.addElement(privilege);
}
/**
* Remove privilege.
*/
public boolean removePrivilege(Privilege privilege) {
return privileges.removeElement(privilege);
}
/**
* Clear privileges.
*/
public void clearPrivileges() {
privileges.clear();
}
}