]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ApiBundle/Security/Authentication/Provider/WsseProvider.php
CS
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Security / Authentication / Provider / WsseProvider.php
index 8e49167aa7c7b7917018f0cd2376f7b89b5a3efc..9bf8b377f6b6416f9d47f7b382f48f9865dd6efc 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace Wallabag\ApiBundle\Security\Authentication\Provider;
 
 use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
@@ -16,7 +17,7 @@ class WsseProvider implements AuthenticationProviderInterface
     public function __construct(UserProviderInterface $userProvider, $cacheDir)
     {
         $this->userProvider = $userProvider;
-        $this->cacheDir     = $cacheDir;
+        $this->cacheDir = $cacheDir;
 
         // If cache directory does not exist we create it
         if (!is_dir($this->cacheDir)) {
@@ -29,7 +30,7 @@ class WsseProvider implements AuthenticationProviderInterface
         $user = $this->userProvider->loadUserByUsername($token->getUsername());
 
         if (!$user) {
-            throw new AuthenticationException("Bad credentials. Did you forgot your username?");
+            throw new AuthenticationException('Bad credentials. Did you forgot your username?');
         }
 
         if ($user && $this->validateDigest($token->digest, $token->nonce, $token->created, $user->getPassword())) {
@@ -46,12 +47,12 @@ class WsseProvider implements AuthenticationProviderInterface
     {
         // Check created time is not in the future
         if (strtotime($created) > time()) {
-            throw new AuthenticationException("Back to the future...");
+            throw new AuthenticationException('Back to the future...');
         }
 
         // Expire timestamp after 5 minutes
         if (time() - strtotime($created) > 300) {
-            throw new AuthenticationException("Too late for this timestamp... Watch your watch.");
+            throw new AuthenticationException('Too late for this timestamp... Watch your watch.');
         }
 
         // Validate nonce is unique within 5 minutes
@@ -65,7 +66,7 @@ class WsseProvider implements AuthenticationProviderInterface
         $expected = base64_encode(sha1(base64_decode($nonce).$created.$secret, true));
 
         if ($digest !== $expected) {
-            throw new AuthenticationException("Bad credentials ! Digest is not as expected.");
+            throw new AuthenticationException('Bad credentials ! Digest is not as expected.');
         }
 
         return $digest === $expected;