2 * Copyright 2001-2006 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
18 * @file KeyResolver.h
\r
20 * Resolves keys based on KeyInfo information or other external factors.
\r
23 #if !defined(__xmltooling_keyres_h__) && !defined(XMLTOOLING_NO_XMLSEC)
\r
24 #define __xmltooling_keyres_h__
\r
26 #include <xmltooling/signature/KeyInfo.h>
\r
28 #include <xsec/dsig/DSIGKeyInfoList.hpp>
\r
29 #include <xsec/enc/XSECCryptoKey.hpp>
\r
31 namespace xmlsignature {
\r
34 * An API for resolving keys.
\r
36 class XMLTOOL_API KeyResolver {
\r
39 * Constructor based on a single externally supplied key.
\r
40 * The key will be destroyed when the resolver is.
\r
42 * @param key external key
\r
44 KeyResolver(XSECCryptoKey* key=NULL) : m_key(key) {}
\r
46 virtual ~KeyResolver() {
\r
51 * Returns a key based on the supplied KeyInfo information.
\r
52 * The caller must delete the key when done with it.
\r
54 * @param keyInfo the key information
\r
55 * @return the resolved key
\r
57 virtual XSECCryptoKey* resolveKey(KeyInfo* keyInfo) {
\r
58 return m_key ? m_key->clone() : NULL;
\r
62 * Returns a key based on the supplied KeyInfo information.
\r
63 * The caller must delete the key when done with it.
\r
65 * @param keyInfo the key information
\r
66 * @return the resolved key
\r
68 virtual XSECCryptoKey* resolveKey(DSIGKeyInfoList* keyInfo=NULL) {
\r
69 return m_key ? m_key->clone() : NULL;
\r
73 * Creates a copy of the resolver.
\r
75 * @return the cloned resolver
\r
77 virtual KeyResolver* clone() const {
\r
78 return new KeyResolver(m_key ? m_key->clone() : NULL);
\r
82 XSECCryptoKey* m_key;
\r
87 #endif /* __xmltooling_keyres_h__ */
\r