2 * Copyright 2001-2007 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file SignatureValidator.h
20 * Validator for signatures based on an externally-supplied key
23 #if !defined(__xmltooling_sigval_h__) && !defined(XMLTOOLING_NO_XMLSEC)
24 #define __xmltooling_sigval_h__
26 #include <xmltooling/signature/KeyResolver.h>
27 #include <xmltooling/signature/Signature.h>
28 #include <xmltooling/validation/Validator.h>
30 namespace xmlsignature {
33 * Validator for signatures based on a Key or a KeyResolver
35 class XMLTOOL_API SignatureValidator : public xmltooling::Validator
39 * Constructor using a KeyResolver
41 * @param resolver the key resolver to use, will be freed by Validator
43 SignatureValidator(KeyResolver* resolver) : m_key(NULL), m_resolver(resolver) {
47 * Constructor using a Key
49 * @param key the verification key to use, will be freed by Validator
51 SignatureValidator(XSECCryptoKey* key=NULL) : m_key(key), m_resolver(NULL) {
54 virtual ~SignatureValidator() {
59 virtual void validate(const xmltooling::XMLObject* xmlObject) const;
62 * Type-safe validator.
64 * @param signature object to validate
66 virtual void validate(const Signature* signature) const;
69 * Replace the current Key, if any, with a new one.
71 * @param key the Key to attach
73 void setKey(XSECCryptoKey* key) {
81 * Replace the current KeyResolver, if any, with a new one.
83 * @param resolver the KeyResolver to attach
85 void setKeyResolver(KeyResolver* resolver) {
93 /** Verification key. */
96 /** KeyResolver to use against signature. */
97 KeyResolver* m_resolver;
102 #endif /* __xmltooling_sigval_h__ */