/** * {@inheritdoc} */ public function authenticate(TokenInterface $token) { /** @var HmacUserToken $token */ if ($this->validateServiceLabel($token->getServiceLabel())) { $user = $this->userProvider->loadUserByUsername($token->getUsername()); if ($this->validateSignature($token->getRequest(), $token->getSignature(), $user->getPassword())) { $authenticatedToken = new HmacUserToken(); $authenticatedToken->setUser($user); $authenticatedToken->setServiceLabel($token->getServiceLabel()); $authenticatedToken->setRequest($token->getRequest()); return $authenticatedToken; } } throw new AuthenticationException('The HMAC authentication failed.'); }