1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  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,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 module hunt.shiro.authz.annotation.RequiresPermissions;
20 
21 import hunt.shiro.authz.annotation.Logical;
22 
23 // import java.lang.annotation.ElementType;
24 // import java.lang.annotation.Retention;
25 // import java.lang.annotation.RetentionPolicy;
26 // import java.lang.annotation.Target;
27 
28 /**
29  * <p>
30  * Requires the current executor's Subject to imply a particular permission in
31  * order to execute the annotated method.  If the executor's associated
32  * {@link hunt.shiro.subject.Subject Subject} determines that the
33  * executor does not imply the specified permission, the method will not be executed.
34  * </p>
35  *
36  * <p>For example, this declaration:
37  * <p/>
38  * <code>&#64;RequiresPermissions( {"file:read", "write:aFile.txt"} )<br/>
39  * void someMethod();</code>
40  * <p/>
41  * indicates the current user must be able to both <tt>read</tt> and <tt>write</tt>
42  * to the file <tt>aFile.txt</tt> in order for the <tt>someMethod()</tt> to execute, otherwise
43  * an {@link hunt.shiro.authz.AuthorizationException AuthorizationException} will be thrown.
44  *
45  * @see hunt.shiro.subject.Subject#checkPermission
46  */
47 // @Target({ElementType.TYPE, ElementType.METHOD})
48 // @Retention(RetentionPolicy.RUNTIME)
49 // public @interface RequiresPermissions {
50 public interface RequiresPermissions {
51     /**
52      * The permission string which will be passed to {@link hunt.shiro.subject.Subject#isPermitted(string)}
53      * to determine if the user is allowed to invoke the code protected by this annotation.
54      */
55     string[] value();
56     
57     /**
58      * The logical operation for the permission checks in case multiple roles are specified. AND is the default
59      */
60     //Logical logical() default Logical.AND; 
61     Logical logical(); 
62 
63 }
64