Skip to content

Commit

Permalink
Removing Rijandel from the Cookie Trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed Feb 28, 2017
1 parent b452e4c commit 31907b7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/Http/Cookie/Cookie.php
Expand Up @@ -149,10 +149,10 @@ public function toHeaderValue()
if ($this->expiresAt !== 0) {
$headerValue[] = $this->_buildExpirationValue();
}
if (!empty($this->path)) {
if ($this->path !== '') {
$headerValue[] = sprintf('path=%s', $this->path);
}
if (!empty($this->domain)) {
if ($this->domain !== '') {
$headerValue[] = sprintf('domain=%s', $this->domain);
}
if ($this->secure) {
Expand Down Expand Up @@ -299,7 +299,7 @@ public function setHttpOnly($httpOnly)
*/
public function isHttpOnly()
{
return $this->isHttpOnly();
return $this->httpOnly;
}

/**
Expand Down
17 changes: 5 additions & 12 deletions src/Http/Cookie/CookieCryptTrait.php
Expand Up @@ -31,8 +31,7 @@ trait CookieCryptTrait
* @var array
*/
protected $_validCiphers = [
'aes',
'rijndael'
'aes'
];

/**
Expand Down Expand Up @@ -68,7 +67,7 @@ public function setEncryptionCipher($cipher)
*
* @return bool
*/
public function encryptionIsEnabled()
public function isEncryptionEnabled()
{
return is_string($this->encryptionCipher);
}
Expand Down Expand Up @@ -105,7 +104,7 @@ public function setEncryptionKey($key)
*/
public function getEncryptionKey()
{
if (empty($this->encryptionKey)) {
if ($this->encryptionKey === null) {
return Security::salt();
}

Expand All @@ -115,7 +114,7 @@ public function getEncryptionKey()
/**
* Encrypts $value using public $type method in Security class
*
* @param string $value Value to encrypt
* @param string|array $value Value to encrypt
* @return string Encoded values
*/
protected function _encrypt($value)
Expand All @@ -129,9 +128,6 @@ protected function _encrypt($value)
$cipher = null;
$key = $this->getEncryptionKey();

if ($encrypt === 'rijndael') {
$cipher = Security::rijndael($value, $key, 'encrypt');
}
if ($encrypt === 'aes') {
$cipher = Security::encrypt($value, $key);
}
Expand Down Expand Up @@ -186,7 +182,7 @@ protected function _decrypt($values, $mode)
*/
protected function _decode($value)
{
if (!$this->encryptionIsEnabled()) {
if (!$this->isEncryptionEnabled()) {
return $this->_expand($value);
}

Expand All @@ -196,9 +192,6 @@ protected function _decode($value)

$value = base64_decode(substr($value, strlen($prefix)));

if ($encrypt === 'rijndael') {
$value = Security::rijndael($value, $key, 'decrypt');
}
if ($encrypt === 'aes') {
$value = Security::decrypt($value, $key);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Http/Cookie/RequestCookies.php
Expand Up @@ -60,11 +60,10 @@ public function has($name)
*/
public function get($name)
{
$key = mb_strtolower($name);
if (isset($this->cookies[$key]) === false) {
if (!$this->has($name)) {;
throw new InvalidArgumentException(sprintf('Cookie `%s` does not exist', $name));
}

return $this->cookies[$key];
return $this->cookies[mb_strtolower($name)];
}
}

0 comments on commit 31907b7

Please sign in to comment.