This repository has been archived by the owner on Mar 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
527 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
src/Eloquent/Otis/Configuration/AbstractOtpConfiguration.php
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,79 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
* | ||
* Copyright © 2013 Erin Millard | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eloquent\Otis\Configuration; | ||
|
||
/** | ||
* An abstract base class for implementing OTP configurations. | ||
*/ | ||
abstract class AbstractOtpConfiguration implements OtpConfigurationInterface | ||
{ | ||
/** | ||
* Construct a new OTP configuration. | ||
* | ||
* @param integer|null $digits The number of password digits. | ||
* @param integer|null $secretLength The length of the shared secret. | ||
* @param HashAlgorithm|null $algorithm The underlying algorithm to use. | ||
*/ | ||
public function __construct( | ||
$digits = null, | ||
$secretLength = null, | ||
HashAlgorithm $algorithm = null | ||
) { | ||
if (null === $digits) { | ||
$digits = 6; | ||
} | ||
if (null === $secretLength) { | ||
$secretLength = 10; | ||
} | ||
if (null === $algorithm) { | ||
$algorithm = HashAlgorithm::SHA1(); | ||
} | ||
|
||
$this->digits = $digits; | ||
$this->secretLength = $secretLength; | ||
$this->algorithm = $algorithm; | ||
} | ||
|
||
/** | ||
* Get the number of password digits. | ||
* | ||
* @return integer The number of digits. | ||
*/ | ||
public function digits() | ||
{ | ||
return $this->digits; | ||
} | ||
|
||
/** | ||
* Get the length of the shared secret. | ||
* | ||
* @return integer The secret length. | ||
*/ | ||
public function secretLength() | ||
{ | ||
return $this->secretLength; | ||
} | ||
|
||
/** | ||
* Get the underlying algorithm name. | ||
* | ||
* @return HashAlgorithm The algorithm name. | ||
*/ | ||
public function algorithm() | ||
{ | ||
return $this->algorithm; | ||
} | ||
|
||
private $digits; | ||
private $secretLength; | ||
private $algorithm; | ||
} |
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,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
* | ||
* Copyright © 2013 Erin Millard | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eloquent\Otis\Configuration; | ||
|
||
use Eloquent\Enumeration\Enumeration; | ||
|
||
/** | ||
* The available hash algorithms. | ||
*/ | ||
final class HashAlgorithm extends Enumeration | ||
{ | ||
/** | ||
* The SHA-1 hash algorithm. | ||
* | ||
* @link http://tools.ietf.org/html/rfc3174 | ||
*/ | ||
const SHA1 = 'sha1'; | ||
|
||
/** | ||
* The SHA-256 hash algorithm. | ||
* | ||
* @link http://tools.ietf.org/html/rfc6234 | ||
*/ | ||
const SHA256 = 'sha256'; | ||
|
||
/** | ||
* The SHA-512 hash algorithm. | ||
* | ||
* @link http://tools.ietf.org/html/rfc6234 | ||
*/ | ||
const SHA512 = 'sha512'; | ||
} |
Oops, something went wrong.