/** * Returns the configured authenticator for the passed URL pattern authenticator mapping. * * @param \AppserverIo\Appserver\ServletEngine\Security\MappingInterface|null $mapping The URL pattern to authenticator mapping * * @return \AppserverIo\Storage\StorageInterface The storage with the authentication types * @throws \AppserverIo\Http\Authentication\AuthenticationException Is thrown if the authenticator with the passed key is not available */ 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'); }