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 xmltooling/security/CredentialCriteria.h
20 * Class for specifying criteria by which a CredentialResolver should resolve credentials.
23 #if !defined(__xmltooling_credcrit_h__) && !defined(XMLTOOLING_NO_XMLSEC)
24 #define __xmltooling_credcrit_h__
26 #include <xmltooling/unicode.h>
27 #include <xmltooling/signature/KeyInfo.h>
28 #include <xmltooling/signature/Signature.h>
31 #include <xsec/dsig/DSIGKeyInfoList.hpp>
32 #include <xsec/dsig/DSIGKeyInfoName.hpp>
34 namespace xmltooling {
37 * Class for specifying criteria by which a CredentialResolver should resolve credentials.
39 class XMLTOOL_API CredentialCriteria
41 MAKE_NONCOPYABLE(CredentialCriteria);
43 CredentialCriteria() : m_keyUsage(UNSPECIFIED_CREDENTIAL), m_keyInfo(NULL), m_nativeKeyInfo(NULL) {}
44 virtual ~CredentialCriteria() {}
47 UNSPECIFIED_CREDENTIAL,
54 * Get the key usage criteria.
58 UsageType getUsage() const {
63 * Set the key usage criteria.
65 * @param usage the usage to set
67 void setUsage(UsageType usage) {
72 * Get the peer name criteria.
74 * @return the peer name
76 const char* getPeerName() const {
77 return m_peerName.c_str();
81 * Set the peer name criteria.
83 * @param peerName peer name to set
85 void setPeerName(const char* peerName) {
88 m_peerName = peerName;
92 * Get the key algorithm criteria.
94 * @return returns the keyAlgorithm.
96 const char* getKeyAlgorithm() const {
97 return m_keyAlgorithm.c_str();
101 * Set the key algorithm criteria.
103 * @param keyAlgorithm The keyAlgorithm to set.
105 void setKeyAlgorithm(const char* keyAlgorithm) {
106 m_keyAlgorithm.erase();
108 m_keyAlgorithm = keyAlgorithm;
112 * Get the key name criteria.
114 * @return the key name
116 const char* getKeyName() const {
117 return m_keyName.c_str();
121 * Set the key name criteria.
123 * @param keyName key name to set
125 void setKeyName(const char* keyName) {
132 * Gets the KeyInfo criteria.
134 * @return the KeyInfo criteria
136 const xmlsignature::KeyInfo* getKeyInfo() const {
141 * Sets the KeyInfo criteria.
143 * @param keyInfo the KeyInfo criteria
145 void setKeyInfo(const xmlsignature::KeyInfo* keyInfo) {
150 * Gets the native KeyInfo criteria.
152 * @return the native KeyInfo criteria
154 DSIGKeyInfoList* getNativeKeyInfo() const {
155 return m_nativeKeyInfo;
159 * Sets the KeyInfo criteria.
161 * @param keyInfo the KeyInfo criteria
163 void setNativeKeyInfo(DSIGKeyInfoList* keyInfo) {
164 m_nativeKeyInfo = keyInfo;
167 void setSignature(const xmlsignature::Signature& sig) {
168 xmlsignature::KeyInfo* k = sig.getKeyInfo();
170 return setKeyInfo(k);
171 DSIGSignature* dsig = sig.getXMLSignature();
173 setNativeKeyInfo(dsig->getKeyInfoList());
177 UsageType m_keyUsage;
178 std::string m_peerName,m_keyAlgorithm,m_keyName;
179 const xmlsignature::KeyInfo* m_keyInfo;
180 DSIGKeyInfoList* m_nativeKeyInfo;
184 #endif /* __xmltooling_credcrit_h__ */