SlingAuthenticatorBridge.java 2.44 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  javax.servlet.http.HttpServletRequest
 *  javax.servlet.http.HttpServletResponse
 *  org.apache.sling.api.auth.Authenticator
 *  org.apache.sling.api.auth.NoAuthenticationHandlerException
 *  org.apache.sling.auth.core.AuthenticationSupport
 */
package com.day.cq.compat.commonsauth.impl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.sling.api.auth.Authenticator;
import org.apache.sling.commons.auth.AuthenticationSupport;
import org.apache.sling.commons.auth.NoAuthenticationHandlerException;

public class SlingAuthenticatorBridge
implements AuthenticationSupport,
org.apache.sling.commons.auth.Authenticator {
    private org.apache.sling.auth.core.AuthenticationSupport slingAuthenticationSupport;
    private Authenticator slingAuthenticator;

    public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) {
        boolean result = this.slingAuthenticationSupport.handleSecurity(request, response);
        if (result) {
            // empty if block
        }
        return true;
    }

    public void login(HttpServletRequest request, HttpServletResponse response) {
        try {
            this.slingAuthenticator.login(request, response);
        }
        catch (org.apache.sling.api.auth.NoAuthenticationHandlerException slingException) {
            throw new NoAuthenticationHandlerException(slingException.getMessage(), slingException.getCause());
        }
    }

    public void logout(HttpServletRequest request, HttpServletResponse response) {
        this.slingAuthenticator.logout(request, response);
    }

    protected void bindSlingAuthenticationSupport(org.apache.sling.auth.core.AuthenticationSupport authenticationSupport) {
        this.slingAuthenticationSupport = authenticationSupport;
    }

    protected void unbindSlingAuthenticationSupport(org.apache.sling.auth.core.AuthenticationSupport authenticationSupport) {
        if (this.slingAuthenticationSupport == authenticationSupport) {
            this.slingAuthenticationSupport = null;
        }
    }

    protected void bindSlingAuthenticator(Authenticator authenticator) {
        this.slingAuthenticator = authenticator;
    }

    protected void unbindSlingAuthenticator(Authenticator authenticator) {
        if (this.slingAuthenticator == authenticator) {
            this.slingAuthenticator = null;
        }
    }
}