/*
- * Copyright 2001-2008 Internet2
+ * Copyright 2001-2009 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <xsec/enc/XSECCryptoX509.hpp>
namespace xmltooling {
+ class XMLTOOL_API Credential;
+
/**
* A helper class for working with keys, certificates, etc.
*/
* @param key2 second key to compare
* @return true iff the keys match
*/
- static bool matches(const XSECCryptoKey* key1, const XSECCryptoKey* key2);
+ static bool matches(const XSECCryptoKey& key1, const XSECCryptoKey& key2);
+
+ /**
+ * Returns the base64-encoded DER encoding of a public key in SubjectPublicKeyInfo format.
+ *
+ * @param cred the credential containing the key to encode
+ * @param hash if true, the DER encoded data is hashed with SHA-1 before base64 encoding
+ * @param nowrap if true, any linefeeds will be stripped from the result
+ * @return the base64 encoded key value
+ */
+ static std::string getDEREncoding(const Credential& cred, bool hash=false, bool nowrap=true);
+
+ /**
+ * Returns the base64-encoded DER encoding of a public key in SubjectPublicKeyInfo format.
+ *
+ * @param key the key to encode
+ * @param hash if true, the DER encoded data is hashed with SHA-1 before base64 encoding
+ * @param nowrap if true, any linefeeds will be stripped from the result
+ * @return the base64 encoded key value
+ */
+ static std::string getDEREncoding(const XSECCryptoKey& key, bool hash=false, bool nowrap=true);
+
+ /**
+ * Returns the base64-encoded DER encoding of a certifiate's public key in SubjectPublicKeyInfo format.
+ *
+ * @param cert the certificate's key to encode
+ * @param hash if true, the DER encoded data is hashed with SHA-1 before base64 encoding
+ * @param nowrap if true, any linefeeds will be stripped from the result
+ * @return the base64 encoded key value
+ */
+ static std::string getDEREncoding(const XSECCryptoX509& cert, bool hash=false, bool nowrap=true);
};
};