2 * Copyright 2001-2010 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/Credential.h
20 * Wraps keys and related functionality.
23 #if !defined(__xmltooling_cred_h__) && !defined(XMLTOOLING_NO_XMLSEC)
24 #define __xmltooling_cred_h__
26 #include <xmltooling/base.h>
33 namespace xmlsignature {
34 class XMLTOOL_API KeyInfo;
37 namespace xmltooling {
39 class XMLTOOL_API CredentialCriteria;
40 class XMLTOOL_API CredentialContext;
43 * Wraps keys and related functionality.
45 * <p>Shared credential implementations should implement reference counting
46 * and honor any locking parameters to ensure appropriate synchronization.
48 class XMLTOOL_API Credential
50 MAKE_NONCOPYABLE(Credential);
55 virtual ~Credential();
58 * Bitmask constants for limiting resolution process inside a CredentialResolver.
66 * Bitmask of use cases for credentials.
69 UNSPECIFIED_CREDENTIAL = 0,
70 SIGNING_CREDENTIAL = 1,
72 ENCRYPTION_CREDENTIAL = 4
76 * Bitmask of supported KeyInfo content to generate.
79 KEYINFO_KEY_VALUE = 1,
84 * Get credential usage types.
86 * @return the usage bitmask
88 virtual unsigned int getUsage() const=0;
91 * Returns an algorithm identifier for the Credential.
93 * @return the Credential algorithm, or nullptr if indeterminate
95 virtual const char* getAlgorithm() const=0;
98 * Returns the size of the key in bits.
100 * @return the key size, or 0 if indeterminate
102 virtual unsigned int getKeySize() const=0;
105 * Returns a secret or private key to use for signing or decryption operations.
107 * @return a secret or private key
109 virtual XSECCryptoKey* getPrivateKey() const=0;
112 * Returns a secret or public key to use for verification or encryption operations.
114 * @return a secret or public key
116 virtual XSECCryptoKey* getPublicKey() const=0;
119 * Returns names representing the Credential.
121 * <p>Names should be unique in the context of the comparisons against CredentialCriteria
122 * that deployments expect to see.
124 * @return a sorted set of names
126 virtual const std::set<std::string>& getKeyNames() const=0;
129 * Returns a ds:KeyInfo object representing the Credential for use in
130 * communicating with other entities.
132 * @param compact true iff the communication medium is such that only compact forms should be included
133 * @return a KeyInfo object, which must be freed by the caller
135 virtual xmlsignature::KeyInfo* getKeyInfo(bool compact=false) const=0;
138 * Get the credential context information, which provides additional information
139 * specific to the context in which the credential was resolved.
141 * @return resolution context of the credential
143 virtual const CredentialContext* getCredentalContext() const;
147 #endif /* __xmltooling_cred_h__ */