AuthenticationHandlerBridge.java 2.66 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  javax.servlet.http.HttpServletRequest
 *  javax.servlet.http.HttpServletResponse
 *  org.apache.sling.auth.core.spi.AuthenticationHandler
 *  org.apache.sling.auth.core.spi.AuthenticationInfo
 */
package com.day.cq.compat.commonsauth.impl;

import com.day.cq.compat.commonsauth.impl.Bridge;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.sling.auth.core.spi.AuthenticationInfo;
import org.apache.sling.commons.auth.spi.AuthenticationHandler;

public class AuthenticationHandlerBridge
implements org.apache.sling.auth.core.spi.AuthenticationHandler,
Bridge {
    private final AuthenticationHandler delegatee;

    AuthenticationHandlerBridge(AuthenticationHandler delegatee) {
        this.delegatee = delegatee;
    }

    public String getServiceName() {
        return "org.apache.sling.auth.core.spi.AuthenticationHandler";
    }

    protected AuthenticationHandler getDelegatee() {
        return this.delegatee;
    }

    public AuthenticationInfo extractCredentials(HttpServletRequest request, HttpServletResponse response) {
        org.apache.sling.commons.auth.spi.AuthenticationInfo interimAuthInfo = this.getDelegatee().extractCredentials(request, response);
        if (interimAuthInfo == null) {
            return null;
        }
        if (interimAuthInfo == org.apache.sling.commons.auth.spi.AuthenticationInfo.DOING_AUTH) {
            return AuthenticationInfo.DOING_AUTH;
        }
        if (interimAuthInfo == org.apache.sling.commons.auth.spi.AuthenticationInfo.FAIL_AUTH) {
            return AuthenticationInfo.FAIL_AUTH;
        }
        AuthenticationInfo authInfo = new AuthenticationInfo(interimAuthInfo.getAuthType());
        authInfo.putAll((Map)interimAuthInfo);
        return authInfo;
    }

    public boolean requestCredentials(HttpServletRequest request, HttpServletResponse response) throws IOException {
        return this.getDelegatee().requestCredentials(request, response);
    }

    public void dropCredentials(HttpServletRequest request, HttpServletResponse response) throws IOException {
        this.getDelegatee().dropCredentials(request, response);
    }

    public boolean equals(Object obj) {
        if (obj instanceof AuthenticationHandlerBridge) {
            return this.getDelegatee() == ((AuthenticationHandlerBridge)obj).getDelegatee();
        }
        return false;
    }

    public int hashCode() {
        return this.getDelegatee().hashCode();
    }

    public String toString() {
        return "Bridged: " + this.getDelegatee().toString();
    }
}