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

import com.l7tech.common.http.GenericHttpClient;
import com.l7tech.common.http.GenericHttpException;
import com.l7tech.common.http.HttpConstants;
import com.l7tech.common.http.HttpHeaders;
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 com.l7tech.xml.saml.SamlAssertion;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;

class c
implements RoutingResultListener {
    final GenericHttpClient val$httpClient;
    final SamlAssertion val$samlAssertion;
    final String val$replyUrl;
    final String val$contextUrl;
    final AbstractServerWsFederationPassiveRequestProfile this$0;
    private static final String[] a;

    /*
     * Ignored method signature, as it can't be verified against descriptor
     */
    c(AbstractServerWsFederationPassiveRequestProfile abstractServerWsFederationPassiveRequestProfile, GenericHttpClient genericHttpClient, SamlAssertion samlAssertion, String string, String string2) {
        this.this$0 = abstractServerWsFederationPassiveRequestProfile;
        this.val$httpClient = genericHttpClient;
        this.val$samlAssertion = samlAssertion;
        this.val$replyUrl = string;
        this.val$contextUrl = string2;
    }

    @Override
    public boolean reroute(URL uRL, int n2, HttpHeaders httpHeaders, PolicyEnforcementContext policyEnforcementContext) {
        boolean bl2;
        block13: {
            bl2 = false;
            try {
                if (n2 != 302 && n2 != 303) break block13;
            }
            catch (AbstractServerWsFederationPassiveRequestProfile.AuthRequiredException authRequiredException) {
                throw c.a(authRequiredException);
            }
            try {
                String string;
                block14: {
                    string = httpHeaders.getOnlyOneValue(HttpConstants.HEADER_LOCATION);
                    try {
                        if (string != null) break block14;
                        AbstractServerWsFederationPassiveRequestProfile.access$400(this.this$0).info(a[2]);
                        break block13;
                    }
                    catch (AbstractServerWsFederationPassiveRequestProfile.AuthRequiredException authRequiredException) {
                        throw c.a(authRequiredException);
                    }
                }
                if (!FederationPassiveClient.isFederationServerUrl((URL)new URL(uRL, string))) break block13;
                try {
                    try {
                        if (AbstractServerWsFederationPassiveRequestProfile.access$500(this.this$0).isLoggable(Level.FINER)) {
                            AbstractServerWsFederationPassiveRequestProfile.access$600(this.this$0).log(Level.FINER, a[0]);
                        }
                    }
                    catch (AbstractServerWsFederationPassiveRequestProfile.AuthRequiredException authRequiredException) {
                        throw c.a(authRequiredException);
                    }
                    this.this$0.a(policyEnforcementContext, this.val$httpClient, this.val$samlAssertion, this.val$replyUrl, this.val$contextUrl);
                    bl2 = true;
                }
                catch (AbstractServerWsFederationPassiveRequestProfile.AuthRequiredException authRequiredException) {
                }
                catch (AbstractServerWsFederationPassiveRequestProfile.StopAndAuditException stopAndAuditException) {
                    AbstractServerWsFederationPassiveRequestProfile.access$700(this.this$0, (AuditDetailMessage)stopAndAuditException.getAssertionMessage(), null, stopAndAuditException.getCause());
                }
            }
            catch (GenericHttpException genericHttpException) {
                String[] stringArray = a;
                AbstractServerWsFederationPassiveRequestProfile.access$800(this.this$0).info(stringArray[3]);
            }
            catch (MalformedURLException malformedURLException) {
                AbstractServerWsFederationPassiveRequestProfile.access$900(this.this$0).log(Level.INFO, a[1], malformedURLException);
            }
        }
        return bl2;
    }

    @Override
    public void routed(URL uRL, int n2, HttpHeaders httpHeaders, PolicyEnforcementContext policyEnforcementContext) {
    }

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

    private static AbstractServerWsFederationPassiveRequestProfile.AuthRequiredException a(AbstractServerWsFederationPassiveRequestProfile.AuthRequiredException authRequiredException) {
        return authRequiredException;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[4];
                var3_1 = 0;
                var2_2 = "?\u0014C\u007fXg\u0017O/\u007f@TgP\u001b40XT{\u0006\u00068u\u000bPo\u0004\n)0JD}\u0018O=qB]|\u0002\nu\u0015&5fJ]`\u0014O)uOX{\u0015\f/0^Ce^";
                var4_3 = "?\u0014C\u007fXg\u0017O/\u007f@TgP\u001b40XT{\u0006\u00068u\u000bPo\u0004\n)0JD}\u0018O=qB]|\u0002\nu\u0015&5fJ]`\u0014O)uOX{\u0015\f/0^Ce^".length();
                var1_4 = 44;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 73;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = c.a(v0, c.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u0007\u0014Gk|A5n\u0012TktM#=ZWx\u007fEq=\u001fC|yK4bZ\\cc[8 \u001d\u0011xuL8<\u001fR~0D>-\u001bEc\u007fF\u007f:\u0007\u0014Gk|A5n\u0012TktM#=ZWx\u007fEq=\u001fC|yK4bZ\\\u007f|\\8>\u0016T*bM5'\bTid\b=!\u0019P~yG?=T";
                    var4_3 = "\u0007\u0014Gk|A5n\u0012TktM#=ZWx\u007fEq=\u001fC|yK4bZ\\cc[8 \u001d\u0011xuL8<\u001fR~0D>-\u001bEc\u007fF\u007f:\u0007\u0014Gk|A5n\u0012TktM#=ZWx\u007fEq=\u001fC|yK4bZ\\\u007f|\\8>\u0016T*bM5'\bTid\b=!\u0019P~yG?=T".length();
                    var1_4 = 56;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 104;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = c.a(v0, c.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        c.a = var5;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x39);
        }
        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 -> 38;
                    case 1 -> 18;
                    case 2 -> 89;
                    case 3 -> 98;
                    case 4 -> 120;
                    case 5 -> 64;
                    default -> 57;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

