/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.mime.ContentTypeHeader
 *  com.l7tech.common.mime.NoSuchPartException
 *  com.l7tech.common.mime.PartInfo
 *  com.l7tech.common.mime.PartIterator
 *  com.l7tech.gateway.common.audit.AssertionMessages
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.policy.assertion.AssertionStatus
 *  com.l7tech.policy.assertion.PolicyAssertionException
 *  com.l7tech.policy.assertion.RequestSwAAssertion
 *  com.l7tech.security.token.SignedPart
 *  com.l7tech.security.xml.processor.ProcessorResult
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.InvalidDocumentFormatException
 *  com.l7tech.util.Option
 *  com.l7tech.wsdl.BindingInfo
 *  com.l7tech.wsdl.BindingOperationInfo
 *  com.l7tech.wsdl.MimePartInfo
 *  com.l7tech.xml.soap.SoapUtil
 *  org.jaxen.JaxenException
 *  org.jaxen.dom.DOMXPath
 */
package com.l7tech.server.policy.assertion;

import com.l7tech.common.mime.ContentTypeHeader;
import com.l7tech.common.mime.NoSuchPartException;
import com.l7tech.common.mime.PartInfo;
import com.l7tech.common.mime.PartIterator;
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.PolicyAssertionException;
import com.l7tech.policy.assertion.RequestSwAAssertion;
import com.l7tech.security.token.SignedPart;
import com.l7tech.security.xml.processor.ProcessorResult;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.policy.assertion.AbstractServerAssertion;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.InvalidDocumentFormatException;
import com.l7tech.util.Option;
import com.l7tech.wsdl.BindingInfo;
import com.l7tech.wsdl.BindingOperationInfo;
import com.l7tech.wsdl.MimePartInfo;
import com.l7tech.xml.soap.SoapUtil;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import org.jaxen.JaxenException;
import org.jaxen.dom.DOMXPath;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class ServerRequestSwAAssertion
extends AbstractServerAssertion<RequestSwAAssertion> {
    private static final long d = 1024L;
    private static final String[] e;

    public ServerRequestSwAAssertion(RequestSwAAssertion requestSwAAssertion) {
        super(requestSwAAssertion);
    }

    @Override
    public AssertionStatus checkRequest(PolicyEnforcementContext policyEnforcementContext) throws IOException, PolicyAssertionException {
        try {
            if (!policyEnforcementContext.getRequest().isSoap()) {
                this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_NOT_SOAP);
                return AssertionStatus.NOT_APPLICABLE;
            }
        }
        catch (IOException iOException) {
            throw ServerRequestSwAAssertion.a(iOException);
        }
        catch (SAXException sAXException) {
            this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_INVALID_XML, ExceptionUtils.getMessage((Throwable)sAXException));
            return AssertionStatus.BAD_REQUEST;
        }
        try {
            if (!policyEnforcementContext.getRequest().getMimeKnob().isMultipart()) {
                this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_NOT_MULTIPART);
                return AssertionStatus.FALSIFIED;
            }
        }
        catch (SAXException sAXException) {
            throw ServerRequestSwAAssertion.a(sAXException);
        }
        try {
            Document document = policyEnforcementContext.getRequest().getXmlKnob().getDocumentReadOnly();
            this.a(policyEnforcementContext, document);
        }
        catch (SAXException sAXException) {
            String[] stringArray = new String[1];
            String[] stringArray2 = e;
            stringArray[0] = stringArray2[33];
            this.logAndAudit((AuditDetailMessage)AssertionMessages.EXCEPTION_WARNING_WITH_MORE_INFO, stringArray, sAXException);
            return AssertionStatus.SERVER_ERROR;
        }
        catch (IOException iOException) {
            String[] stringArray = new String[1];
            String[] stringArray3 = e;
            stringArray[0] = stringArray3[26];
            this.logAndAudit((AuditDetailMessage)AssertionMessages.EXCEPTION_WARNING_WITH_MORE_INFO, stringArray, iOException);
            return AssertionStatus.SERVER_ERROR;
        }
        catch (JaxenException jaxenException) {
            String[] stringArray = new String[1];
            String[] stringArray4 = e;
            stringArray[0] = stringArray4[26];
            this.logAndAudit((AuditDetailMessage)AssertionMessages.EXCEPTION_WARNING_WITH_MORE_INFO, stringArray, jaxenException);
            return AssertionStatus.SERVER_ERROR;
        }
        catch (NoSuchPartException noSuchPartException) {
            String[] stringArray = new String[1];
            String[] stringArray5 = e;
            stringArray[0] = stringArray5[1] + noSuchPartException.getWhatWasMissing() + stringArray5[29];
            this.logAndAudit((AuditDetailMessage)AssertionMessages.EXCEPTION_INFO_WITH_MORE_INFO, stringArray, noSuchPartException);
            return AssertionStatus.FALSIFIED;
        }
        catch (AttachmentProcessingException attachmentProcessingException) {
            this.logger.log(Level.INFO, e[23], attachmentProcessingException.getMessage());
            return attachmentProcessingException.getAssertionStatus();
        }
        return AssertionStatus.NONE;
    }

    private DOMXPath a(String string) throws JaxenException {
        DOMXPath dOMXPath = null;
        Map map = ((RequestSwAAssertion)this.assertion).getNamespaceMap();
        if (string != null) {
            dOMXPath = new DOMXPath(string);
            if (map != null) {
                for (Map.Entry entry : map.entrySet()) {
                    String string2 = (String)entry.getKey();
                    String string3 = (String)entry.getValue();
                    dOMXPath.addNamespace(string2, string3);
                }
            }
        }
        return dOMXPath;
    }

    private void a(PolicyEnforcementContext policyEnforcementContext, Document document) throws JaxenException, IOException, NoSuchPartException, SAXException, AttachmentProcessingException {
        Map map = ((RequestSwAAssertion)this.assertion).getBindings();
        for (String string : map.keySet()) {
            BindingInfo bindingInfo = (BindingInfo)map.get(string);
            for (String string2 : bindingInfo.getBindingOperations().keySet()) {
                List list;
                BindingOperationInfo bindingOperationInfo;
                block15: {
                    bindingOperationInfo = (BindingOperationInfo)bindingInfo.getBindingOperations().get(string2);
                    DOMXPath dOMXPath = this.a(bindingOperationInfo.getXpath());
                    list = dOMXPath.selectNodes((Object)document);
                    try {
                        try {
                            if (list != null && list.size() != 0) break block15;
                        }
                        catch (JaxenException jaxenException) {
                            throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                        }
                        this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_OPERATION_NOT_FOUND, bindingOperationInfo.getXpath());
                        continue;
                    }
                    catch (JaxenException jaxenException) {
                        throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                    }
                }
                try {
                    if (list.size() > 1) {
                        this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_REPEATED_OPERATION, bindingOperationInfo.getXpath());
                        throw new AttachmentProcessingException(e[2], AssertionStatus.FALSIFIED);
                    }
                }
                catch (JaxenException jaxenException) {
                    throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                }
                Object e10 = list.get(0);
                try {
                    if (!(e10 instanceof Node)) {
                        throw new RuntimeException(e[17]);
                    }
                }
                catch (JaxenException jaxenException) {
                    throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                }
                Node node = (Node)e10;
                short s2 = node.getNodeType();
                try {
                    if (s2 != 1) {
                        this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_OPERATION_NOT_ELEMENT_NODE, bindingOperationInfo.getXpath(), node.toString());
                        throw new AttachmentProcessingException(e[21], AssertionStatus.FAILED);
                    }
                }
                catch (JaxenException jaxenException) {
                    throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                }
                this.a(policyEnforcementContext, document, bindingOperationInfo);
                return;
            }
        }
        this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_INVALID_OPERATION);
        throw new AttachmentProcessingException(e[22], AssertionStatus.FALSIFIED);
    }

    private void a(PolicyEnforcementContext policyEnforcementContext, Document document, BindingOperationInfo bindingOperationInfo) throws JaxenException, IOException, NoSuchPartException, SAXException, AttachmentProcessingException {
        MimePartInfo mimePartInfo;
        this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_OPERATION_FOUND, bindingOperationInfo.getName());
        ProcessorResult processorResult = null;
        for (String string : bindingOperationInfo.getMultipart().keySet()) {
            mimePartInfo = (MimePartInfo)bindingOperationInfo.getMultipart().get(string);
            if (!mimePartInfo.isRequireSignature()) continue;
            processorResult = policyEnforcementContext.getRequest().getSecurityKnob().getProcessorResult();
            break;
        }
        for (String string : bindingOperationInfo.getMultipart().keySet()) {
            List list;
            block22: {
                List list2;
                mimePartInfo = (MimePartInfo)bindingOperationInfo.getMultipart().get(string);
                Option option = Option.none();
                try {
                    option = Option.optional((Object)this.a(bindingOperationInfo.getXpath() + "/" + mimePartInfo.getName()));
                }
                catch (JaxenException jaxenException) {
                    // empty catch block
                }
                try {
                    list2 = option.isSome() ? ((DOMXPath)option.some()).selectNodes((Object)document) : null;
                }
                catch (JaxenException jaxenException) {
                    throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                }
                list = list2;
                try {
                    try {
                        if (list != null && list.size() != 0) break block22;
                    }
                    catch (JaxenException jaxenException) {
                        throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                    }
                    this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_PART_NOT_FOUND, bindingOperationInfo.getXpath(), mimePartInfo.getName());
                    throw new AttachmentProcessingException(e[24] + mimePartInfo.getName(), AssertionStatus.FALSIFIED);
                }
                catch (JaxenException jaxenException) {
                    throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                }
            }
            try {
                if (list.size() > 1) {
                    this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_REPEATED_MIME_PART, bindingOperationInfo.getXpath(), mimePartInfo.getName());
                    throw new AttachmentProcessingException(e[5] + mimePartInfo.getName(), AssertionStatus.FALSIFIED);
                }
            }
            catch (JaxenException jaxenException) {
                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
            }
            Object e10 = list.get(0);
            try {
                if (!(e10 instanceof Node)) {
                    throw new RuntimeException(e[18]);
                }
            }
            catch (JaxenException jaxenException) {
                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
            }
            Node node = (Node)e10;
            short s2 = node.getNodeType();
            try {
                if (s2 != 1) {
                    this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_PARAMETER_NOT_ELEMENT_NODE, bindingOperationInfo.getXpath(), mimePartInfo.getName(), node.toString());
                    throw new AttachmentProcessingException(e[7] + mimePartInfo.getName(), AssertionStatus.FAILED);
                }
            }
            catch (JaxenException jaxenException) {
                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
            }
            this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_PARAMETER_FOUND, mimePartInfo.getName());
            Element element = (Element)node;
            List<Attr> list3 = this.a(element);
            try {
                if (list3.isEmpty()) {
                    this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_REFERENCE_NOT_FOUND, mimePartInfo.getName());
                    throw new AttachmentProcessingException(e[16] + mimePartInfo.getName(), AssertionStatus.FALSIFIED);
                }
            }
            catch (JaxenException jaxenException) {
                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
            }
            this.a(policyEnforcementContext, mimePartInfo, list3, processorResult);
        }
        this.a(policyEnforcementContext, bindingOperationInfo);
    }

    private int a(PolicyEnforcementContext policyEnforcementContext, MimePartInfo mimePartInfo, List<Attr> list, ProcessorResult processorResult) throws JaxenException, IOException, NoSuchPartException, SAXException, AttachmentProcessingException {
        int n2 = 0;
        for (Attr attr : list) {
            String string;
            block23: {
                PartInfo partInfo;
                block29: {
                    block31: {
                        block30: {
                            block26: {
                                block28: {
                                    block27: {
                                        block24: {
                                            string = attr.getValue();
                                            this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_REFERENCE_FOUND, mimePartInfo.getName(), string);
                                            int n3 = string.indexOf(":");
                                            try {
                                                if (n3 < 0) {
                                                    this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_INVALID_CONTENT_ID_URL, string);
                                                    throw new AttachmentProcessingException(e[32] + string, AssertionStatus.FALSIFIED);
                                                }
                                            }
                                            catch (JaxenException jaxenException) {
                                                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                                            }
                                            String string2 = string.substring(0, n3);
                                            String string3 = string.substring(n3 + 1);
                                            try {
                                                if (!e[25].equals(string2)) {
                                                    this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_INVALID_CONTENT_ID_URL, string);
                                                    throw new AttachmentProcessingException(e[27] + string, AssertionStatus.FALSIFIED);
                                                }
                                            }
                                            catch (JaxenException jaxenException) {
                                                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                                            }
                                            partInfo = policyEnforcementContext.getRequest().getMimeKnob().getPartByContentId(string3);
                                            try {
                                                block25: {
                                                    try {
                                                        try {
                                                            try {
                                                                if (partInfo == null) break block23;
                                                                if (!mimePartInfo.isRequireSignature()) break block24;
                                                            }
                                                            catch (JaxenException jaxenException) {
                                                                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                                                            }
                                                            if (processorResult == null) break block25;
                                                        }
                                                        catch (JaxenException jaxenException) {
                                                            throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                                                        }
                                                        if (this.a(partInfo, processorResult.getPartsThatWereSigned())) break block24;
                                                    }
                                                    catch (JaxenException jaxenException) {
                                                        throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                                                    }
                                                }
                                                this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_NOT_SIGNED, mimePartInfo.getName(), string);
                                                throw new AttachmentProcessingException(e[9] + mimePartInfo.getName(), AssertionStatus.FALSIFIED);
                                            }
                                            catch (JaxenException jaxenException) {
                                                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                                            }
                                        }
                                        try {
                                            try {
                                                if (mimePartInfo.validateContentType(partInfo.getContentType())) break block26;
                                                if (mimePartInfo.getContentTypes().length <= 1) break block27;
                                            }
                                            catch (JaxenException jaxenException) {
                                                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                                            }
                                            this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_NOT_IN_CONTENT_TYPES, string, mimePartInfo.retrieveAllContentTypes());
                                            break block28;
                                        }
                                        catch (JaxenException jaxenException) {
                                            throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                                        }
                                    }
                                    this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_BAD_CONTENT_TYPE, string, mimePartInfo.retrieveAllContentTypes());
                                }
                                String[] stringArray = e;
                                throw new AttachmentProcessingException(stringArray[8] + mimePartInfo.getName(), AssertionStatus.FALSIFIED);
                            }
                            n2 += (int)partInfo.getActualContentLength();
                            try {
                                try {
                                    if ((long)n2 <= (long)mimePartInfo.getMaxLength() * 1024L) break block29;
                                    if (list.size() <= 1) break block30;
                                }
                                catch (JaxenException jaxenException) {
                                    throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                                }
                                this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_TOTAL_LENGTH_LIMIT_EXCEEDED, mimePartInfo.getName(), String.valueOf(list.size()), String.valueOf(mimePartInfo.getMaxLength()));
                                break block31;
                            }
                            catch (JaxenException jaxenException) {
                                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                            }
                        }
                        this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_PART_LENGTH_LIMIT_EXCEEDED, string, String.valueOf(mimePartInfo.getMaxLength()));
                    }
                    String[] stringArray = e;
                    throw new AttachmentProcessingException(stringArray[20] + mimePartInfo.getName(), AssertionStatus.FALSIFIED);
                }
                partInfo.setValidated(true);
                continue;
            }
            this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_NO_ATTACHMENT, string);
            throw new AttachmentProcessingException(e[0] + mimePartInfo.getName(), AssertionStatus.FALSIFIED);
        }
        return n2;
    }

    private boolean a(PartInfo partInfo, SignedPart[] signedPartArray) {
        boolean bl2 = false;
        String string = partInfo.getContentId(true);
        for (SignedPart signedPart : signedPartArray) {
            PartInfo partInfo2 = signedPart.getPartInfo();
            String string2 = partInfo2.getContentId(true);
            try {
                if (string2 == null || !string2.equals(string)) continue;
            }
            catch (RuntimeException runtimeException) {
                throw ServerRequestSwAAssertion.a(runtimeException);
            }
            bl2 = true;
        }
        return bl2;
    }

    private void a(PolicyEnforcementContext policyEnforcementContext, BindingOperationInfo bindingOperationInfo) throws JaxenException, IOException, NoSuchPartException, SAXException, AttachmentProcessingException {
        int n2 = ((RequestSwAAssertion)this.assertion).getUnboundAttachmentPolicy();
        Map<String, long[]> map = this.a(bindingOperationInfo);
        HashSet<PartInfo> hashSet = new HashSet<PartInfo>();
        PartIterator partIterator = policyEnforcementContext.getRequest().getMimeKnob().getParts();
        while (partIterator.hasNext()) {
            Object object;
            PartInfo partInfo;
            block20: {
                String[] stringArray;
                block21: {
                    block19: {
                        partInfo = partIterator.next();
                        try {
                            if (partInfo.getPosition() == 0) {
                                continue;
                            }
                        }
                        catch (JaxenException jaxenException) {
                            throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                        }
                        object = partInfo.getContentId(true);
                        try {
                            if (object != null && ((String)object).length() >= 1) break block19;
                        }
                        catch (JaxenException jaxenException) {
                            throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                        }
                        stringArray = e;
                        object = stringArray[28] + partInfo.getPosition();
                    }
                    if (partInfo.isValidated()) continue;
                    long[] lArray = this.a(partInfo, map);
                    try {
                        try {
                            if (lArray == null) break block20;
                            if (!this.a(partInfo, lArray)) break block21;
                        }
                        catch (JaxenException jaxenException) {
                            throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                        }
                        this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_EXTRA_ATTACHMENT, new String[]{object});
                        partInfo.setValidated(true);
                        continue;
                    }
                    catch (JaxenException jaxenException) {
                        throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
                    }
                }
                stringArray = e;
                throw new AttachmentProcessingException(stringArray[10] + (String)object, AssertionStatus.FALSIFIED);
            }
            try {
                if (n2 == 2) {
                    this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_EXTRA_ATTACHMENT, new String[]{object});
                    partInfo.setValidated(true);
                    continue;
                }
            }
            catch (JaxenException jaxenException) {
                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
            }
            try {
                if (n2 == 1) {
                    this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_EXTRA_ATTACHMENT_DROPPED, new String[]{object});
                    hashSet.add(partInfo);
                    continue;
                }
            }
            catch (JaxenException jaxenException) {
                throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
            }
            this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_UNEXPECTED_ATTACHMENT, new String[]{object});
            throw new AttachmentProcessingException(e[4] + (String)object, AssertionStatus.FALSIFIED);
        }
        try {
            if (!hashSet.isEmpty()) {
                this.a(policyEnforcementContext, hashSet);
            }
        }
        catch (JaxenException jaxenException) {
            throw ServerRequestSwAAssertion.a((Exception)((Object)jaxenException));
        }
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private void a(PolicyEnforcementContext policyEnforcementContext, Set<PartInfo> set) throws IOException, SAXException {
        policyEnforcementContext.getRequest().getMimeKnob().setStreamValidatedPartsOnly();
        Document document = policyEnforcementContext.getRequest().getXmlKnob().getDocumentWritable();
        try {
            Element element = SoapUtil.getBodyElement((Document)document);
            try {
                if (element == null) {
                    throw new SAXException(e[3]);
                }
            }
            catch (InvalidDocumentFormatException invalidDocumentFormatException) {
                throw ServerRequestSwAAssertion.a((Exception)((Object)invalidDocumentFormatException));
            }
            for (PartInfo partInfo : set) {
                String string = partInfo.getContentId(true);
                try {
                    if (string == null) continue;
                    this.a(element, e[14] + string);
                }
                catch (InvalidDocumentFormatException invalidDocumentFormatException) {
                    throw ServerRequestSwAAssertion.a((Exception)((Object)invalidDocumentFormatException));
                    return;
                }
            }
        }
        catch (InvalidDocumentFormatException invalidDocumentFormatException) {
            throw (SAXException)new SAXException(e[11]).initCause(invalidDocumentFormatException);
        }
    }

    private Map<String, long[]> a(BindingOperationInfo bindingOperationInfo) {
        HashMap<String, long[]> hashMap = new HashMap<String, long[]>();
        Map map = bindingOperationInfo.getExtraMultipart();
        for (Map.Entry entry : map.entrySet()) {
            String string = (String)entry.getKey();
            MimePartInfo mimePartInfo = (MimePartInfo)entry.getValue();
            long l2 = (long)mimePartInfo.getMaxLength() * 1024L;
            hashMap.put(string, new long[]{l2, l2});
        }
        return hashMap;
    }

    private void a(Element element, String string) {
        Element element2;
        int n2;
        NodeList nodeList = element.getChildNodes();
        ArrayList<Element> arrayList = new ArrayList<Element>();
        for (n2 = 0; n2 < nodeList.getLength(); ++n2) {
            Node node2 = nodeList.item(n2);
            if (node2.getNodeType() != 1) continue;
            element2 = (Element)node2;
            try {
                if (!string.equals(element2.getAttribute(e[19]))) continue;
                arrayList.add(element2);
                continue;
            }
            catch (RuntimeException runtimeException) {
                throw ServerRequestSwAAssertion.a(runtimeException);
            }
        }
        if (!arrayList.isEmpty()) {
            for (Element element3 : arrayList) {
                element2 = (Element)element3.getParentNode();
                element2.removeChild(element3);
            }
        }
        nodeList = element.getChildNodes();
        for (n2 = 0; n2 < nodeList.getLength(); ++n2) {
            Node node = nodeList.item(n2);
            try {
                if (node.getNodeType() != 1) continue;
                this.a((Element)node, string);
                continue;
            }
            catch (RuntimeException runtimeException) {
                throw ServerRequestSwAAssertion.a(runtimeException);
            }
        }
    }

    private List<Attr> a(Element element) {
        ArrayList<Attr> arrayList = new ArrayList<Attr>();
        String[] stringArray = e;
        Attr attr = element.getAttributeNode(stringArray[15]);
        if (attr == null) {
            Node node = element.getFirstChild();
            do {
                if (!(node instanceof Element)) continue;
                attr = ((Element)node).getAttributeNode(e[15]);
                try {
                    if (attr == null) continue;
                    arrayList.add(attr);
                }
                catch (RuntimeException runtimeException) {
                    throw ServerRequestSwAAssertion.a(runtimeException);
                }
            } while ((node = node.getNextSibling()) != null);
        } else {
            arrayList.add(attr);
        }
        return arrayList;
    }

    private long[] a(PartInfo partInfo, Map<String, long[]> map) {
        ContentTypeHeader contentTypeHeader;
        String string;
        long[] lArray = null;
        ContentTypeHeader contentTypeHeader2 = partInfo.getContentType();
        String string2 = String.valueOf(map);
        String string3 = contentTypeHeader2.getSubtype();
        String string4 = contentTypeHeader2.getType();
        String[] stringArray = e;
        this.logger.info(stringArray[12] + string4 + "/" + string3 + " " + string2);
        for (Map.Entry<String, long[]> entry : map.entrySet()) {
            string = entry.getKey();
            try {
                contentTypeHeader = ContentTypeHeader.parseValue((String)string);
                if (!contentTypeHeader.matches(contentTypeHeader2)) continue;
                lArray = entry.getValue();
            }
            catch (IOException iOException) {
                stringArray = e;
                this.logger.warning(stringArray[13] + string + stringArray[31]);
            }
        }
        if (lArray == null) {
            for (Map.Entry<String, long[]> entry : map.entrySet()) {
                string = entry.getKey();
                try {
                    contentTypeHeader = ContentTypeHeader.parseValue((String)string);
                    if (!contentTypeHeader2.matches(contentTypeHeader)) continue;
                    lArray = entry.getValue();
                }
                catch (IOException iOException) {
                    stringArray = e;
                    this.logger.warning(stringArray[30] + string + stringArray[6]);
                }
            }
        }
        return lArray;
    }

    private boolean a(PartInfo partInfo, long[] lArray) throws NoSuchPartException, IOException {
        boolean bl2 = false;
        long l2 = lArray[1];
        lArray[0] = lArray[0] - partInfo.getActualContentLength();
        if (lArray[0] >= 0L) {
            bl2 = true;
        } else {
            this.logAndAudit((AuditDetailMessage)AssertionMessages.SWA_EXTRA_LENGTH_EXCEEDED, Long.toString(l2));
        }
        return bl2;
    }

    private static Exception a(Exception exception) {
        return exception;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[34];
                var3_1 = 0;
                var2_2 = "Q@5?\u0000N8uZ5~\rI!0R.+\rBuv[3~\u0013G'd\u0014\u0018D\\$~\u0011C$e]3;\u0007\u00064d@ =\u000bK0~@a&EZ$&\u0013C6dQ%~\u0011C&eX5~\u0005T:}\u0014..\u0006T4d].0C~\u0005q@)\f^[a\r,g\u00050V.:\u001a\u0016EZ$&\u0013C6dQ%~\u0002R!qW)3\u0006H!0\u000eBQ1;\u0002R0t\u00141?\u0011Ru\u00027\u001a&EZ$&\u0013C6dQ%~\u0011C&eX5~\u0005T:}\u0014\u0019.\u0002R=0R.,CV4b@a\u001bFU-7\u0007G!y[/~\u0005G<|Q%~\u0005I'0D ,\u0017\u0006,C]&0\u0002R bQa,\u0006W yF$:CD d\u0014/1\u0017\u0006%bQ2;\rRuv[3~\u0013G'd\u0014\u0019YZ7?\u000fO10Q9*\u0011Guq@5?\u0000N8uZ5~\u000fYZ7?\u000fO10F$/\u0016C&d(S\\$=\bO;w\u0014'1\u0011\u0006%uF,7\u0017R0t\u0014$&\u0017T4c\u001467\u0017NudM1;C8YS/1\u0011O;w\u0014(0\u0015G9yPa=\fH!uZ5~\u0017_%u\u0014);\u0002B0b\u0014i;\u001bR'q\u001dm~\u0015G9eQa7\u0010\u0006r\u0004s]%d\u0004xF$8\u001c^[a,\u0006@0bQ/=\u0006\u00063\u007fA/:C@:b\u00141?\u0011Ru-D\\$~\u0015G9eQ2~\f@ud\\$~\u000eG%0]2~\rI!0[39MQfs\u001a%1\u000e\b\u001b\u007fP$-D\\$~\u0015G9eQ2~\f@ud\\$~\u000eG%0]2~\rI!0[39MQfs\u001a%1\u000e\b\u001b\u007fP$\u0004xF$8\u001f\\Q/9\u0017Nu|],7\u0017\u00060hW$;\u0007C10R.,CV4b@a&EZ$&\u0013C6dQ%~\u0011C&eX5~\u0005T:}\u0014..\u0006T4d].0C~\u0005q@)\u0013_D$,\u0002R<\u007fZa0\fRuv[40\u0007/Q@5?\u0000N8uZ5~\u0013T:sQ2-\nH20@$,\u000eO;q@$:CB u\u001451C\u0001rk\u0004<yD\u000f@U3*CH:d\u0014'1\u0016H10\u0003s]%*UF31\u0011\u0006'u@37\u0006P<~Sa&\u000eJut[\"+\u000eC;d\u0014',\fKubQ0+\u0006U!\u0017YZ7?\u000fO10U5*\u0002E=}Q/*Cs\u0007\\\u0014\ryZa.\fU<d].0C\u0005\u001cgU2~\rI!0R.+\rBuyZa*\u000bCubQ0+\u0006U!8YS/1\u0011O;w\u0014(0\u0015G9yPa=\fH!uZ5~\u0017_%u\u0014);\u0002B0b\u0014i;\u001bR'q\u001dm~\u0015G9eQa7\u0010\u0006r\u00027\u001a";
                var4_3 = "Q@5?\u0000N8uZ5~\rI!0R.+\rBuv[3~\u0013G'd\u0014\u0018D\\$~\u0011C$e]3;\u0007\u00064d@ =\u000bK0~@a&EZ$&\u0013C6dQ%~\u0011C&eX5~\u0005T:}\u0014..\u0006T4d].0C~\u0005q@)\f^[a\r,g\u00050V.:\u001a\u0016EZ$&\u0013C6dQ%~\u0002R!qW)3\u0006H!0\u000eBQ1;\u0002R0t\u00141?\u0011Ru\u00027\u001a&EZ$&\u0013C6dQ%~\u0011C&eX5~\u0005T:}\u0014\u0019.\u0002R=0R.,CV4b@a\u001bFU-7\u0007G!y[/~\u0005G<|Q%~\u0005I'0D ,\u0017\u0006,C]&0\u0002R bQa,\u0006W yF$:CD d\u0014/1\u0017\u0006%bQ2;\rRuv[3~\u0013G'd\u0014\u0019YZ7?\u000fO10Q9*\u0011Guq@5?\u0000N8uZ5~\u000fYZ7?\u000fO10F$/\u0016C&d(S\\$=\bO;w\u0014'1\u0011\u0006%uF,7\u0017R0t\u0014$&\u0017T4c\u001467\u0017NudM1;C8YS/1\u0011O;w\u0014(0\u0015G9yPa=\fH!uZ5~\u0017_%u\u0014);\u0002B0b\u0014i;\u001bR'q\u001dm~\u0015G9eQa7\u0010\u0006r\u0004s]%d\u0004xF$8\u001c^[a,\u0006@0bQ/=\u0006\u00063\u007fA/:C@:b\u00141?\u0011Ru-D\\$~\u0015G9eQ2~\f@ud\\$~\u000eG%0]2~\rI!0[39MQfs\u001a%1\u000e\b\u001b\u007fP$-D\\$~\u0015G9eQ2~\f@ud\\$~\u000eG%0]2~\rI!0[39MQfs\u001a%1\u000e\b\u001b\u007fP$\u0004xF$8\u001f\\Q/9\u0017Nu|],7\u0017\u00060hW$;\u0007C10R.,CV4b@a&EZ$&\u0013C6dQ%~\u0011C&eX5~\u0005T:}\u0014..\u0006T4d].0C~\u0005q@)\u0013_D$,\u0002R<\u007fZa0\fRuv[40\u0007/Q@5?\u0000N8uZ5~\u0013T:sQ2-\nH20@$,\u000eO;q@$:CB u\u001451C\u0001rk\u0004<yD\u000f@U3*CH:d\u0014'1\u0016H10\u0003s]%*UF31\u0011\u0006'u@37\u0006P<~Sa&\u000eJut[\"+\u000eC;d\u0014',\fKubQ0+\u0006U!\u0017YZ7?\u000fO10U5*\u0002E=}Q/*Cs\u0007\\\u0014\ryZa.\fU<d].0C\u0005\u001cgU2~\rI!0R.+\rBuyZa*\u000bCubQ0+\u0006U!8YS/1\u0011O;w\u0014(0\u0015G9yPa=\fH!uZ5~\u0017_%u\u0014);\u0002B0b\u0014i;\u001bR'q\u001dm~\u0015G9eQa7\u0010\u0006r\u00027\u001a".length();
                var1_4 = 30;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = ServerRequestSwAAssertion.b(v0, ServerRequestSwAAssertion.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u000f\faiY\u0019gf\u0003c|T\u0013k+\u0007y|\u0015%Q\nB*\u0003\u0010egGPq#\u0016eaP\u0006j(\u00057pX\u001c#\"\rt}X\u0015m2BqzZ\u001d#4\u0007f}P\u0003w";
                    var4_3 = "\u000f\faiY\u0019gf\u0003c|T\u0013k+\u0007y|\u0015%Q\nB*\u0003\u0010egGPq#\u0016eaP\u0006j(\u00057pX\u001c#\"\rt}X\u0015m2BqzZ\u001d#4\u0007f}P\u0003w".length();
                    var1_4 = 23;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 46;
                        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++] = ServerRequestSwAAssertion.b(v0, ServerRequestSwAAssertion.b(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;
            }
        }
        ServerRequestSwAAssertion.e = var5;
    }

    private static char[] b(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x2D);
        }
        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 -> 104;
                    case 1 -> 76;
                    case 2 -> 57;
                    case 3 -> 38;
                    case 4 -> 27;
                    case 5 -> 94;
                    default -> 45;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }

    private static final class AttachmentProcessingException
    extends Exception {
        private AssertionStatus assertionStatus;
        static final long serialVersionUID = -8661700323887625662L;

        public AttachmentProcessingException(String string, AssertionStatus assertionStatus) {
            super(string);
            this.assertionStatus = assertionStatus;
        }

        public AssertionStatus getAssertionStatus() {
            return this.assertionStatus;
        }
    }
}

