libqtaws  0.1.0
UnofficialAWSlibraryforQt-InternalDocumentation
Public Slots | Signals | Public Member Functions | List of all members
AwsAbstractCredentials Class Referenceabstract

Interface class for providing AWS credentials. More...

Inheritance diagram for AwsAbstractCredentials:
Inheritance graph
[legend]
Collaboration diagram for AwsAbstractCredentials:
Collaboration graph
[legend]

Public Slots

virtual bool refresh ()
 Refresh this object's credentials. More...
 

Signals

void changed ()
 Signal emitted when this object's credentials have been updated. More...
 

Public Member Functions

 AwsAbstractCredentials (QObject *const parent=0)
 Construct an AwsAbstractCredentials. More...
 
virtual QString accessKeyId () const =0
 AWS access key ID for this credentials object. More...
 
virtual QString secretKey () const =0
 AWS secret access key for this credentials object. More...
 
virtual QString token () const =0
 AWS security token for this credentials object. More...
 
virtual QDateTime expiration () const
 DateTime at which the credentials will expire. More...
 
virtual bool isExpired () const
 Is this credentials object currently expired. More...
 
virtual bool isRefreshable () const
 Is this credentials object refreshable. More...
 

Detailed Description

Interface class for providing AWS credentials.

Definition at line 30 of file awsabstractcredentials.h.

Constructor & Destructor Documentation

AwsAbstractCredentials::AwsAbstractCredentials ( QObject *const  parent = 0)

Construct an AwsAbstractCredentials.

Parameters
parent

Definition at line 36 of file awsabstractcredentials.cpp.

36 : QObject(parent) { }

Member Function Documentation

QString AwsAbstractCredentials::accessKeyId ( ) const
pure virtual

AWS access key ID for this credentials object.

Returns
The AWS access key ID for this credentials object.

Implemented in AwsBasicCredentials, and AwsAnonymousCredentials.

Referenced by AwsSignatureV0Private::adornRequest(), AwsSignatureV2Private::adornRequest(), AwsSignatureV3Private::authorizationHeaderValue(), and AwsSignatureV4Private::authorizationHeaderValue().

void AwsAbstractCredentials::changed ( )
signal

Signal emitted when this object's credentials have been updated.

See also
refresh()

Referenced by AwsBasicCredentials::setAccessKeyId(), AwsBasicCredentials::setSecretKey(), and AwsBasicCredentials::setToken().

QDateTime AwsAbstractCredentials::expiration ( ) const
virtual

DateTime at which the credentials will expire.

This method should not be invoked unless the object is known to be refreshable (ie isRefreshable() returns true). As the base implementation of isRefreshable() always returns false, this implementation of expiration() should not be invoked.

Derived classes that return true from isRefreshable() must also override this function to provide the appropriate expiration timestamp (which may a null QDateTime if the credentials never expire).

Returns
The DateTime at whcih the credentials will expire.
See also
isExpired()
isRefreshable()
refresh()

Definition at line 79 of file awsabstractcredentials.cpp.

References isRefreshable().

Referenced by isExpired().

80 {
81  if (isRefreshable()) {
82  qWarning() << "AwsAbstractCredentials: expiration must be implemented by refreshable derived classes";
83  } else {
84  qWarning() << "AwsAbstractCredentials: expiration should not be invoked on non-refreshable objects";
85  }
86  return QDateTime(); // A null QDateTime.
87 }
virtual bool isRefreshable() const
Is this credentials object refreshable.
bool AwsAbstractCredentials::isExpired ( ) const
virtual

Is this credentials object currently expired.

In this base implementation, non-refreshable credentials (ie those for which isRefreshable() returns false) are assumed to never expire, whereas refreshable credentials are assume to be expired only if expiration() returns a valid QDateTime representing a time in the past (ie earlier than QDateTime::currentDateTimeUtc()).

Derived classes may override this method to implement custom expiration logic.

Returns
true if this credentials object is expired, false otherwise.
See also
expiration()
isRefreshable()
refresh()

Definition at line 105 of file awsabstractcredentials.cpp.

References expiration(), and isRefreshable().

106 {
107  if (isRefreshable()) {
108  const QDateTime expiration = this->expiration();
109  return ((expiration.isValid()) && (expiration < QDateTime::currentDateTimeUtc()));
110  }
111  return false; // Non-refreshable credentials do not expire, by default.
112 }
virtual bool isRefreshable() const
Is this credentials object refreshable.
virtual QDateTime expiration() const
DateTime at which the credentials will expire.
bool AwsAbstractCredentials::isRefreshable ( ) const
virtual

Is this credentials object refreshable.

This base implementation always returns false - ie credentials are not refreshable by default. However, dervived classes may override this method as appropriate.

Derived classes that override this method must also override the expiration() method (merely returning a null QDateTime is the credentials do not expire), and may wish to override isExpired() also.

Returns
true if this credentials object is expired, false otherwise.
See also
expiration()
isExpired()
refresh()

Definition at line 130 of file awsabstractcredentials.cpp.

Referenced by expiration(), isExpired(), and refresh().

131 {
132  return false;
133 }
bool AwsAbstractCredentials::refresh ( )
virtualslot

Refresh this object's credentials.

This slot begins an asynchronous refresh transaction, and should be followed by a change() signal when the credentials have been refreshed.

Todo:
A signal for errors?

This method should not be invoked unless the object is known to be refreshable (ie isRefreshable() returns true). As the base implementation of isRefreshable() always returns false, this implementation of expiration() should not be invoked.

Derived classes that return true from isRefreshable() must also override this function to provide the appropriate refresh behaviour.

Returns
true if the refresh transaction has begun successfully, false otherwise.
See also
isRefreshable()
changed()

Definition at line 155 of file awsabstractcredentials.cpp.

References isRefreshable().

156 {
157  if (isRefreshable()) {
158  qWarning() << "AwsAbstractCredentials: refresh must be implemented by refreshable derived classes";
159  } else {
160  qWarning() << "AwsAbstractCredentials: refresh should not be invoked on non-refreshable objects";
161  }
162  return false;
163 }
virtual bool isRefreshable() const
Is this credentials object refreshable.
QString AwsAbstractCredentials::secretKey ( ) const
pure virtual

AWS secret access key for this credentials object.

Returns
The AWS secret access key for this credentials object.

Implemented in AwsBasicCredentials, and AwsAnonymousCredentials.

Referenced by AwsSignatureV3Private::authorizationHeaderValue(), AwsSignatureV0::sign(), AwsSignatureV2::sign(), and AwsSignatureV4Private::signingKey().

QString AwsAbstractCredentials::token ( ) const
pure virtual

AWS security token for this credentials object.

Returns
The AWS security token for this credentials object.

Implemented in AwsBasicCredentials, and AwsAnonymousCredentials.


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