001: /*
002: * Copyright 2006 Day Management AG, Switzerland. All rights reserved.
003: */
004: package javax.jcr.security;
005:
006: /**
007: * A privilege represents the capability of performing a particular set
008: * of operations on items in the JCR repository. Each privilege is identified
009: * by a NAME that is unique across the set of privileges supported by a
010: * repository. JCR defines a set of standard privileges in the <code>jcr</code>
011: * namespace. Implementations may add additional privileges in namespaces other
012: * than <code>jcr</code>.
013: * <p/>
014: * A privilege may be an aggregate privilege. Aggregate privileges are sets of
015: * other privileges. Granting, denying, or testing an aggregate privilege is
016: * equivalent to individually granting, denying, or testing each privilege it
017: * contains. The privileges contained by an aggregate privilege may themselves
018: * be aggregate privileges if the resulting privilege graph is acyclic.
019: * <p/>
020: * A privilege may be an abstract privilege. Abstract privileges cannot
021: * themselves be granted or denied, but can be composed into aggregate privileges
022: * which are granted or denied.
023: * <p/>
024: * A privilege can be both aggregate and abstract.
025: *
026: * @since JCR 2.0
027: */
028: public interface Privilege {
029:
030: /**
031: * A constant representing <code>READ</code>, the privilege to retrieve
032: * a node and get its properties and their values.
033: */
034: public static final String READ = "javax.jcr.security.Privilege.READ";
035:
036: /**
037: * A constant representing <code>MODIFY_PROPERTIES</code>, the privilege
038: * to create, remove and modify the values of the properties of a node.
039: */
040: public static final String MODIFY_PROPERTIES = "javax.jcr.security.Privilege.MODIFY_PROPERTIES";
041:
042: /**
043: * A constant representing <code>ADD_CHILD_NODES</code>, the privilege
044: * to create child nodes of a node.
045: */
046: public static final String ADD_CHILD_NODES = "javax.jcr.security.Privilege.ADD_CHILD_NODES";
047:
048: /**
049: * A constant representing <code>REMOVE_CHILD_NODES</code>, the privilege
050: * to remove child nodes of a node.
051: */
052: public static final String REMOVE_CHILD_NODES = "javax.jcr.security.Privilege.REMOVE_CHILD_NODES";
053:
054: /**
055: * A constant representing <code>WRITE</code>, an aggregate privilege that contains:
056: *<ul>
057: * <li>MODIFY_PROPERTIES</li>
058: * <li>ADD_CHILD_NODES</li>
059: * <li>REMOVE_CHILD_NODES</li>
060: * </ul>
061: */
062: public static final String WRITE = "javax.jcr.security.Privilege.WRITE";
063:
064: /**
065: * A constant representing <code>GET_ACCESS_CONTROL_POLICY</code>, the privilege
066: * to get the access control policy of a node.
067: */
068: public static final String GET_ACCESS_CONTROL_POLICY = "javax.jcr.security.Privilege.GET_ACCESS_CONTROL_POLICY";
069:
070: /**
071: * A constant representing <code>MODIFY_ACCESS_CONTROL_POLICY</code>, the privilege
072: * to modify the access control policies of a node.
073: */
074: public static final String MODIFY_ACCESS_CONTROL_POLICY = "javax.jcr.security.Privilege.MODIFY_ACCESS_CONTROL_POLICY";
075:
076: /**
077: * A constant representing <code>ALL</code>, an aggregate privilege that contains:
078: * <ul>
079: * <li>READ</li>
080: * <li>WRITE</li>
081: * <li>GET_ACCESS_CONTROL</li>
082: * <li>MODIFY_ACCESS_CONTROL</li>
083: * </ul>
084: */
085: public static final String ALL = "javax.jcr.security.Privilege.ALL";
086:
087: /**
088: * Returns the name of this privilege.
089: *
090: * @return the name of this privilege.
091: */
092: String getName();
093:
094: /**
095: * Returns a description of this privilege.
096: *
097: * @return a description of this privilege.
098: */
099: String getDescription();
100:
101: /**
102: * Returns whether this privilege is an abstract privilege.
103: * @return <code>true</code> if this privilege is an abstract privilege;
104: * <code>false</code> otherwise.
105: */
106: boolean isAbstract();
107:
108: /**
109: * Returns whether this privilege is an aggregate privilege.
110: * @return <code>true</code> if this privilege is an aggregate privilege;
111: * <code>false</code> otherwise.
112: */
113: boolean isAggregate();
114:
115: /**
116: * If this privilege is an aggregate privilege, returns the privileges directly
117: * contained by the aggregate privilege. Otherwise returns an empty array.
118: *
119: * @return an array of <code>Privilege</code>s
120: */
121: Privilege[] getDeclaredAggregatePrivileges();
122:
123: /**
124: * If this privilege is an aggregate privilege, returns the privileges it
125: * contains, the privileges contained by any aggregate privileges among
126: * those, and so on (the transitive closure of privileges contained by this
127: * privilege). Otherwise returns an empty array.
128: *
129: * @return an array of <code>Privilege</code>s
130: */
131: Privilege[] getAggregatePrivileges();
132: }
|