Google APIs Client Library for C++
CredentialStore Class Reference

Base class for a data store of persisted credentials. More...

#include "client/auth/credential_store.h"

List of all members.

Public Member Functions

 CredentialStore ()
 Standard constructor.
virtual ~CredentialStore ()
 Standard destructor.
void set_codec (Codec *codec)
 Sets the Codec that this store should use for re-encoding and decoding data streams.
Codeccodec () const
 Returns the codec for this store.
virtual util::Status InitCredential (const StringPiece &user_name, AuthorizationCredential *credential)=0
 Restore a credential for the given user name.
virtual util::Status Store (const StringPiece &user_name, const AuthorizationCredential &credential)=0
 Stores the credential under the given user_name.
virtual util::Status Delete (const StringPiece &user_name)=0
 Deletes the credential with the given user_name.

Protected Member Functions

DataReaderDecodedToEncodingReader (DataReader *reader, util::Status *status)
 Applies the codec (if any) to decode a reader.
DataReaderEncodedToDecodingReader (DataReader *reader, util::Status *status)
 Applies the codec (if any) to encode a reader.

Detailed Description

Base class for a data store of persisted credentials.

This interface is in terms of the DataReader that the abstract AuthorizationCredential uses. Therefore it is suitable for any type of credential derived from AuthorizationCredential, including the OAuth2Credential introduced in the OAuth 2.0 module.

Warning:
The library does not currently provide encryption. However, for security you are encouraged to encrypt the data streams if possible. This will prevent authorization and refresh tokens from being readable should the persisted store become compramised. The refresh token still requires the client secret to turn into an access token.

Although no encryption mechanism is provided at this time, the CredentialStore will accomodate one injected using a Codec that you can write.

See also:
Codec
AuthorizationCredential

Constructor & Destructor Documentation

Standard constructor.

virtual ~CredentialStore ( ) [virtual]

Standard destructor.


Member Function Documentation

Codec* codec ( ) const [inline]

Returns the codec for this store.

Returns:
NULL if the store is not encrypted.
DataReader* DecodedToEncodingReader ( DataReader reader,
util::Status status 
) [protected]

Applies the codec (if any) to decode a reader.

Parameters:
[in]readerThe caller passes ownership to the reader.
[out]statusSuccess if the reader could be decoded.
Returns:
The decoded stream. Ownerhsip is passed back to the caller. This will always return a reader, though may be an InvalidDataReader if there is an error.
virtual util::Status Delete ( const StringPiece &  user_name) [pure virtual]

Deletes the credential with the given user_name.

Parameters:
[in]user_nameThe key to remove.
Returns:
success if the key no longer exists in the store.
DataReader* EncodedToDecodingReader ( DataReader reader,
util::Status status 
) [protected]

Applies the codec (if any) to encode a reader.

Parameters:
[in]readerThe caller passes ownership to the reader.
[out]statusSuccess if the reader could be encoded.
Returns:
The encoded stream. Ownerhsip is passed back to the caller. This will always return a reader, though may be an InvalidDataReader if there is an error.
virtual util::Status InitCredential ( const StringPiece &  user_name,
AuthorizationCredential credential 
) [pure virtual]

Restore a credential for the given user name.

Parameters:
[in]user_nameThe key to store from
[out]credentialThe credential to load into.
Returns:
success if the credential could be restored. A successful result requires that a credential had been stored at some earlier time.
void set_codec ( Codec codec)

Sets the Codec that this store should use for re-encoding and decoding data streams.

The intention here is to encrypt and decrypt but the codec can be used for any purpose.

Parameters:
[in]codecOwnership is passsed to the store. NULL is permitted to mean do not perform any encryption or decryption.
virtual util::Status Store ( const StringPiece &  user_name,
const AuthorizationCredential credential 
) [pure virtual]

Stores the credential under the given user_name.

This will replace any previously stored credential for the user_name.

Parameters:
[in]user_nameThe key to store the credential under.
[in]credentialThe credential to store.
Returns:
success if the credential could be stored successfully.

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines