AuthenticationInfoPostProcessorBridge.java 2.75 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.AuthenticationInfo
 *  org.apache.sling.auth.core.spi.AuthenticationInfoPostProcessor
 */
package com.day.cq.compat.commonsauth.impl;

import com.day.cq.compat.commonsauth.impl.Bridge;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.sling.auth.core.spi.AuthenticationInfoPostProcessor;
import org.apache.sling.commons.auth.spi.AuthenticationInfo;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public class AuthenticationInfoPostProcessorBridge
implements AuthenticationInfoPostProcessor,
Bridge {
    private final org.apache.sling.commons.auth.spi.AuthenticationInfoPostProcessor delegatee;

    AuthenticationInfoPostProcessorBridge(org.apache.sling.commons.auth.spi.AuthenticationInfoPostProcessor delegatee) {
        this.delegatee = delegatee;
    }

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

    public void postProcess(org.apache.sling.auth.core.spi.AuthenticationInfo info, HttpServletRequest request, HttpServletResponse response) {
        AuthenticationInfo interimAuthInfo = new AuthenticationInfo(info.getAuthType());
        this.putAllButAuthType((HashMap<String, Object>)info, interimAuthInfo);
        this.delegatee.postProcess(interimAuthInfo, request, response);
        this.clearAllButAuthType((HashMap<String, Object>)info);
        this.putAllButAuthType(interimAuthInfo, (HashMap<String, Object>)info);
    }

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

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

    private void putAllButAuthType(HashMap<String, Object> source, HashMap<String, Object> destination) {
        for (Map.Entry<String, Object> entry : source.entrySet()) {
            String key = entry.getKey();
            if ("sling.authType".equals(key)) continue;
            destination.put(key, entry.getValue());
        }
    }

    private void clearAllButAuthType(HashMap<String, Object> map) {
        Iterator<String> iterator = map.keySet().iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            if ("sling.authType".equals(key)) continue;
            iterator.remove();
        }
    }
}