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/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>
27 #include <xsec/enc/XSECCryptoKey.hpp>
32 namespace xmlsignature {
33 class XMLTOOL_API KeyInfo;
36 namespace xmltooling {
38 class XMLTOOL_API CredentialCriteria;
39 class XMLTOOL_API CredentialContext;
42 * Wraps keys and related functionality.
44 * <p>Shared credential implementations should implement reference counting
45 * and honor any locking parameters to ensure appropriate synchronization.
47 class XMLTOOL_API Credential
49 MAKE_NONCOPYABLE(Credential);
54 virtual ~Credential() {}
57 * Bitmask constants for limiting resolution process inside a CredentialResolver.
65 * Bitmask of use cases for credentials.
68 UNSPECIFIED_CREDENTIAL = 0,
69 SIGNING_CREDENTIAL = 1,
71 ENCRYPTION_CREDENTIAL = 4
75 * Get credential usage types.
77 * @return the usage bitmask
79 virtual unsigned int getUsage() const=0;
82 * Returns an algorithm identifier for the Credential.
84 * @return the Credential algorithm, or NULL if indeterminate
86 virtual const char* getAlgorithm() const=0;
89 * Returns the size of the key.
91 * @return the key size, or 0 if indeterminate
93 virtual unsigned int getKeySize() const=0;
96 * Returns a secret or private key to use for signing or decryption operations.
98 * @return a secret or private key
100 virtual XSECCryptoKey* getPrivateKey() const=0;
103 * Returns a secret or public key to use for verification or encryption operations.
105 * @return a secret or public key
107 virtual XSECCryptoKey* getPublicKey() const=0;
110 * Returns names representing the Credential.
112 * <p>Names should be unique in the context of the comparisons against CredentialCriteria
113 * that deployments expect to see.
115 * @return a sorted set of names
117 virtual const std::set<std::string>& getKeyNames() const=0;
120 * Returns a ds:KeyInfo object representing the Credential for use in
121 * communicating with other entities.
123 * @param compact true iff the communication medium is such that only compact forms should be included
124 * @return a KeyInfo object, which must be freed by the caller
126 virtual xmlsignature::KeyInfo* getKeyInfo(bool compact=false) const=0;
129 * Get the credential context information, which provides additional information
130 * specific to the context in which the credential was resolved.
132 * @return resolution context of the credential
134 virtual const CredentialContext* getCredentalContext() const {
140 #endif /* __xmltooling_cred_h__ */