Attempt at a metadata generation handler.
[shibboleth/sp.git] / shibsp / handler / Handler.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file shibsp/handler/Handler.h
19  * 
20  * Pluggable runtime functionality that implement protocols and services 
21  */
22
23 #ifndef __shibsp_handler_h__
24 #define __shibsp_handler_h__
25
26 #include <shibsp/util/PropertySet.h>
27 #ifndef SHIBSP_LITE
28 # include <saml/saml2/metadata/Metadata.h>
29 #endif
30
31 namespace shibsp {
32
33     class SHIBSP_API SPRequest;
34
35     /**
36      * Pluggable runtime functionality that implement protocols and services
37      */
38     class SHIBSP_API Handler : public virtual PropertySet
39     {
40         MAKE_NONCOPYABLE(Handler);
41     protected:
42         Handler() {}
43     public:
44         virtual ~Handler() {}
45
46         /**
47          * Executes handler functionality as an incoming request.
48          * 
49          * <p>Handlers can be run either directly by incoming web requests
50          * or indirectly/implicitly during other SP processing.
51          * 
52          * @param request   SP request context
53          * @param isHandler true iff executing in the context of a direct handler invocation
54          * @return  a pair containing a "request completed" indicator and a server-specific response code
55          */
56         virtual std::pair<bool,long> run(SPRequest& request, bool isHandler=true) const=0;
57
58 #ifndef SHIBSP_LITE
59         /**
60          * Generates and/or modifies metadata reflecting the handler.
61          *
62          * <p>The default implementation does nothing.
63          *
64          * @param role          metadata role to decorate
65          * @param handlerURL    base location of handler's endpoint
66          */
67         virtual void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const {
68         }
69 #endif
70     };
71     
72     /** Registers Handler implementations. */
73     void SHIBSP_API registerHandlers();
74 };
75
76 #endif /* __shibsp_handler_h__ */