class Signer implements SignerInterface, LoggerAwareInterface

The Signer class is designed for those who are signing data on behalf of a public-private keypair.

In principle, the "client party" has public key (i.e., client_id) has a matching private key (i.e., client_secret) that can be verified by both the signer, as well as the client, but by nobody else as we don't want to make forgeries possible.

The "signing party" has a simple an identifier which acts as an additional piece of entropy in the algorithm, and can help differentiate between multiple signing parties if the client party does something like try to use the same public-private keypair independently of a signing party (as is common with GPG signing).

For example, in the original AWS implementation, the "self key" for AWS was "AWS4".

Traits

Basic Implementation of LoggerAwareInterface.

Methods

setLogger(LoggerInterface $logger)

Sets a logger.

__construct(string $self_key, string $client_id, string $client_secret, string $hash_algo = 'sha512')

Constructs a new instance of this class.

string
getSelfKey()

Gets the self key that was set in the constructor.

string
getClientId()

Gets the client key that was set in the constructor.

string
getClientSecret()

Gets the client secret that was set in the constructor.

string
sign(array $payload)

Sign the payload to produce a signature for its contents.

Details

in LoggerAwareTrait at line line 18
setLogger(LoggerInterface $logger)

Sets a logger.

Parameters

LoggerInterface $logger

at line line 75
__construct(string $self_key, string $client_id, string $client_secret, string $hash_algo = 'sha512')

Constructs a new instance of this class.

Parameters

string $self_key A string which identifies the signing party and adds additional entropy.
string $client_id A string which is the public portion of the keypair identifying the client party. The pairing of the public and private portions of the keypair should only be known to the client party and the signing party.
string $client_secret A string which is the private portion of the keypair identifying the client party. The pairing of the public and private portions of the keypair should only be known to the client party and the signing party.
string $hash_algo The hash algorithm to use for signing. Run hash_algos() to see what's supported. The default value is sha512.

See also

http://php.net/hash_algos

at line line 87
string getSelfKey()

Gets the self key that was set in the constructor.

Return Value

string The self key.

at line line 96
string getClientId()

Gets the client key that was set in the constructor.

Return Value

string The client key.

at line line 105
string getClientSecret()

Gets the client secret that was set in the constructor.

Return Value

string The client secret.

at line line 114
string sign(array $payload)

Sign the payload to produce a signature for its contents.

Parameters

array $payload The data to generate a signature for.

Return Value

string The signature for the payload contents.