public function testIsAuthenticationValid() { $username = '******'; $password = '******'; $this->getMockAuthResource()->expects($this->once())->method('isAuthenticationValid')->with($username, $password)->will($this->returnValue(true)); $this->assertTrue($this->crowd->isAuthenticationValid($username, $password)); }
public function authenticate(TokenInterface $token) { $user = $this->userProvider->loadUserByUsername($token->getUsername()); if ($user && ($token->isAuthenticated() || $this->crowd->isauthenticationvalid($token->getUsername(), $token->getCredentials()))) { $authenticatedToken = new CrowdToken($user->getRoles()); $authenticatedToken->setUser($user); return $authenticatedToken; } throw new AuthenticationException('The Crowd authentication failed.'); }
/** * @param string $username The username * * @return UserInterface * * @see UsernameNotFoundException * * @throws UsernameNotFoundException if the user is not found * */ public function loadUserByUsername($username) { $sessionKey = 'seiffert_crowd_auth.user'; if ($this->session->has($sessionKey)) { return $this->session->get($sessionKey); } try { $user = User::fromUser($this->crowd->getUser($username)); $this->session->set($sessionKey, $user); return $user; } catch (UserNotFoundException $e) { throw new UsernameNotFoundException($e->getMessage(), $e->getCode(), $e); } }