1 /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.springframework.security.acls;
16
17 import java.io.Serializable;
18
19 /**
20 * Represents a permission granted to a {@link org.springframework.security.acls.sid.Sid Sid} for a given domain object.
21 *
22 * @author Ben Alex
23 * @version $Id: Permission.java 2864 2008-04-05 05:58:11Z benalex $
24 */
25 public interface Permission extends Serializable {
26 //~ Static fields/initializers =====================================================================================
27
28 char RESERVED_ON = '~';
29 char RESERVED_OFF = '.';
30 String THIRTY_TWO_RESERVED_OFF = "................................";
31
32 //~ Methods ========================================================================================================
33
34 /**
35 * Returns the bits that represents the permission.
36 *
37 * @return the bits that represent the permission
38 */
39 int getMask();
40
41 /**
42 * Returns a 32-character long bit pattern <code>String</code> representing this permission.
43 * <p>
44 * Implementations are free to format the pattern as they see fit, although under no circumstances may
45 * {@link #RESERVED_OFF} or {@link #RESERVED_ON} be used within the pattern. An exemption is in the case of
46 * {@link #RESERVED_OFF} which is used to denote a bit that is off (clear).
47 * Implementations may also elect to use {@link #RESERVED_ON} internally for computation purposes,
48 * although this method may not return any <code>String</code> containing {@link #RESERVED_ON}.
49 * </p>
50 * <p>The returned String must be 32 characters in length.</p>
51 * <p>This method is only used for user interface and logging purposes. It is not used in any permission
52 * calculations. Therefore, duplication of characters within the output is permitted.</p>
53 *
54 * @return a 32-character bit pattern
55 */
56 String getPattern();
57 }