AppserverIo\Appserver\ServletEngine\Security\StandardAuthenticationManager::getAuthenticator PHP Method

getAuthenticator() public method

Returns the configured authenticator for the passed URL pattern authenticator mapping.
public getAuthenticator ( AppserverIo\Appserver\ServletEngine\Security\MappingInterface $mapping = null ) : AppserverIo\Storage\StorageInterface
$mapping AppserverIo\Appserver\ServletEngine\Security\MappingInterface The URL pattern to authenticator mapping
return AppserverIo\Storage\StorageInterface The storage with the authentication types
    public function getAuthenticator(MappingInterface $mapping = null)
    {
        // query whether or not a mapping has been passed
        if ($mapping != null) {
            // query whether or not we've an authentication manager with the passed key
            if (isset($this->authenticators[$authenticatorSerial = $mapping->getAuthenticatorSerial()])) {
                return $this->authenticators[$authenticatorSerial];
            }
            // throw an exception if not
            throw new AuthenticationException(sprintf('Can\'t find authenticator serial %s', $authenticatorSerial));
        }
        // try to find the default authenticator instead
        foreach ($this->authenticators as $authenticator) {
            if ($authenticator->isDefaultAuthenticator()) {
                return $authenticator;
            }
        }
        // throw an exception if we can't find a default authenticator also
        throw new AuthenticationException('Can\'t find a default authenticator');
    }