/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.AssertionMessages
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.policy.assertion.AssertionStatus
 *  com.l7tech.policy.assertion.Operation
 *  com.l7tech.policy.assertion.PolicyAssertionException
 *  com.l7tech.util.InvalidDocumentFormatException
 *  com.l7tech.util.Pair
 *  javax.wsdl.Binding
 *  javax.wsdl.Operation
 *  javax.wsdl.WSDLException
 */
package com.l7tech.server.policy.assertion;

import com.l7tech.gateway.common.audit.AssertionMessages;
import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.policy.assertion.AssertionStatus;
import com.l7tech.policy.assertion.Operation;
import com.l7tech.policy.assertion.PolicyAssertionException;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.policy.assertion.AbstractServerAssertion;
import com.l7tech.util.InvalidDocumentFormatException;
import com.l7tech.util.Pair;
import java.io.IOException;
import java.util.logging.Level;
import javax.wsdl.Binding;
import javax.wsdl.WSDLException;
import org.xml.sax.SAXException;

public class ServerOperation
extends AbstractServerAssertion<Operation> {
    private static final String[] d;

    public ServerOperation(Operation operation) {
        super(operation);
    }

    @Override
    public AssertionStatus checkRequest(PolicyEnforcementContext policyEnforcementContext) throws IOException, PolicyAssertionException {
        try {
            Pair<Binding, javax.wsdl.Operation> pair = policyEnforcementContext.getBindingAndOperation();
            if (pair != null) {
                javax.wsdl.Operation operation = (javax.wsdl.Operation)pair.right;
                String string = operation.getName();
                if (((Operation)this.assertion).getOperationName().equals(string)) {
                    return AssertionStatus.NONE;
                }
                this.logAndAudit((AuditDetailMessage)AssertionMessages.WSDLOPERATION_NOMATCH, string, ((Operation)this.assertion).getOperationName());
                return AssertionStatus.FALSIFIED;
            }
        }
        catch (SAXException sAXException) {
            String[] stringArray = d;
            this.logger.log(Level.WARNING, stringArray[1], sAXException);
        }
        catch (InvalidDocumentFormatException invalidDocumentFormatException) {
            String[] stringArray = d;
            this.logger.log(Level.WARNING, stringArray[0], invalidDocumentFormatException);
        }
        catch (WSDLException wSDLException) {
            this.logger.log(Level.WARNING, d[0], wSDLException);
        }
        this.logAndAudit((AuditDetailMessage)AssertionMessages.WSDLOPERATION_CANNOTIDENTIFY);
        return AssertionStatus.FAILED;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "\u001ay\u000br\u0017u?\u001a\u007f\rt\u000b2x\bx\u001dqE:(\u001ay\u0018i\f:6_m\u000br\bu;\u0010e\rx\u001d!)\u001ay\u000br\u0017u?\u001a\u007f\rt\u000b2x\bx\u001dqE:(\u001ay\u0018i\f:6_m\u000br\bu;\u0010e\rx\u001d!";
        int n3 = "\u001ay\u000br\u0017u?\u001a\u007f\rt\u000b2x\bx\u001dqE:(\u001ay\u0018i\f:6_m\u000br\bu;\u0010e\rx\u001d!)\u001ay\u000br\u0017u?\u001a\u007f\rt\u000b2x\bx\u001dqE:(\u001ay\u0018i\f:6_m\u000br\bu;\u0010e\rx\u001d!".length();
        int n4 = 41;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = ServerOperation.b(113, ServerOperation.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                d = 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] ^ 0x29);
        }
        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 -> 14;
                    case 1 -> 122;
                    case 2 -> 8;
                    case 3 -> 108;
                    case 4 -> 20;
                    case 5 -> 36;
                    default -> 41;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

