Update copyright.
[shibboleth/cpp-xmltooling.git] / xmltooling / security / KeyInfoSource.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 xmltooling/security/KeyInfoSource.h
19  * 
20  * Interface for objects that can supply KeyInfo objects to a TrustEngine
21  * via the KeyInfoIterator interface.
22  */
23
24 #if !defined(__xmltooling_keysource_h__) && !defined(XMLTOOLING_NO_XMLSEC)
25 #define __xmltooling_keysource_h__
26
27 #include <xmltooling/base.h>
28 #include <string>
29
30 namespace xmlsignature {
31     class XMLTOOL_API KeyInfo;
32 };
33
34 namespace xmltooling {
35
36     /**
37      * Callback interface to supply KeyInfo objects to a TrustEngine.
38      * Applications can adapt TrustEngines to their environment by supplying
39      * implementations of this interface. 
40      */
41     class XMLTOOL_API KeyInfoIterator {
42         MAKE_NONCOPYABLE(KeyInfoIterator);
43     protected:
44         KeyInfoIterator() {}
45     public:
46         virtual ~KeyInfoIterator() {}
47         
48         /**
49          * Indicates whether additional KeyInfo objects are available.
50          * 
51          * @return true iff another KeyInfo object can be fetched
52          */
53         virtual bool hasNext() const=0;
54         
55         /**
56          * Returns the next KeyInfo object available.
57          * 
58          * @return the next KeyInfo object, or NULL if none are left
59          */
60         virtual const xmlsignature::KeyInfo* next()=0;
61     };
62
63     /**
64      * Interface for objects that can supply KeyInfo objects to a TrustEngine
65      * via the KeyInfoIterator interface.
66      */
67     class XMLTOOL_API KeyInfoSource {
68     protected:
69         KeyInfoSource() {}
70     public:
71         virtual ~KeyInfoSource() {}
72
73         /**
74          * Returns the name of this source of keys, for example a peer entity name
75          * or a principal's name.
76          * 
77          * @return  name of key source, or empty string
78          */
79         virtual std::string getName() const=0;
80         
81         /**
82          * Provides access to the KeyInfo information associated with the source.
83          * The caller must free the returned interface when finished with it.
84          * 
85          * @return interface for obtaining KeyInfo data  
86          */
87         virtual KeyInfoIterator* getKeyInfoIterator() const=0;
88     };
89
90 };
91
92 #endif /* __xmltooling_keysource_h__ */