/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.AssertionMessages
 *  com.l7tech.gateway.common.audit.Audit
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.policy.assertion.ext.CustomAssertion
 *  com.l7tech.policy.assertion.ext.CustomAuditor
 *  com.l7tech.policy.assertion.ext.ServiceInvocation
 */
package com.l7tech.server.policy.custom;

import com.l7tech.gateway.common.audit.AssertionMessages;
import com.l7tech.gateway.common.audit.Audit;
import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.policy.assertion.ext.CustomAssertion;
import com.l7tech.policy.assertion.ext.CustomAuditor;
import com.l7tech.policy.assertion.ext.ServiceInvocation;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;

public class CustomAuditorImpl
implements CustomAuditor {
    private static final Logger a;
    private final Audit b;
    private static final String[] c;

    public CustomAuditorImpl(Audit audit) {
        if (audit == null) {
            throw new IllegalArgumentException(c[0]);
        }
        this.b = audit;
    }

    public void auditInfo(CustomAssertion customAssertion, String string) {
        block4: {
            try {
                try {
                    if (customAssertion == null || string == null) break block4;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw CustomAuditorImpl.a(illegalArgumentException);
                }
                this.b.logAndAudit((AuditDetailMessage)AssertionMessages.CUSTOM_ASSERTION_INFO, new String[]{this.a(customAssertion.getName()), string});
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw CustomAuditorImpl.a(illegalArgumentException);
            }
        }
    }

    public void auditWarning(CustomAssertion customAssertion, String string) {
        block4: {
            try {
                try {
                    if (customAssertion == null || string == null) break block4;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw CustomAuditorImpl.a(illegalArgumentException);
                }
                this.b.logAndAudit((AuditDetailMessage)AssertionMessages.CUSTOM_ASSERTION_WARN, new String[]{this.a(customAssertion.getName()), string});
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw CustomAuditorImpl.a(illegalArgumentException);
            }
        }
    }

    public void register(ServiceInvocation serviceInvocation) {
        try {
            String[] stringArray = c;
            Method method = ServiceInvocation.class.getDeclaredMethod(stringArray[2], CustomAuditor.class);
            method.setAccessible(true);
            method.invoke((Object)serviceInvocation, this);
        }
        catch (Exception exception) {
            a.log(Level.WARNING, c[1], exception);
        }
    }

    private String a(String string) {
        String string2;
        try {
            string2 = string == null ? "" : string;
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw CustomAuditorImpl.a(illegalArgumentException);
        }
        return string2;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[3];
        int n2 = 0;
        String string = "rR\u001c0z[93J\r*z\u0014%|SX;k\u0014%fK\u0014+VU\n6|\u00148vS\f0`SkrR\u001c0z[93A\u0017+.W>`S\u00174.U8`B\n-g[%=\u0010`B\f\u001a{G?|J9,j]?|U";
        int n3 = "rR\u001c0z[93J\r*z\u0014%|SX;k\u0014%fK\u0014+VU\n6|\u00148vS\f0`SkrR\u001c0z[93A\u0017+.W>`S\u00174.U8`B\n-g[%=\u0010`B\f\u001a{G?|J9,j]?|U".length();
        int n4 = 24;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = CustomAuditorImpl.a(127, CustomAuditorImpl.b(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                c = stringArray;
                a = Logger.getLogger(CustomAuditorImpl.class.getName());
                return;
            }
            n4 = string.charAt(n5);
        }
    }

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

    private static char[] b(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x34);
        }
        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 -> 108;
                    case 1 -> 88;
                    case 2 -> 7;
                    case 3 -> 38;
                    case 4 -> 113;
                    case 5 -> 75;
                    default -> 52;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

