/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.Audit
 *  com.l7tech.policy.assertion.xmlsec.RequireSaml
 *  com.l7tech.policy.assertion.xmlsec.SamlAuthenticationStatement
 *  com.l7tech.security.saml.SamlConstants
 *  com.l7tech.util.Pair
 *  org.apache.xmlbeans.XmlObject
 *  x0Assertion.oasisNamesTcSAML1.AuthenticationStatementType
 */
package com.l7tech.server.policy.assertion.xmlsec;

import com.l7tech.gateway.common.audit.Audit;
import com.l7tech.policy.assertion.xmlsec.RequireSaml;
import com.l7tech.policy.assertion.xmlsec.SamlAuthenticationStatement;
import com.l7tech.security.saml.SamlConstants;
import com.l7tech.server.policy.assertion.xmlsec.SamlAssertionValidate;
import com.l7tech.server.policy.assertion.xmlsec.SamlStatementValidate;
import com.l7tech.util.Pair;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import org.apache.xmlbeans.XmlObject;
import x0Assertion.oasisNamesTcSAML1.AuthenticationStatementType;

class l
extends SamlStatementValidate {
    private SamlAuthenticationStatement a;
    private static final String[] c;

    l(RequireSaml requireSaml) {
        super(requireSaml);
        this.a = requireSaml.getAuthenticationStatement();
        if (this.a == null) {
            throw new IllegalArgumentException(c[1]);
        }
    }

    @Override
    protected void validate(XmlObject xmlObject, Collection<SamlAssertionValidate.Error> collection, Collection<Pair<String, String[]>> collection2, Map<String, Object> map, Audit audit) {
        try {
            if (!(xmlObject instanceof AuthenticationStatementType)) {
                throw new IllegalArgumentException(c[0] + String.valueOf(AuthenticationStatementType.class));
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw l.a(illegalArgumentException);
        }
        AuthenticationStatementType authenticationStatementType = (AuthenticationStatementType)xmlObject;
        String string = authenticationStatementType.getAuthenticationMethod();
        if (string == null) {
            SamlAssertionValidate.Error error = new SamlAssertionValidate.Error(c[2], null, new Object[0]);
            collection.add(error);
            this.logger.finer(error.toString());
            return;
        }
        String[] stringArray = this.a(this.a.getAuthenticationMethods());
        String string2 = this.a.getCustomAuthenticationMethods();
        this.validateAuthenticationMethods(string, Arrays.asList(stringArray), string2, collection, map, audit);
    }

    private String[] a(String[] stringArray) {
        return SamlAssertionValidate.a(stringArray, SamlConstants.ALL_AUTHENTICATIONS);
    }

    private static IllegalArgumentException a(IllegalArgumentException illegalArgumentException) {
        return illegalArgumentException;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[3];
        int n2 = 0;
        String string = "S\u0011i:^d/rI3W\u001cm7X~>\u007f\nx+T\u007f$6\u001b|.Hy8s\u0004|1Icj~\bo:\u001d~%bI{:X~je\u0019|<Tv#s\r\"X\u00069\u001eHd\"s\u0007m6^q>\u007f\u0006w\u007fpu>~\u0006}\u007fN`/u\u0000\u007f6Xt";
        int n3 = "S\u0011i:^d/rI3W\u001cm7X~>\u007f\nx+T\u007f$6\u001b|.Hy8s\u0004|1Icj~\bo:\u001d~%bI{:X~je\u0019|<Tv#s\r\"X\u00069\u001eHd\"s\u0007m6^q>\u007f\u0006w\u007fpu>~\u0006}\u007fN`/u\u0000\u007f6Xt".length();
        int n4 = 9;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = l.b(15, l.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                c = 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] ^ 0x45);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(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 -> 25;
                    case 1 -> 102;
                    case 2 -> 22;
                    case 3 -> 80;
                    case 4 -> 50;
                    case 5 -> 31;
                    default -> 69;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

