Search in sources :

Example 1 with RemoteCredentials

use of org.apache.jackrabbit.oak.remote.RemoteCredentials in project jackrabbit-oak by apache.

the class AuthenticationWrapperHandler method handle.

@Override
public void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    RemoteSession session = (RemoteSession) request.getAttribute("session");
    if (session != null) {
        authenticated.handle(request, response);
        return;
    }
    RemoteRepository repository = (RemoteRepository) request.getAttribute("repository");
    if (repository == null) {
        sendInternalServerError(response, "repository not found");
        return;
    }
    RemoteCredentials credentials = extractCredentials(request, repository);
    if (credentials == null) {
        notAuthenticated.handle(request, response);
        return;
    }
    try {
        session = repository.login(credentials);
    } catch (RemoteLoginException e) {
        logger.warn("unable to authenticate to the repository", e);
        notAuthenticated.handle(request, response);
        return;
    }
    request.setAttribute("session", session);
    authenticated.handle(request, response);
}
Also used : RemoteLoginException(org.apache.jackrabbit.oak.remote.RemoteLoginException) RemoteCredentials(org.apache.jackrabbit.oak.remote.RemoteCredentials) RemoteSession(org.apache.jackrabbit.oak.remote.RemoteSession) RemoteRepository(org.apache.jackrabbit.oak.remote.RemoteRepository)

Aggregations

RemoteCredentials (org.apache.jackrabbit.oak.remote.RemoteCredentials)1 RemoteLoginException (org.apache.jackrabbit.oak.remote.RemoteLoginException)1 RemoteRepository (org.apache.jackrabbit.oak.remote.RemoteRepository)1 RemoteSession (org.apache.jackrabbit.oak.remote.RemoteSession)1