/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.http.GenericHttpException
 *  com.l7tech.common.http.HttpConstants
 *  com.l7tech.common.http.HttpHeaders
 *  com.l7tech.gateway.common.audit.AssertionMessages
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.security.wsfederation.FederationPassiveClient
 */
package com.l7tech.server.policy.assertion.credential;

import com.l7tech.common.http.GenericHttpException;
import com.l7tech.common.http.HttpConstants;
import com.l7tech.common.http.HttpHeaders;
import com.l7tech.gateway.common.audit.AssertionMessages;
import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.security.wsfederation.FederationPassiveClient;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.policy.assertion.RoutingResultListener;
import com.l7tech.server.policy.assertion.credential.AbstractServerWsFederationPassiveRequestProfile;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;

class b
implements RoutingResultListener {
    final AbstractServerWsFederationPassiveRequestProfile this$0;
    private static final String[] a;

    b(AbstractServerWsFederationPassiveRequestProfile abstractServerWsFederationPassiveRequestProfile) {
        this.this$0 = abstractServerWsFederationPassiveRequestProfile;
    }

    @Override
    public boolean reroute(URL uRL, int n2, HttpHeaders httpHeaders, PolicyEnforcementContext policyEnforcementContext) {
        return false;
    }

    @Override
    public void routed(URL uRL, int n2, HttpHeaders httpHeaders, PolicyEnforcementContext policyEnforcementContext) {
        block10: {
            try {
                if (n2 != 302 && n2 != 303) break block10;
            }
            catch (GenericHttpException genericHttpException) {
                throw b.a(genericHttpException);
            }
            try {
                String string;
                block11: {
                    string = httpHeaders.getOnlyOneValue(HttpConstants.HEADER_LOCATION);
                    try {
                        if (string != null) break block11;
                        AbstractServerWsFederationPassiveRequestProfile.access$000(this.this$0).info(a[2]);
                        break block10;
                    }
                    catch (GenericHttpException genericHttpException) {
                        throw b.a(genericHttpException);
                    }
                }
                try {
                    if (FederationPassiveClient.isFederationServerUrl((URL)new URL(uRL, string))) {
                        AbstractServerWsFederationPassiveRequestProfile.access$100(this.this$0, (AuditDetailMessage)AssertionMessages.WSFEDPASS_UNAUTHORIZED);
                    }
                }
                catch (GenericHttpException genericHttpException) {
                    throw b.a(genericHttpException);
                }
            }
            catch (GenericHttpException genericHttpException) {
                String[] stringArray = a;
                AbstractServerWsFederationPassiveRequestProfile.access$200(this.this$0).info(stringArray[0]);
            }
            catch (MalformedURLException malformedURLException) {
                AbstractServerWsFederationPassiveRequestProfile.access$300(this.this$0).log(Level.INFO, a[1], malformedURLException);
            }
        }
    }

    @Override
    public void failed(URL uRL, Throwable throwable, PolicyEnforcementContext policyEnforcementContext) {
    }

    private static GenericHttpException a(GenericHttpException genericHttpException) {
        return genericHttpException;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[3];
        int n2 = 0;
        String string = "^d=k\u0016917b.k\u001e5'd*-x\u0015=udo9|\u001330;*&\u007f\u0016$<gf.*\b51~x.i\u000ep9xi*~\u0013?;d$\u0015^d=k\u0016917x.n\u0013\"0t~k\u007f\b<{8^d=k\u0016917b.k\u001e5'd*-x\u0015=udo9|\u001330;*&c\t#<ymkx\u001f4<eo(~Z<:tk?c\u0015>{";
        int n3 = "^d=k\u0016917b.k\u001e5'd*-x\u0015=udo9|\u001330;*&\u007f\u0016$<gf.*\b51~x.i\u000ep9xi*~\u0013?;d$\u0015^d=k\u0016917x.n\u0013\"0t~k\u007f\b<{8^d=k\u0016917b.k\u001e5'd*-x\u0015=udo9|\u001330;*&c\t#<ymkx\u001f4<eo(~Z<:tk?c\u0015>{".length();
        int n4 = 58;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = b.a(109, b.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                a = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x38);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 122;
                    case 1 -> 103;
                    case 2 -> 38;
                    case 3 -> 103;
                    case 4 -> 23;
                    case 5 -> 61;
                    default -> 56;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

