1 /* 2 * $Id: Permission.java,v 1.2 2004/07/24 00:16:22 benjmestrallet Exp $ 3 * 4 * Copyright 2002-2004 Day Management AG, Switzerland. 5 * 6 * Licensed under the Day RI License, Version 2.0 (the "License"), 7 * as a reference implementation of the following specification: 8 * 9 * Content Repository API for Java Technology, revision 0.12 10 * <http://www.jcp.org/en/jsr/detail?id=170> 11 * 12 * You may not use this file except in compliance with the License. 13 * You may obtain a copy of the License files at 14 * 15 * http://www.day.com/content/en/licenses/day-ri-license-2.0 16 * http://www.apache.org/licenses/LICENSE-2.0 17 * 18 * Unless required by applicable law or agreed to in writing, software 19 * distributed under the License is distributed on an "AS IS" BASIS, 20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 * See the License for the specific language governing permissions and 22 * limitations under the License. 23 */ 24 package javax.jcr.access; 25 26 /** 27 * The permissions used by <code>{@link javax.jcr.access.AccessManager}</code>. 28 * <p/> 29 * <b>Level 2 only</b> 30 * <p/> 31 * <p>This interface defines the following permissions: 32 * <UL> 33 * <LI>ADD_NODE 34 * <LI>SET_PROPERTY 35 * <LI>REMOVE_ITEM 36 * <LI>READ_ITEM 37 * </UL> 38 * <b>Level 2 only</b></code> 39 * <p/> 40 * Given a particular ticket, a particular <code>Permission</code> is either 41 * <code>true</code> or <code>false</code> of a particular node or property. 42 * The possible permissions and their meanings are: 43 * <dl> 44 * <dt><code>Permission.ADD_NODE</code></dt> 45 * <dd> 46 * If <code>true</code> of node <code>N</code> then <code>N.addNode</code> 47 * is allowed. If <code>false</code> then it will throw an 48 * <code>AccessDeniedException</code> on <code>save</code>. Always 49 * <code>false</code> of properties. 50 * </dd> 51 * <dt><code>Permission.SET_PROPERTY</code></dt> 52 * <dd> 53 * If <code>true</code> of node <code>N</code> then <code>N.setProperty</code> 54 * is allowed. If <code>true</code> of property <code>P</code> then 55 * <code>P.setValue</code> is allowed. If <code>false</code> then these methods 56 * will throw an <code>AccessDeniedException</code> on <code>save</code>. 57 * </dd> 58 * <dt><code>Permission.REMOVE_ITEM</code></dt> 59 * <dd> 60 * If <code>true</code> of item <code>I</code>, where the path of <code>I</code> 61 * relative to <code>N</code> is <code>T</code>, then <code>N.remove(T)</code> 62 * is allowed. If <code>false</code>, then it will cause an 63 * <code>AccessControlException</code> on <code>save</code>. 64 * </dd> 65 * <dt><code>Permission.READ_ITEM</code></dt> 66 * <dd> 67 * If <code>true</code> of property <code>P</code>, where the path of 68 * <code>P</code> relative to <code>N</code> is <code>T</code>, then 69 * <code>N.getProperty(T)</code> is allowed. If <code>false</code> then it 70 * throws an <code>PathNotFoundException</code>.<p> 71 * If <code>true</code> of node <code>M</code>, where the path of 72 * <code>M</code> relative to <code>N</code> is <code>T</code>, then 73 * <code>N.getNode(T)</code> is allowed. If <code>false</code> then it 74 * throws an <code>PathNotFoundException</code>. 75 * </dd> 76 * </dl> 77 * 78 * @author Peeter Piegaze 79 * @author Stefan Guggisberg 80 */ 81 public interface Permission { 82 83 /** 84 * The permissions defined by the JCR standard. Each constant is a 85 * power of 2 (i.e. sets of permissions can be encoded as a bitmask 86 * in a <code>long</code> value). 87 */ 88 public static final long ADD_NODE = 1; 89 public static final long SET_PROPERTY = 2; 90 public static final long REMOVE_ITEM = 4; 91 public static final long READ_ITEM = 8; 92 93 /** 94 * Returns the numerical constant identifying this permission. This value 95 * is always a power of 2 ((i.e. sets of permissions can be encoded as 96 * a bitmask in a <code>long</code> value). 97 * 98 * @return the numerical value 99 * @see AccessManager#getSupportedPermissions 100 */ 101 public long getValue(); 102 103 /** 104 * Returns the descriptive name of this permission. 105 * 106 * @return the name 107 * @see AccessManager#getSupportedPermissions 108 */ 109 public String getName(); 110 } 111 112