-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from jeremykendall/develop
Merge develop into master
- Loading branch information
Showing
13 changed files
with
235 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* Query Auth: Signature generation and validation for REST API query authentication | ||
* | ||
* @copyright 2013 Jeremy Kendall | ||
* @license https://github.com/jeremykendall/query-auth/blob/master/LICENSE MIT | ||
* @link https://github.com/jeremykendall/query-auth | ||
*/ | ||
|
||
namespace QueryAuth; | ||
|
||
use QueryAuth\Client; | ||
use QueryAuth\ParameterCollection; | ||
use QueryAuth\Server; | ||
use QueryAuth\Signer; | ||
use RandomLib\Factory as RandomFactory; | ||
|
||
/** | ||
* Creates QueryAuth classes | ||
*/ | ||
class Factory | ||
{ | ||
/** | ||
* @var RandomFactory RandomLib Factory | ||
*/ | ||
private $randomFactory; | ||
|
||
/** | ||
* Creates a client instance | ||
* | ||
* @return Client Client instance | ||
*/ | ||
public function newClient() | ||
{ | ||
return new Client($this->newSigner()); | ||
} | ||
|
||
/** | ||
* Creates a server instance | ||
* | ||
* @return Server Server instance | ||
*/ | ||
public function newServer() | ||
{ | ||
return new Server($this->newSigner()); | ||
} | ||
|
||
/** | ||
* Creates new KeyGenerator created with medium strength RandomLib\Generator | ||
*/ | ||
public function newKeyGenerator() | ||
{ | ||
return new KeyGenerator( | ||
$this->getRandomFactory()->getMediumStrengthGenerator() | ||
); | ||
} | ||
|
||
/** | ||
* Creates a signer for either server or client | ||
* | ||
* @return Signer Signer instance | ||
*/ | ||
protected function newSigner() | ||
{ | ||
return new Signer(new ParameterCollection()); | ||
} | ||
|
||
/** | ||
* Get an instance of RandomFactory. If property is null, creates a new | ||
* instance. | ||
* | ||
* @return RandomFactory Instance of RandomFactory | ||
*/ | ||
public function getRandomFactory() | ||
{ | ||
if ($this->randomFactory === null) { | ||
$this->randomFactory = new RandomFactory(); | ||
} | ||
|
||
return $this->randomFactory; | ||
} | ||
|
||
/** | ||
* Set randomFactory | ||
* | ||
* @param RandomFactory $randomFactory Instance of RandomFactory | ||
*/ | ||
public function setRandomFactory(RandomFactory $randomFactory) | ||
{ | ||
$this->randomFactory = $randomFactory; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.