Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
RequiresPermissions |
|
| 0.0;0 |
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 | package org.apache.shiro.authz.annotation; | |
20 | ||
21 | import java.lang.annotation.ElementType; | |
22 | import java.lang.annotation.Retention; | |
23 | import java.lang.annotation.RetentionPolicy; | |
24 | import java.lang.annotation.Target; | |
25 | ||
26 | /** | |
27 | * <p> | |
28 | * Requires the current executor's Subject to imply a particular permission in | |
29 | * order to execute the annotated method. If the executor's associated | |
30 | * {@link org.apache.shiro.subject.Subject Subject} determines that the | |
31 | * executor does not imply the specified permission, the method will not be executed. | |
32 | * </p> | |
33 | * | |
34 | * <p>For example, this declaration: | |
35 | * <p/> | |
36 | * <code>@RequiresPermissions( {"file:read", "write:aFile.txt"} )<br/> | |
37 | * void someMethod();</code> | |
38 | * <p/> | |
39 | * indicates the current user must be able to both <tt>read</tt> and <tt>write</tt> | |
40 | * to the file <tt>aFile.txt</tt> in order for the <tt>someMethod()</tt> to execute, otherwise | |
41 | * an {@link org.apache.shiro.authz.AuthorizationException AuthorizationException} will be thrown. | |
42 | * | |
43 | * @see org.apache.shiro.subject.Subject#checkPermission | |
44 | * @since 0.1 | |
45 | */ | |
46 | @Target({ElementType.TYPE, ElementType.METHOD}) | |
47 | @Retention(RetentionPolicy.RUNTIME) | |
48 | public @interface RequiresPermissions { | |
49 | ||
50 | /** | |
51 | * The permission string which will be passed to {@link org.apache.shiro.subject.Subject#isPermitted(String)} | |
52 | * to determine if the user is allowed to invoke the code protected by this annotation. | |
53 | */ | |
54 | String[] value(); | |
55 | ||
56 | /** | |
57 | * The logical operation for the permission checks in case multiple roles are specified. AND is the default | |
58 | * @since 1.1.0 | |
59 | */ | |
60 | Logical logical() default Logical.AND; | |
61 | ||
62 | } | |
63 |