Use shibboleth-sp as package name for compatibility.
[shibboleth/cpp-sp.git] / shibsp / SessionCacheEx.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/SessionCacheEx.h
23  * 
24  * Extended SessionCache API with additional capabilities
25  */
26
27 #ifndef __shibsp_sessioncacheex_h__
28 #define __shibsp_sessioncacheex_h__
29
30 #include <shibsp/SessionCache.h>
31
32 namespace shibsp {
33
34     /**
35      * Extended SessionCache API with additional capabilities
36      */
37     class SHIBSP_API SessionCacheEx : public SessionCache
38     {
39     protected:
40         SessionCacheEx();
41     public:
42         virtual ~SessionCacheEx();
43         
44 #ifndef SHIBSP_LITE
45         /**
46          * Returns active sessions that match particular parameters and records the logout
47          * to prevent race conditions.
48          *
49          * <p>On exit, the mapping between these sessions and the associated information MAY be
50          * removed by the cache, so subsequent calls to this method may not return anything.
51          *
52          * <p>Until logout expiration, any attempt to create a session with the same parameters
53          * will be blocked by the cache.
54          * 
55          * @param application   reference to Application that owns the session(s)
56          * @param issuer        source of session(s)
57          * @param nameid        name identifier associated with the session(s) to terminate
58          * @param indexes       indexes of sessions, or nullptr for all sessions associated with other parameters
59          * @param expires       logout expiration
60          * @param sessions      on exit, contains the IDs of the matching sessions found
61          */
62         virtual std::vector<std::string>::size_type logout(
63             const Application& application,
64             const opensaml::saml2md::EntityDescriptor* issuer,
65             const opensaml::saml2::NameID& nameid,
66             const std::set<std::string>* indexes,
67             time_t expires,
68             std::vector<std::string>& sessions
69             )=0;
70 #endif
71
72         /**
73          * Locates an existing session by ID.
74          * 
75          * <p>If the client address is supplied, then a check will be performed against
76          * the address recorded in the record.
77          * 
78          * @param application   reference to Application that owns the Session
79          * @param key           session key
80          * @param client_addr   network address of client (if known)
81          * @param timeout       inactivity timeout to enforce (0 for none, nullptr to bypass check/update of last access)
82          * @return  pointer to locked Session, or nullptr
83          */
84         virtual Session* find(const Application& application, const char* key, const char* client_addr=nullptr, time_t* timeout=nullptr)=0;
85
86         /**
87          * Deletes an existing session.
88          * 
89          * @param application   reference to Application that owns the Session
90          * @param key           session key
91          */
92         virtual void remove(const Application& application, const char* key)=0;
93     };
94 };
95
96 #endif /* __shibsp_sessioncacheex_h__ */