This project has retired. For details please refer to its Attic page.
Resource xref
View Javadoc

1   package org.apache.archiva.redback.rbac;
2   
3   /*
4    * Copyright 2001-2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  /**
20   * Resource
21   *
22   * Resources are things that can be paired up with operations inside of a
23   * permission.
24   *
25   * Rbac doesn't strictly specify what a resource (or Object) is, so there are a
26   * couple of variations planned for resources.
27   *
28   * Initially the resource is simply a string representaton of whatever you desire
29   * to match up to an operation.  Eventually we want to support different types of
30   * expression evaluation for these resources, like a tuple resource.  *-* where
31   * wildcards can be used on the resource definition to streamline the assigning of
32   * permissions for _large_ sets of things.
33   *
34   * @author Jesse McConnell <jmcconnell@apache.org>
35   * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
36   *
37   */
38  public interface Resource
39  {
40      /**
41       * Resource identifier refering to all objects.
42       */
43      public static final String GLOBAL = "*";
44  
45      /**
46       * Resource identifier refering to no objects.
47       */
48      public static final String NULL = "-";
49  
50      /**
51       * Get The string identifier for an operation.
52       *
53       * NOTE: This field is considered the Primary Key for this object.
54       */
55      public String getIdentifier();
56  
57      /**
58       * true if the identifer is a pattern that is to be evaluated, for
59       * example x.* could match x.a or x.b and x.** could match x.foo
60       *
61       * Jesse: See {@link #setPattern(boolean)}
62       *
63       */
64      public boolean isPattern();
65  
66      /**
67       * Set The string identifier for an operation.
68       *
69       * NOTE: This field is considered the Primary Key for this object.
70       * 
71       * @param identifier
72       */
73      public void setIdentifier( String identifier );
74  
75      /**
76       * true if the identifer is a pattern that is to be evaluated, for
77       * example x.* could match x.a or x.b and x.** could match x.foo
78       *
79       * TODO is this even a good idea?
80       * TODO we could look for a character like '*' or a string starting with "%/" to indicate if this is a pattern or not.
81       * 
82       * @param pattern
83       */
84      public void setPattern( boolean pattern );
85  
86      /**
87       * Test to see if the object is a permanent object or not.
88       * 
89       * @return true if the object is permanent.
90       */
91      public boolean isPermanent();
92  
93      /**
94       * Set flag indicating if the object is a permanent object or not.
95       * 
96       * @param permanent true if the object is permanent.
97       */
98      public void setPermanent( boolean permanent );
99  }