@param \Seat\Eseye\Containers\EsiAuthentication $authentication

@return \Seat\Eseye\Eseye
@throws \Seat\Eseye\Exceptions\InvalidContainerDataException
542919
public function setAuthentication(EsiAuthentication $authentication): self
    {

        if (! $authentication->valid())
            throw new InvalidContainerDataException('Authentication data invalid/empty');

        $this->authentication = $authentication;

        return $this;
    }
1265392
public function configureGoogleAuthenticator($config, ContainerBuilder $container)
    {
        $container->setParameter('sonata.user.google.authenticator.enabled', $config['google_authenticator']['enabled']);

        if (!$config['google_authenticator']['enabled']) {
            $container->removeDefinition('sonata.user.google.authenticator');
            $container->removeDefinition('sonata.user.google.authenticator.provider');
            $container->removeDefinition('sonata.user.google.authenticator.interactive_login_listener');
            $container->removeDefinition('sonata.user.google.authenticator.request_listener');

            return;
        }

        if (!class_exists('Google\Authenticator\GoogleAuthenticator')
            && !class_exists('Sonata\GoogleAuthenticator\GoogleAuthenticator')) {
            throw new \RuntimeException('Please add ``sonata-project/google-authenticator`` package');
        }

        $container->setParameter('sonata.user.google.authenticator.forced_for_role', $config['google_authenticator']['forced_for_role']);
        $container->setParameter('sonata.user.google.authenticator.ip_white_list', $config['google_authenticator']['ip_white_list']);

        $container->getDefinition('sonata.user.google.authenticator.provider')
            ->replaceArgument(0, $config['google_authenticator']['server']);
    }
525049
protected static function createAuthenticationFailedResponse(ContainerInterface $container): ResponseInterface
    {
        /** @var SettingsProviderInterface $provider */
        $provider = $container->get(SettingsProviderInterface::class);
        $settings = $provider->get(S::class);
        $factory  = $settings[S::KEY_FAILED_CUSTOM_UNAUTHENTICATED_FACTORY] ?? null;

        assert($factory === null || is_callable($factory) === true);

        $response = $factory === null ? new EmptyResponse(401) : call_user_func($factory);

        return $response;
    }
498490
public static function device(
        Authorization $authorization,
        ClientInterface $client = null,
        SerializerInterface $serializer = null
    ) {
        AnnotationRegistry::registerLoader('class_exists');

        $afterpayClient = $client ?: new Client([ 'base_uri' => $authorization->getEndpoint() ]);
        $afterpaySerializer = $serializer ?: SerializerFactory::getSerializer();

        return new Service\InStore\Device($authorization, $afterpayClient, $afterpaySerializer);
    }
1373040
public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
    {
        // The user provider should implement JWTUserProviderInterface
        if (!$userProvider instanceof JWTUserProviderInterface) {
            throw new InvalidArgumentException('Argument must implement interface Auth0\JWTAuthBundle\Security\Core\JWTUserProviderInterface');
        }

        if ($token->getCredentials() === null) {
            $user = $userProvider->getAnonymousUser();
        } else {
            // Get the user for the injected UserProvider
            $user = $userProvider->loadUserByJWT($token->getCredentials());

            if (!$user) {
                throw new AuthenticationException(sprintf('Invalid JWT.'));
            }
        }

        return new PreAuthenticatedToken(
            $user,
            $token,
            $providerKey,
            $user->getRoles()
        );
    }
550783
public function setAuthentication(array $credentials): AbstractClientBuilder
    {
        if (array_key_exists('session_id', $credentials)) {
            $this->authentication = new HeaderAuthenticate($credentials['session_id']);
        } elseif (array_key_exists('username', $credentials) && array_key_exists('password', $credentials)) {
            $this->authentication = new HeaderLogin($credentials['username'], $credentials['password']);
        } else {
            throw new \InvalidArgumentException('No credentials given.');
        }

        return $this;
    }
1144111
public function getAuthenticationAdapter()
    {
        if (null === $this->authenticationAdapter) {
            $authenticationAdapter = $this->getAuthenticationService()->getAdapter();
            $this->setAuthenticationAdapter($authenticationAdapter);
        }

        return $this->authenticationAdapter;
    }
1242060
protected function switchCredentials(AuthenticationOperation $operation)
    {
        $this->connection->getConfig()->setUsername($operation->getUsername());
        $this->connection->getConfig()->setPassword($operation->getPassword());
    }
1300396
public function getContext($sid) {
        return new AuthRegistrationsCredentialListMappingContext(
            $this->version,
            $this->solution['accountSid'],
            $this->solution['domainSid'],
            $sid
        );
    }
1281541
private function authenticateWithPassword()
    {
        if ($this->credentials->havePassword()) {
            $authCommand = new Auth();
            $authCommand->setArguments([$this->credentials->getPassword()]);
            $authResponse = $this->connection->execute($authCommand);
            $response = $authCommand->parse($authResponse);
            if ($response !== self::AUTH_SUCCESS_MESSAGE) {
                throw new AuthenticationException();
            }
        }
    }
217688
public function authenticationResponse()
    {
        $client = new Client();

        try {
            $response = $client->request('GET', static::AUTH_URL, [
                'headers' => [
                    'X-Auth-User' => $this->username,
                    'X-Auth-Key' => $this->password,
                ],
            ]);
        } catch (RequestException $e) {
            throw new AuthenticationFailedException('Given credentials are wrong.', 403);
        }

        return $response;
    }
664310
protected Authentication getAuthenticationSatisfiedByPolicy(final Authentication authentication, final ServiceContext context) throws AbstractTicketException {
        val policy = this.serviceContextAuthenticationPolicyFactory.createPolicy(context);
        try {
            if (policy.isSatisfiedBy(authentication)) {
                return authentication;
            }
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        throw new UnsatisfiedAuthenticationPolicyException(policy);
    }
1048062
protected function setAuthentication(array $config, Authentication $authentication = null)
    {
        $this->authentication = $authentication;
        if ($authentication === null) {
            $this->authentication = new Authentication();
        }

        if (isset($config['timestamp'])) {
            $this->authentication->setTimestamp($config['timestamp']);
        }

        if (isset($config['nonce'])) {
            $this->authentication->setNonce($config['nonce']);
        }
    }
608628
public function register(array $credentials, $activation = false)
    {
        try {
            $exists = $this->sentinel->findUserByCredentials($credentials);

            if ($exists) {
                throw new InvalidArgumentException("Invalid credentials provided");
            }

            $user = $this->sentinel->register($credentials, $activation);
            if (!$activation) {
                $activation = $this->activations->create($user);
            }
        } catch (Exception $e) {
            return $this->returnException($e);
        }

        if ($user) {
            $message = $this->translate('registration_success', 'Registration complete');
            return new SuccessReply($message, ['user' => $user, 'activation' => $activation]);
        }

        $message = $this->translate('registration_failed', 'Registration denied due to invalid credentials.');
        return new FailureReply($message);
    }
1176743
public function authorize(AuthenticationInterface $authentication)
    {
        $this->setHeader();

        $this->fetchToken();

        $this->checkTokenType();

        $authentication->addAttribute($this->token->access_token);
    }
926621
private function setSessionCookies(AuthenticationRecordInterface $authentication)
    {
        $systemKey = new EncryptionKey($this->systemEncryptionKey);
        $sessionKey = new HiddenString($authentication->getSessionKey());
        $userKey = new EncryptionKey($sessionKey);
        $hashCookieName = hash_hmac('sha256', $sessionKey . $authentication->getUsername(), $systemKey);
        $userTuple = base64_encode(Crypto::encrypt(new HiddenString($authentication->getUserId() . ':' . $hashCookieName), $systemKey));
        $hashCookieContents = base64_encode(Crypto::encrypt(new HiddenString(time() . ':' . $authentication->getUserId() . ':' . $authentication->getUsername()), $userKey));

        //
        // 1 - Set the cookie that contains the user ID, and hash cookie name
        //
        $this->setCookie(
            self::COOKIE_USER,
            $userTuple
        );

        //
        // 2 - Set the cookie with random name, that contains a verification hash, that's a function of the switching session key
        //
        $this->setCookie(
            self::COOKIE_HASH_PREFIX . $hashCookieName,
            $hashCookieContents
        );

        //
        // 3 - Set the sign cookie, that acts as a safeguard against tampering
        //
        $this->setCookie(
            self::COOKIE_VERIFY_A,
            hash_hmac('sha256', $userTuple, $systemKey)
        );

        //
        // 4 - Set a sign cookie for the hashCookie's values
        //
        $this->setCookie(
            self::COOKIE_VERIFY_B,
            hash_hmac('sha256', $hashCookieContents, $userKey)
        );
    }
622890
protected function getAuthenticationResponse(AuthenticationOperation $operation)
    {
        $authenticated = false;
        $errorMessage = null;
        $errorCode = null;

        // Only catch a bind failure. Let the others through, as it's probably a sign of other issues.
        try {
            $authenticated = (bool) $this->connection->close()->connect(...$operation->getArguments());
        } catch (LdapBindException $e) {
            $errorMessage = $this->connection->getLastError();
            $errorCode = $this->connection->getExtendedErrorNumber();
        }

        return new AuthenticationResponse($authenticated, $errorMessage, $errorCode);
    }