01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.lenya.ac;
20:
21: /**
22: * A policy assigns roles to accreditables using credentials.
23: * Additionally, SSL protection is defined.
24: *
25: * @version $Id: Policy.java 479620 2006-11-27 14:02:13Z andreas $
26: */
27: public interface Policy {
28:
29: /**
30: * The identity was not matched in this policy.
31: */
32: int RESULT_NOT_MATCHED = 0;
33:
34: /**
35: * The role is denied for the identity.
36: */
37: int RESULT_DENIED = 1;
38:
39: /**
40: * The role is granted for the identity.
41: */
42: int RESULT_GRANTED = 2;
43:
44: /**
45: * Checks if a certain role is granted for a certain policy.
46: * @param identity The identity.
47: * @param role The role to check.
48: * @return A result code.
49: * @throws AccessControlException when something went wrong.
50: */
51: int check(Identity identity, Role role)
52: throws AccessControlException;
53:
54: /**
55: * Returns if this policy requires SSL protection.
56: * @return A boolean value.
57: * @throws AccessControlException when something went wrong.
58: */
59: boolean isSSLProtected() throws AccessControlException;
60:
61: /**
62: * Returns if the policy is empty. A policy is empty if it does
63: * not contain any credentials.
64: * @return A boolean value.
65: * @throws AccessControlException when something went wrong.
66: */
67: boolean isEmpty() throws AccessControlException;
68:
69: /**
70: * @param identity The identity.
71: * @return All credentials defined by this policy for this identity.
72: * @throws AccessControlException if an error occurs.
73: */
74: Credential[] getCredentials(Identity identity)
75: throws AccessControlException;
76:
77: /**
78: * @return All credentials defined by this policy.
79: * @throws AccessControlException if an error occurs.
80: */
81: Credential[] getCredentials() throws AccessControlException;
82:
83: }
|