class AccessTokenAuthenticationStrategy implements AuthenticationStrategy {

    @Override
    public Mono<MailboxSession> createMailboxSession(HttpServerRequest httpRequest) {
        return Mono.fromCallable(() -> authHeaders(httpRequest))
            .filter(tokenString -> !tokenString.startsWith("Bearer"))
            .map(AccessToken::fromString)
            .filterWhen(accessTokenManager::isValid)
            .flatMap(item -> Mono.from(accessTokenManager.getUsernameFromToken(item)))
            .map(mailboxManager::createSystemSession)
            .onErrorResume(InvalidAccessToken.class, error -> Mono.error(new UnauthorizedException("Invalid access token", error)))
            .onErrorResume(NotAnAccessTokenException.class, error -> Mono.error(new UnauthorizedException("Not an access token", error)));
    }

    @Inject @VisibleForTesting  AccessTokenAuthenticationStrategy(AccessTokenManager accessTokenManager, MailboxManager mailboxManager);

}