xmltooling  1.5.6
xmltooling::SecurityHelper Class Reference

A helper class for working with keys, certificates, etc. More...

#include <xmltooling/security/SecurityHelper.h>

Static Public Member Functions

static const char * guessEncodingFormat (const char *pathname)
 Access a file to try and guess the encoding format used. More...
 
static XSECCryptoKey * loadKeyFromFile (const char *pathname, const char *format=0, const char *password=0)
 Loads a private key from a local file. More...
 
static std::vector< XSECCryptoX509 * >::size_type loadCertificatesFromFile (std::vector< XSECCryptoX509 * > &certs, const char *pathname, const char *format=0, const char *password=0)
 Loads certificate(s) from a local file. More...
 
static std::vector< XSECCryptoX509CRL * >::size_type loadCRLsFromFile (std::vector< XSECCryptoX509CRL * > &crls, const char *pathname, const char *format=0)
 Loads CRL(s) from a local file. More...
 
static XSECCryptoKey * loadKeyFromURL (SOAPTransport &transport, const char *backing, const char *format=0, const char *password=0)
 Loads a private key from a URL. More...
 
static std::vector< XSECCryptoX509 * >::size_type loadCertificatesFromURL (std::vector< XSECCryptoX509 * > &certs, SOAPTransport &transport, const char *backing, const char *format=0, const char *password=0)
 Loads certificate(s) from a URL. More...
 
static std::vector< XSECCryptoX509CRL * >::size_type loadCRLsFromURL (std::vector< XSECCryptoX509CRL * > &crls, SOAPTransport &transport, const char *backing, const char *format=0)
 Loads CRL(s) from a URL. More...
 
static bool matches (const XSECCryptoKey &key1, const XSECCryptoKey &key2)
 Compares two keys for equality. More...
 
static std::string doHash (const char *hashAlg, const char *buf, unsigned long buflen, bool toHex=true)
 Performs a hash operation over the supplied data. More...
 
static std::string getDEREncoding (const Credential &cred, const char *hash, bool nowrap=true)
 Returns the base64-encoded DER encoding of a public key in SubjectPublicKeyInfo format. More...
 
static std::string getDEREncoding (const XSECCryptoKey &key, const char *hash, bool nowrap=true)
 Returns the base64-encoded DER encoding of a public key in SubjectPublicKeyInfo format. More...
 
static std::string getDEREncoding (const XSECCryptoX509 &cert, const char *hash, bool nowrap=true)
 Returns the base64-encoded DER encoding of a certifiate's public key in SubjectPublicKeyInfo format. More...
 
static std::string getDEREncoding (const Credential &cred, bool hash=false, bool nowrap=true)
 
static std::string getDEREncoding (const XSECCryptoKey &key, bool hash=false, bool nowrap=true)
 
static std::string getDEREncoding (const XSECCryptoX509 &cert, bool hash=false, bool nowrap=true)
 
static XSECCryptoKey * fromDEREncoding (const char *buf, unsigned long buflen, bool base64=true)
 Decodes a DER-encoded public key. More...
 
static XSECCryptoKey * fromDEREncoding (const XMLCh *buf)
 Decodes a base64-encoded and DER-encoded public key. More...
 

Detailed Description

A helper class for working with keys, certificates, etc.

Member Function Documentation

static std::string xmltooling::SecurityHelper::doHash ( const char *  hashAlg,
const char *  buf,
unsigned long  buflen,
bool  toHex = true 
)
static

Performs a hash operation over the supplied data.

Parameters
hashAlgname of hash algorithm, syntax specific to crypto provider
bufinput data to hash
buflenlength of input data
toHexif true, hex-encodes the resulting raw bytes
Returns
result of hash operation, or an empty string
static XSECCryptoKey* xmltooling::SecurityHelper::fromDEREncoding ( const char *  buf,
unsigned long  buflen,
bool  base64 = true 
)
static

Decodes a DER-encoded public key.

Parameters
bufDER encoded data
buflenlength of data in bytes
base64true iff DER is base64-encoded
Returns
the decoded public key, or nullptr
static XSECCryptoKey* xmltooling::SecurityHelper::fromDEREncoding ( const XMLCh *  buf)
static

Decodes a base64-encoded and DER-encoded public key.

Parameters
bufbase64 and DER encoded data
Returns
the decoded public key, or nullptr
static std::string xmltooling::SecurityHelper::getDEREncoding ( const Credential cred,
const char *  hash,
bool  nowrap = true 
)
static

Returns the base64-encoded DER encoding of a public key in SubjectPublicKeyInfo format.

If a hash algorithm is provided, the data is digested before being base64-encoded.

Parameters
credthe credential containing the key to encode
hashoptional name of hash algorithm, syntax specific to crypto provider
nowrapif true, any linefeeds will be stripped from the result
Returns
the base64 encoded key value
static std::string xmltooling::SecurityHelper::getDEREncoding ( const XSECCryptoKey &  key,
const char *  hash,
bool  nowrap = true 
)
static

Returns the base64-encoded DER encoding of a public key in SubjectPublicKeyInfo format.

If a hash algorithm is provided, the data is digested before being base64-encoded.

Parameters
keythe key to encode
hashoptional name of hash algorithm, syntax specific to crypto provider
nowrapif true, any linefeeds will be stripped from the result
Returns
the base64 encoded key value
static std::string xmltooling::SecurityHelper::getDEREncoding ( const XSECCryptoX509 &  cert,
const char *  hash,
bool  nowrap = true 
)
static

Returns the base64-encoded DER encoding of a certifiate's public key in SubjectPublicKeyInfo format.

If a hash algorithm is provided, the data is digested before being base64-encoded.

Parameters
certthe certificate's key to encode
hashoptional name of hash algorithm, syntax specific to crypto provider
nowrapif true, any linefeeds will be stripped from the result
Returns
the base64 encoded key value
static std::string xmltooling::SecurityHelper::getDEREncoding ( const Credential cred,
bool  hash = false,
bool  nowrap = true 
)
static
Deprecated:
Returns the base64-encoded DER encoding of a public key in SubjectPublicKeyInfo format.
Parameters
credthe credential containing the key to encode
hashif true, the DER encoded data is hashed with SHA-1 before base64 encoding
nowrapif true, any linefeeds will be stripped from the result
Returns
the base64 encoded key value
static std::string xmltooling::SecurityHelper::getDEREncoding ( const XSECCryptoKey &  key,
bool  hash = false,
bool  nowrap = true 
)
static
Deprecated:
Returns the base64-encoded DER encoding of a public key in SubjectPublicKeyInfo format.
Parameters
keythe key to encode
hashif true, the DER encoded data is hashed with SHA-1 before base64 encoding
nowrapif true, any linefeeds will be stripped from the result
Returns
the base64 encoded key value
static std::string xmltooling::SecurityHelper::getDEREncoding ( const XSECCryptoX509 &  cert,
bool  hash = false,
bool  nowrap = true 
)
static
Deprecated:
Returns the base64-encoded DER encoding of a certificate's public key in SubjectPublicKeyInfo format.
Parameters
certthe certificate's key to encode
hashif true, the DER encoded data is hashed with SHA-1 before base64 encoding
nowrapif true, any linefeeds will be stripped from the result
Returns
the base64 encoded key value
static const char* xmltooling::SecurityHelper::guessEncodingFormat ( const char *  pathname)
static

Access a file to try and guess the encoding format used.

Parameters
pathnamepath to file
Returns
constant identifying encoding format
static std::vector<XSECCryptoX509*>::size_type xmltooling::SecurityHelper::loadCertificatesFromFile ( std::vector< XSECCryptoX509 * > &  certs,
const char *  pathname,
const char *  format = 0,
const char *  password = 0 
)
static

Loads certificate(s) from a local file.

Parameters
certsarray to populate with certificate(s)
pathnamepath to file containing certificate(s)
formatoptional constant identifying certificate encoding format
passwordoptional password to decrypt certificate(s)
Returns
size of the resulting array
static std::vector<XSECCryptoX509*>::size_type xmltooling::SecurityHelper::loadCertificatesFromURL ( std::vector< XSECCryptoX509 * > &  certs,
SOAPTransport transport,
const char *  backing,
const char *  format = 0,
const char *  password = 0 
)
static

Loads certificate(s) from a URL.

Parameters
certsarray to populate with certificate(s)
transportobject to use to acquire certificate(s)
backingbacking file for certificate(s) (written to or read from if download fails)
formatoptional constant identifying certificate encoding format
passwordoptional password to decrypt certificate(s)
Returns
size of the resulting array
static std::vector<XSECCryptoX509CRL*>::size_type xmltooling::SecurityHelper::loadCRLsFromFile ( std::vector< XSECCryptoX509CRL * > &  crls,
const char *  pathname,
const char *  format = 0 
)
static

Loads CRL(s) from a local file.

Parameters
crlsarray to populate with CRL(s)
pathnamepath to file containing CRL(s)
formatoptional constant identifying CRL encoding format
Returns
size of the resulting array
static std::vector<XSECCryptoX509CRL*>::size_type xmltooling::SecurityHelper::loadCRLsFromURL ( std::vector< XSECCryptoX509CRL * > &  crls,
SOAPTransport transport,
const char *  backing,
const char *  format = 0 
)
static

Loads CRL(s) from a URL.

Parameters
crlsarray to populate with CRL(s)
transportobject to use to acquire CRL(s)
backingbacking file for CRL(s) (written to or read from if download fails)
formatoptional constant identifying CRL encoding format
Returns
size of the resulting array
static XSECCryptoKey* xmltooling::SecurityHelper::loadKeyFromFile ( const char *  pathname,
const char *  format = 0,
const char *  password = 0 
)
static

Loads a private key from a local file.

Parameters
pathnamepath to file containing key
formatoptional constant identifying key encoding format
passwordoptional password to decrypt key
Returns
a populated key object
static XSECCryptoKey* xmltooling::SecurityHelper::loadKeyFromURL ( SOAPTransport transport,
const char *  backing,
const char *  format = 0,
const char *  password = 0 
)
static

Loads a private key from a URL.

Parameters
transportobject to use to acquire key
backingbacking file for key (written to or read from if download fails)
formatoptional constant identifying key encoding format
passwordoptional password to decrypt key
Returns
a populated key object
static bool xmltooling::SecurityHelper::matches ( const XSECCryptoKey &  key1,
const XSECCryptoKey &  key2 
)
static

Compares two keys for equality.

Parameters
key1first key to compare
key2second key to compare
Returns
true iff the keys match

The documentation for this class was generated from the following file: