Use shibboleth-sp as package name for compatibility.
[shibboleth/cpp-sp.git] / shibsp / AccessControl.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * @file shibsp/AccessControl.h
23  *
24  * Interface to an access control plugin
25  */
26
27 #ifndef __shibsp_acl_h__
28 #define __shibsp_acl_h__
29
30 #include <shibsp/base.h>
31 #include <xmltooling/Lockable.h>
32
33 namespace shibsp {
34
35     class SHIBSP_API Session;
36     class SHIBSP_API SPRequest;
37
38      /**
39      * Interface to an access control plugin
40      *
41      * Access control plugins return authorization decisions based on the intersection
42      * of the resource request and the active session. They can be implemented through
43      * cross-platform or platform-specific mechanisms.
44      */
45     class SHIBSP_API AccessControl : public virtual xmltooling::Lockable
46     {
47         MAKE_NONCOPYABLE(AccessControl);
48     protected:
49         AccessControl();
50     public:
51         virtual ~AccessControl();
52
53         /**
54          * Possible results from an access control decision.
55          */
56         enum aclresult_t {
57             shib_acl_true,
58             shib_acl_false,
59             shib_acl_indeterminate
60         };
61
62         /**
63          * Perform an authorization check.
64          *
65          * @param request   SP request information
66          * @param session   active user session, if any
67          * @return true iff access should be granted
68          */
69         virtual aclresult_t authorized(const SPRequest& request, const Session* session) const=0;
70     };
71
72     /**
73      * Registers AccessControl classes into the runtime.
74      */
75     void SHIBSP_API registerAccessControls();
76
77     /** Chains together multiple plugins. */
78     #define CHAINING_ACCESS_CONTROL "Chaining"
79
80     /** AccessControl based on rudimentary XML syntax. */
81     #define XML_ACCESS_CONTROL      "XML"
82
83     /** Reserved for Apache-style .htaccess support. */
84     #define HT_ACCESS_CONTROL       "htaccess"
85 };
86
87 #endif /* __shibsp_acl_h__ */