public function authenticate(IAuthentication $auth) { if ($auth == null) { throw new BadCredentialsException(null, 'Bad credentials - null given'); } if (!$auth instanceof UsernamePasswordAuthenticationToken) { throw new BadCredentialsException(null, 'Bad credentials - expected UsernamePasswordAuthenticationToken'); } // Normally we would use a IUserDetailsService implementation here to // lookup our given user against the local credential store, we don't // need to as we are simply authenticating users if un==pw. if ($auth->getPrinciple() != null && $auth->getPrinciple() == $auth->getCredentials()) { $roles = array(); $roles[] = 'ROLE_REGISTERED_USER'; $auth->setAuthorities($roles); $userDetails = new GOCDBUserDetails($auth->getPrinciple(), true, $roles, 'customVal2', ''); $auth->setDetails($userDetails); return $auth; } // We didn't manage to authenticate the user, so throw exception throw new AuthenticationException(null, 'Authentication failed'); }
public function Logout(UserSession $user) { $this->authToDecorate->Logout($user); }