Source code: org/acegisecurity/taglibs/velocity/Authz.java
1 /* Copyright 2004, 2005 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
16 package org.acegisecurity.taglibs.velocity;
17
18 import org.acegisecurity.Authentication;
19
20 import org.acegisecurity.acl.AclManager;
21
22 import org.acegisecurity.taglibs.authz.AclTag;
23 import org.acegisecurity.taglibs.authz.AuthenticationTag;
24 import org.acegisecurity.taglibs.authz.AuthorizeTag;
25
26 import org.acegisecurity.userdetails.UserDetails;
27
28 import org.springframework.context.ApplicationContext;
29
30
31 /**
32 * Wrapper the implementation of Acegi Security for Spring JSP tag includes:
33 * {@link AuthenticationTag}, {@link AclTag}, {@link AuthorizeTag}
34 *
35 * @author Wang Qi
36 * @version $Id: Authz.java,v 1.1 2005/12/01 09:38:50 benalex Exp $
37 */
38 public interface Authz {
39 //~ Methods ================================================================
40
41 /**
42 * all the listed roles must be granted to return true, otherwise fasle;
43 *
44 * @param roles - comma separate GrantedAuthoritys
45 *
46 * @return granted (true|false)
47 */
48 public boolean allGranted(String roles);
49
50 /**
51 * any the listed roles must be granted to return true, otherwise fasle;
52 *
53 * @param roles - comma separate GrantedAuthoritys
54 *
55 * @return granted (true|false)
56 */
57 public boolean anyGranted(String roles);
58
59 /**
60 * set Spring application context which contains acegi related bean
61 *
62 * @return DOCUMENT ME!
63 */
64 public ApplicationContext getAppCtx();
65
66 /**
67 * return the principal's name, supports the various type of principals
68 * that can exist in the {@link Authentication} object, such as a String
69 * or {@link UserDetails} instance
70 *
71 * @return string representation of principal's name
72 */
73 public String getPrincipal();
74
75 /**
76 * return true if the principal holds either permission specified for the
77 * provided domain object
78 *
79 * <P>
80 * Only works with permissions that are subclasses of {@link
81 * net.sf.acegisecurity.acl.basic.AbstractBasicAclEntry}.
82 * </p>
83 *
84 * <p>
85 * For this class to operate it must be able to access the application
86 * context via the <code>WebApplicationContextUtils</code> and locate an
87 * {@link AclManager}.
88 * </p>
89 *
90 * @param domainObject - domain object need acl control
91 * @param permissions - comma separate integer permissions
92 *
93 * @return got acl permission (true|false)
94 */
95 public boolean hasPermission(Object domainObject, String permissions);
96
97 /**
98 * none the listed roles must be granted to return true, otherwise fasle;
99 *
100 * @param roles - comma separate GrantedAuthoritys
101 *
102 * @return granted (true|false)
103 */
104 public boolean noneGranted(String roles);
105
106 /**
107 * get Spring application context which contains acegi related bean
108 *
109 * @param appCtx DOCUMENT ME!
110 */
111 public void setAppCtx(ApplicationContext appCtx);
112 }