/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.http.CertificateCheck2Info
 *  com.l7tech.common.http.HttpHeader
 *  com.l7tech.common.http.Pre60CertificateCheckInfo
 *  com.l7tech.common.io.CertUtils
 *  com.l7tech.common.io.XmlUtil
 *  com.l7tech.common.mime.ByteArrayStashManager
 *  com.l7tech.common.mime.ContentTypeHeader
 *  com.l7tech.common.mime.StashManager
 *  com.l7tech.common.protocol.SecureSpanConstants
 *  com.l7tech.common.protocol.SecureSpanConstants$HttpHeaders
 *  com.l7tech.gateway.common.Component
 *  com.l7tech.gateway.common.audit.AuditRecord
 *  com.l7tech.gateway.common.audit.SystemAuditRecord
 *  com.l7tech.gateway.common.custom.CustomAssertionsRegistrar
 *  com.l7tech.gateway.common.service.PublishedService
 *  com.l7tech.gateway.common.transport.SsgConnector$Endpoint
 *  com.l7tech.identity.IdentityProvider
 *  com.l7tech.identity.User
 *  com.l7tech.identity.UserBean
 *  com.l7tech.identity.internal.InternalUser
 *  com.l7tech.message.HttpRequestKnob
 *  com.l7tech.message.HttpResponseKnob
 *  com.l7tech.message.HttpServletRequestKnob
 *  com.l7tech.message.HttpServletResponseKnob
 *  com.l7tech.message.Message
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.policy.PolicyPathBuilder
 *  com.l7tech.policy.PolicyPathBuilderFactory
 *  com.l7tech.util.Charsets
 *  com.l7tech.util.ConfigFactory
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.HexUtils
 *  com.l7tech.util.InetAddressUtil
 *  com.l7tech.util.ResourceUtils
 *  com.l7tech.xml.SoapFaultLevel
 *  jakarta.servlet.ServletConfig
 *  jakarta.servlet.ServletException
 *  jakarta.servlet.ServletOutputStream
 *  jakarta.servlet.http.HttpServletRequest
 *  jakarta.servlet.http.HttpServletResponse
 *  org.springframework.beans.BeansException
 *  org.springframework.context.ApplicationContext
 */
package com.l7tech.server.policy;

import com.l7tech.common.http.CertificateCheck2Info;
import com.l7tech.common.http.HttpHeader;
import com.l7tech.common.http.Pre60CertificateCheckInfo;
import com.l7tech.common.io.CertUtils;
import com.l7tech.common.io.XmlUtil;
import com.l7tech.common.mime.ByteArrayStashManager;
import com.l7tech.common.mime.ContentTypeHeader;
import com.l7tech.common.mime.StashManager;
import com.l7tech.common.protocol.SecureSpanConstants;
import com.l7tech.gateway.common.Component;
import com.l7tech.gateway.common.audit.AuditRecord;
import com.l7tech.gateway.common.audit.SystemAuditRecord;
import com.l7tech.gateway.common.custom.CustomAssertionsRegistrar;
import com.l7tech.gateway.common.service.PublishedService;
import com.l7tech.gateway.common.transport.SsgConnector;
import com.l7tech.identity.IdentityProvider;
import com.l7tech.identity.User;
import com.l7tech.identity.UserBean;
import com.l7tech.identity.internal.InternalUser;
import com.l7tech.message.HttpRequestKnob;
import com.l7tech.message.HttpResponseKnob;
import com.l7tech.message.HttpServletRequestKnob;
import com.l7tech.message.HttpServletResponseKnob;
import com.l7tech.message.Message;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.policy.PolicyPathBuilder;
import com.l7tech.policy.PolicyPathBuilderFactory;
import com.l7tech.server.AuthenticatableHttpServlet;
import com.l7tech.server.DefaultKey;
import com.l7tech.server.audit.AuditContextFactory;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.message.PolicyEnforcementContextFactory;
import com.l7tech.server.policy.PolicyCache;
import com.l7tech.server.policy.PolicyService;
import com.l7tech.server.policy.ab;
import com.l7tech.server.policy.ac;
import com.l7tech.server.util.SoapFaultManager;
import com.l7tech.util.Charsets;
import com.l7tech.util.ConfigFactory;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.HexUtils;
import com.l7tech.util.InetAddressUtil;
import com.l7tech.util.ResourceUtils;
import com.l7tech.xml.SoapFaultLevel;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

public class PolicyServlet
extends AuthenticatableHttpServlet {
    private static final String DUMMY_ID_PROVIDER_OID;
    private AuditContextFactory auditContextFactory;
    private SoapFaultManager soapFaultManager;
    private byte[] serverCertificate;
    private PolicyPathBuilder policyPathBuilder;
    private PolicyCache policyCache;
    private SecureRandom secureRandom;
    private String nodeId;
    static final long serialVersionUID = 8804225192424689127L;
    private static final String[] b;

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        super.init(servletConfig);
        try {
            ApplicationContext applicationContext = this.getApplicationContext();
            String[] stringArray = b;
            this.auditContextFactory = (AuditContextFactory)applicationContext.getBean(stringArray[31], AuditContextFactory.class);
            this.soapFaultManager = (SoapFaultManager)applicationContext.getBean(stringArray[15], SoapFaultManager.class);
            DefaultKey defaultKey = (DefaultKey)applicationContext.getBean(stringArray[44], DefaultKey.class);
            this.nodeId = (String)applicationContext.getBean(stringArray[48], String.class);
            this.serverCertificate = defaultKey.getServerSslInfo().getCertificate().getEncoded();
            PolicyPathBuilderFactory policyPathBuilderFactory = (PolicyPathBuilderFactory)applicationContext.getBean(stringArray[17], PolicyPathBuilderFactory.class);
            this.policyPathBuilder = policyPathBuilderFactory.makePathBuilder();
            this.policyCache = (PolicyCache)applicationContext.getBean(stringArray[50], PolicyCache.class);
            this.secureRandom = this.getBean(stringArray[14], SecureRandom.class);
        }
        catch (BeansException beansException) {
            throw new ServletException((Throwable)beansException);
        }
        catch (IOException iOException) {
            throw new ServletException((Throwable)iOException);
        }
        catch (CertificateException certificateException) {
            throw new ServletException((Throwable)certificateException);
        }
    }

    @Override
    protected String getFeature() {
        return b[0];
    }

    @Override
    protected SsgConnector.Endpoint getRequiredEndpoint() {
        return SsgConnector.Endpoint.POLICYDISCO;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
        PolicyEnforcementContext policyEnforcementContext = null;
        try {
            String[] stringArray = b;
            if (!httpServletRequest.getContentType().startsWith(stringArray[39])) {
                this.logger.warning(stringArray[9] + httpServletRequest.getContentType());
                return;
            }
            Message message = new Message();
            message.initialize((StashManager)new ByteArrayStashManager(), ContentTypeHeader.parseValue((String)httpServletRequest.getContentType()), (InputStream)httpServletRequest.getInputStream(), Message.getMaxBytes());
            message.attachHttpRequestKnob((HttpRequestKnob)new HttpServletRequestKnob(httpServletRequest));
            Message message2 = new Message();
            message2.attachHttpResponseKnob((HttpResponseKnob)new HttpServletResponseKnob(httpServletResponse));
            policyEnforcementContext = PolicyEnforcementContextFactory.createPolicyEnforcementContext(message, message2, true);
            boolean[] blArray = new boolean[]{false};
            PolicyEnforcementContext policyEnforcementContext2 = policyEnforcementContext;
            stringArray = b;
            SystemAuditRecord systemAuditRecord = new SystemAuditRecord(Level.INFO, this.nodeId, Component.GW_POLICY_SERVICE, stringArray[23], false, null, null, null, stringArray[5], httpServletRequest.getRemoteAddr());
            this.auditContextFactory.doWithNewAuditContext((AuditRecord)systemAuditRecord, new ab(this, httpServletRequest, policyEnforcementContext2, httpServletResponse, message2, blArray));
            ResourceUtils.closeQuietly((Closeable)policyEnforcementContext);
        }
        catch (Exception exception) {
            this.logger.log(Level.SEVERE, b[11], exception);
            this.sendExceptionFault(policyEnforcementContext, exception, httpServletResponse);
        }
        finally {
            ResourceUtils.closeQuietly(policyEnforcementContext);
        }
    }

    protected PolicyService getPolicyService() {
        return (PolicyService)((Object)this.getApplicationContext().getBean(b[35]));
    }

    protected PolicyService.PolicyGetter normalPolicyGetter(boolean bl2, boolean bl3, boolean bl4) {
        return new ac(this, bl3, bl2, bl4);
    }

    /*
     * Exception decompiling
     */
    protected void doGet(HttpServletRequest var1_1, HttpServletResponse var2_2) throws ServletException, IOException {
        /*
         * This method has failed to decompile.  When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
         * 
         * org.benf.cfr.reader.util.ConfusedCFRException: Tried to end blocks [28[CASE]], but top level block is 19[TRYBLOCK]
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.processEndingBlocks(Op04StructuredStatement.java:435)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.buildNestedBlocks(Op04StructuredStatement.java:484)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op03SimpleStatement.createInitialStructuredBlock(Op03SimpleStatement.java:736)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:850)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
         *     at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
         *     at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1055)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
         *     at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
         *     at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
         *     at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
         *     at org.benf.cfr.reader.Main.main(Main.java:54)
         */
        throw new IllegalStateException("Decompilation failed");
    }

    private boolean systemAllowsAnonymousDownloads(HttpServletRequest httpServletRequest) {
        String[] stringArray = b;
        String string = this.config.getProperty(stringArray[32]);
        StringTokenizer stringTokenizer = new StringTokenizer(string);
        String string2 = httpServletRequest.getRemoteAddr();
        while (stringTokenizer.hasMoreTokens()) {
            String string3 = stringTokenizer.nextToken();
            try {
                if (!InetAddressUtil.patternMatchesAddress((String)string3, (InetAddress)InetAddressUtil.getAddress((String)string2))) continue;
                this.logger.fine(b[21] + string2 + b[61] + string3);
                return true;
            }
            catch (BeansException beansException) {
                throw PolicyServlet.a((Exception)((Object)beansException));
            }
        }
        stringArray = b;
        this.logger.finest(stringArray[13] + string2 + stringArray[33] + string);
        return false;
    }

    private boolean systemAllowsDisabledServiceDownloads(HttpServletRequest httpServletRequest) {
        boolean bl2 = false;
        String[] stringArray = b;
        String string = this.config.getProperty(stringArray[3]);
        if (stringArray[60].equalsIgnoreCase(string)) {
            bl2 = true;
        } else if (b[7].equalsIgnoreCase(string)) {
            bl2 = this.systemAllowsAnonymousDownloads(httpServletRequest);
        }
        return bl2;
    }

    private void doCertDownload(HttpServletResponse httpServletResponse, String string, String string2) throws FindException, IOException {
        byte[] byArray;
        block5: {
            String[] stringArray = b;
            this.logger.finest(stringArray[46]);
            String string3 = CertUtils.encodeAsPEM((byte[])this.serverCertificate);
            byArray = string3.getBytes(Charsets.UTF8);
            boolean bl2 = ConfigFactory.getBooleanProperty((String)stringArray[41], (boolean)false);
            try {
                try {
                    if (!bl2 || string == null) break block5;
                }
                catch (FindException findException) {
                    throw PolicyServlet.a((Exception)((Object)findException));
                }
                if (string2 == null) break block5;
            }
            catch (FindException findException) {
                throw PolicyServlet.a((Exception)((Object)findException));
            }
            Collection<HttpHeader> collection = this.findCheckInfoHeaders(string, byArray, string2);
            for (HttpHeader httpHeader : collection) {
                httpServletResponse.addHeader(httpHeader.getName(), httpHeader.getFullValue());
            }
        }
        httpServletResponse.setStatus(200);
        httpServletResponse.setContentType(b[26]);
        httpServletResponse.setContentLength(byArray.length);
        httpServletResponse.getOutputStream().write(byArray);
        httpServletResponse.flushBuffer();
    }

    private void outputPolicyDoc(HttpServletResponse httpServletResponse, Document document) throws IOException {
        httpServletResponse.setContentType(XmlUtil.TEXT_XML);
        httpServletResponse.setStatus(200);
        ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();
        XmlUtil.nodeToOutputStream((Node)document, (OutputStream)servletOutputStream);
        servletOutputStream.close();
    }

    private Collection<HttpHeader> findCheckInfoHeaders(String string, byte[] byArray, String string2) throws FindException {
        ArrayList<HttpHeader> arrayList;
        block20: {
            String[] stringArray;
            arrayList = new ArrayList<HttpHeader>();
            String string3 = string.trim();
            byte[] byArray2 = string2.getBytes(Charsets.UTF8);
            boolean bl2 = false;
            Collection<IdentityProvider> collection = this.identityProviderFactory.findAllIdentityProviders();
            for (IdentityProvider identityProvider : collection) {
                try {
                    boolean bl3;
                    block18: {
                        String string4;
                        User user = identityProvider.getUserManager().findByLogin(string3);
                        if (user == null) continue;
                        bl3 = false;
                        try {
                            string4 = user instanceof InternalUser ? ((InternalUser)user).getHashedPassword() : null;
                        }
                        catch (FindException findException) {
                            throw PolicyServlet.a((Exception)((Object)findException));
                        }
                        String string5 = string4;
                        try {
                            if (string5 == null || !this.passwordHasher.isVerifierRecognized(string5)) break block18;
                        }
                        catch (FindException findException) {
                            throw PolicyServlet.a((Exception)((Object)findException));
                        }
                        byte[] byArray3 = this.passwordHasher.extractSaltFromVerifier(string5);
                        if (byArray3 != null) {
                            String string6 = HexUtils.hexDump((byte[])byArray3);
                            String string7 = Goid.toString((Goid)identityProvider.getConfig().getGoid());
                            byte[] byArray4 = new byte[16];
                            this.secureRandom.nextBytes(byArray4);
                            String string8 = HexUtils.hexDump((byte[])byArray4);
                            byte[] byArray5 = CertUtils.getVerifierBytes((byte[])string5.getBytes(Charsets.UTF8), (byte[])byArray2, (byte[])byArray4, (byte[])byArray);
                            String string9 = HexUtils.hexDump((byte[])byArray5);
                            arrayList.add(new CertificateCheck2Info(string7, string8, string9, string6).asHttpHeader());
                            bl3 = true;
                        }
                    }
                    if (bl3) continue;
                    bl2 = true;
                }
                catch (FindException findException) {
                    stringArray = b;
                    this.logger.log(Level.WARNING, stringArray[40] + ExceptionUtils.getMessage((Throwable)findException), ExceptionUtils.getDebugException((Throwable)findException));
                }
                catch (NoSuchAlgorithmException noSuchAlgorithmException) {
                    stringArray = b;
                    this.logger.log(Level.WARNING, stringArray[19] + ExceptionUtils.getMessage((Throwable)noSuchAlgorithmException), ExceptionUtils.getDebugException((Throwable)noSuchAlgorithmException));
                }
            }
            stringArray = b;
            CustomAssertionsRegistrar customAssertionsRegistrar = (CustomAssertionsRegistrar)this.getApplicationContext().getBean(stringArray[45]);
            try {
                block19: {
                    try {
                        try {
                            if (bl2) break block19;
                            if (customAssertionsRegistrar == null) break block20;
                        }
                        catch (FindException findException) {
                            throw PolicyServlet.a((Exception)((Object)findException));
                        }
                        if (!customAssertionsRegistrar.hasCustomCredentialSource()) break block20;
                    }
                    catch (FindException findException) {
                        throw PolicyServlet.a((Exception)((Object)findException));
                    }
                }
                arrayList.add(new CertificateCheck2Info(DUMMY_ID_PROVIDER_OID, "", SecureSpanConstants.NOPASS, "").asHttpHeader());
            }
            catch (FindException findException) {
                throw PolicyServlet.a((Exception)((Object)findException));
            }
        }
        try {
            if (!arrayList.isEmpty()) {
                arrayList.add(new Pre60CertificateCheckInfo(DUMMY_ID_PROVIDER_OID, SecureSpanConstants.NOPASS, b[38]).asHttpHeader());
            }
        }
        catch (FindException findException) {
            throw PolicyServlet.a((Exception)((Object)findException));
        }
        return arrayList;
    }

    private void sendAuthChallenge(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
        String string;
        String[] stringArray;
        block2: {
            stringArray = b;
            string = stringArray[12] + InetAddressUtil.getHostForUrl((String)httpServletRequest.getServerName());
            int n2 = this.config.getIntProperty(stringArray[4], 8080);
            int n3 = this.config.getIntProperty(stringArray[43], 8443);
            try {
                if (httpServletRequest.getServerPort() != n2 && httpServletRequest.getServerPort() != n3) break block2;
            }
            catch (IOException iOException) {
                throw PolicyServlet.a(iOException);
            }
            string = string + ":" + n3;
        }
        string = string + httpServletRequest.getRequestURI() + "?" + httpServletRequest.getQueryString();
        httpServletResponse.setHeader(SecureSpanConstants.HttpHeaders.POLICYURL_HEADER, string);
        httpServletResponse.setStatus(401);
        stringArray = b;
        this.logger.fine(stringArray[27]);
        httpServletResponse.setHeader(stringArray[18], stringArray[42]);
        httpServletResponse.getOutputStream().close();
    }

    private User getUser(PolicyEnforcementContext policyEnforcementContext) {
        User user = null;
        if (policyEnforcementContext.getDefaultAuthenticationContext().isAuthenticated()) {
            user = policyEnforcementContext.getDefaultAuthenticationContext().getLastAuthenticatedUser();
        }
        if (user == null) {
            user = new UserBean();
        }
        return user;
    }

    private String getName(User user) {
        String string;
        try {
            string = user.getName() != null ? user.getName() : user.getLogin();
        }
        catch (BeansException beansException) {
            throw PolicyServlet.a((Exception)((Object)beansException));
        }
        return string;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private void returnFault(PolicyEnforcementContext policyEnforcementContext, HttpServletResponse httpServletResponse) throws IOException {
        ServletOutputStream servletOutputStream = null;
        try {
            servletOutputStream = httpServletResponse.getOutputStream();
            httpServletResponse.setStatus(500);
            SoapFaultLevel soapFaultLevel = policyEnforcementContext.getFaultlevel();
            SoapFaultManager.FaultResponse faultResponse = this.soapFaultManager.constructReturningFault(soapFaultLevel, policyEnforcementContext);
            this.soapFaultManager.sendExtraHeaders(faultResponse, httpServletResponse);
            httpServletResponse.setContentType(faultResponse.getContentType().getFullValue());
            servletOutputStream.write(faultResponse.getContentBytes());
            if (servletOutputStream == null) return;
        }
        catch (Throwable throwable) {
            try {
                if (servletOutputStream == null) throw throwable;
                servletOutputStream.close();
                throw throwable;
            }
            catch (IOException iOException) {
                throw PolicyServlet.a(iOException);
            }
        }
        servletOutputStream.close();
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private void returnError(HttpServletResponse httpServletResponse, String string) throws IOException {
        ServletOutputStream servletOutputStream = null;
        try {
            servletOutputStream = httpServletResponse.getOutputStream();
            httpServletResponse.setContentType(b[34]);
            httpServletResponse.setStatus(500);
            servletOutputStream.write(string.getBytes());
            if (servletOutputStream == null) return;
        }
        catch (Throwable throwable) {
            try {
                if (servletOutputStream == null) throw throwable;
                servletOutputStream.close();
                throw throwable;
            }
            catch (IOException iOException) {
                throw PolicyServlet.a(iOException);
            }
        }
        servletOutputStream.close();
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private void sendExceptionFault(PolicyEnforcementContext policyEnforcementContext, Throwable throwable, HttpServletResponse httpServletResponse) throws IOException {
        OutputStream outputStream = null;
        try {
            SoapFaultManager.FaultResponse faultResponse = this.soapFaultManager.constructExceptionFault(throwable, null, policyEnforcementContext);
            this.soapFaultManager.sendExtraHeaders(faultResponse, httpServletResponse);
            outputStream = httpServletResponse.getOutputStream();
            httpServletResponse.setContentType(faultResponse.getContentType().getFullValue());
            httpServletResponse.setStatus(500);
            outputStream.write(faultResponse.getContentBytes());
            if (outputStream == null) return;
        }
        catch (Throwable throwable2) {
            try {
                if (outputStream == null) throw throwable2;
                outputStream.close();
                throw throwable2;
            }
            catch (IOException iOException) {
                throw PolicyServlet.a(iOException);
            }
        }
        outputStream.close();
    }

    static /* synthetic */ ApplicationContext access$000(PolicyServlet policyServlet) {
        return policyServlet.getApplicationContext();
    }

    static /* synthetic */ Logger access$100(PolicyServlet policyServlet) {
        return policyServlet.logger;
    }

    static /* synthetic */ Logger access$200(PolicyServlet policyServlet) {
        return policyServlet.logger;
    }

    static /* synthetic */ PublishedService access$300(PolicyServlet policyServlet, Goid goid) {
        return policyServlet.resolveService(goid);
    }

    static /* synthetic */ PublishedService access$400(PolicyServlet policyServlet, Long l2) {
        return policyServlet.resolveService(l2);
    }

    static /* synthetic */ Logger access$500(PolicyServlet policyServlet) {
        return policyServlet.logger;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[62];
                var3_1 = 0;
                var2_2 = "|^G!\u0007Ov5kZ;\u0007Oj\u0003v^F\u0016JIG8\u001c\fza\u001be8\u0002EpvhP%\u0018Epj |^G!\u0007Ov!_\\$\u000fN\u007fj_f2\u001cZzl^q8\u0019B\u007f`ZQ$\bgOA'>Ca{\u0003H~a0XRY;N\\r|HA?\u001cCfhS\u00156\u0000H3}^A\"\u001cB3iNY;N\\|cRV.NH|lNX2\u0000X\u000b\u007fZF$\u001aDa`NR?\u0016JIG8\u001c\fza\u001be8\u0002EpvhP%\u0018Epj\u0011MZQw\rC}{^[#NXj\u007f^\u00159HZA2\u0019Mj/KZ;\u0007Oj/_\\$\rCejILw\u001dIayRV2NB|{\u001bP9\u000fN\u007fj_\u00158\u0000\fggRFw\u001eCa{\u0015ZUP/\u001eIp{^Qw\u000bTpjKA>\u0001B)\bgOA'\u001d\u0016< \n}^X8\u001aI3fK\u0015\f|^V\"\u001cIAnUQ8\u0003\u0010|TT'(MfcOx6\u0000MtjI\u001aNNA?\u000bBgfXT#\u0007C}/^M4\u000b\\gfT[mN\u0018\u007fTY>\rUCnO]\u0015\u001bE\u007fk^G\u0011\u000fOg`IL\u0010Xlbz/Ygg^[#\u0007Or{^$ZUT5\u0002I3{T\u0015#\u0001\fp`VE\"\u001aI3l^G#NZv}RS>\u000b^)/3XRY;N\\r|HA?\u001cCfhS\u00156\u0000H3}^A\"\u001cB3fUY>\u0000Iw/KZ;\u0007Oj/_Z4\u001bAvaO\n}^X8\u001aI3fK\u0015\u001dZUT5\u0002I3{T\u00151\u001b@ufW\u00154\u000b^g/IP&\u001bI`{\u000e_TY>\rU3}^D\"\u000b_g\u0011_ZF$\u000bH3yZY\"\u000b\fu`I\u0015\u0005/LT$N\u001enKE;\u0007Or{RZ9AT>w\u000e\u0005nC_v}MP%COv}O%|^[3\u0007Bt/YT4\u0005\frzO]2\u0000XzlZA>\u0001B3lST;\u0002I}h^\u000efUA2\u001cBrc\u001bP%\u001cCa\u0007JIG8\u001c\u00163/XRY;NE}lW@3\u000b\fp`VX2\u0000X`/L\\#\u0006\fuzWYw\u001eC\u007ffXLw\nCpzVP9\u001a\u0013nNQ>\u001ao|aOP/\u001ajrlOZ%\u0017\u0014\u007fZF$\u001aDa`NR?*CdaWZ6\n_*/LT$NB|{\u001bT\"\u001aD|}RO2\n\fqv\u001bT9\u0017\fcnHF#\u0006^|z\\]w\u0007B3\n{^M#A\\\u007fnR[\r\u007fTY>\rU@jIC>\rI\u000efUA2\u001cBrc\u001bP%\u001cCa\u0010}^A\"\u001cBza\\\u0015'\u0001@zlB\u0005kNX:\u0017\b{^M#AT~c(ZUT5\u0002I3{T\u0015#\u0001\fajOG>\u000bZv/NF2\u001c\fza]Z%\u0003MgfT[mN$|^G!\u0007Ov|\u0015V2\u001cXziRV6\u001aIWfHV8\u0018Iav~[6\f@vk\u001dMZF>\r\fajZY:S\u000e_8hf\u0010,M`fXg2\u000f@~-\tgOA'\u001d||}O\nk^S6\u001b@gD^L\u0018lNF#\u0001AR|HP%\u001aE|aiP0\u0007_g}ZG\u0015]^D\"\u000b_g/]Z%N^|`O\u00154\u000b^g {S\\$N\\|cRV.NH|xUY8\u000fH3fH\u0015%\u000bJf|^Qy\rlW@$\u001aIaATQ2'H$\\^G!\u0007Ov/RFw\u001bB\u007ffXP9\u001dIw#\u001bG2\u001aYaaR[0N\u0019#?\u000b\u007fTY>\rUPnX]2\u0005/LT$N\u0011|^[3\u0007Bt/X]6\u0002@va\\P)_TY>\rU3aTAw\bCfa_\u00158\u001c\fw`L[;\u0001Mw/N[6\u001bX{`I\\-\u000bH7HZA2\u0019Mj/KZ;\u0007Oj/_\\$\rCejILw\u001dIayRV2NB|{\u001bP9\u000fN\u007fj_\u00155\u0017\f\u007ffXP9\u001dI4\\^G!\u0007Ov/RFw\u0000Cg/KP%\u0003Eg{^Qw\u0001B3{S\\$N\\|}O\u0019w\u001cIgzI[>\u0000K3:\u000b\u0005\u0011_ZF$\u000bH3yZY\"\u000b\fu`I\u0015.ZUT5\u0002I3{T\u00151\u001b@ufW\u00154\u000b^gf]\\4\u000fXv/_\\$\rCejILw\u001cIbz^F#\u0003v^F\u000faTAw\u0007Acc^X2\u0000Xvk";
                var4_3 = "|^G!\u0007Ov5kZ;\u0007Oj\u0003v^F\u0016JIG8\u001c\fza\u001be8\u0002EpvhP%\u0018Epj |^G!\u0007Ov!_\\$\u000fN\u007fj_f2\u001cZzl^q8\u0019B\u007f`ZQ$\bgOA'>Ca{\u0003H~a0XRY;N\\r|HA?\u001cCfhS\u00156\u0000H3}^A\"\u001cB3iNY;N\\|cRV.NH|lNX2\u0000X\u000b\u007fZF$\u001aDa`NR?\u0016JIG8\u001c\fza\u001be8\u0002EpvhP%\u0018Epj\u0011MZQw\rC}{^[#NXj\u007f^\u00159HZA2\u0019Mj/KZ;\u0007Oj/_\\$\rCejILw\u001dIayRV2NB|{\u001bP9\u000fN\u007fj_\u00158\u0000\fggRFw\u001eCa{\u0015ZUP/\u001eIp{^Qw\u000bTpjKA>\u0001B)\bgOA'\u001d\u0016< \n}^X8\u001aI3fK\u0015\f|^V\"\u001cIAnUQ8\u0003\u0010|TT'(MfcOx6\u0000MtjI\u001aNNA?\u000bBgfXT#\u0007C}/^M4\u000b\\gfT[mN\u0018\u007fTY>\rUCnO]\u0015\u001bE\u007fk^G\u0011\u000fOg`IL\u0010Xlbz/Ygg^[#\u0007Or{^$ZUT5\u0002I3{T\u0015#\u0001\fp`VE\"\u001aI3l^G#NZv}RS>\u000b^)/3XRY;N\\r|HA?\u001cCfhS\u00156\u0000H3}^A\"\u001cB3fUY>\u0000Iw/KZ;\u0007Oj/_Z4\u001bAvaO\n}^X8\u001aI3fK\u0015\u001dZUT5\u0002I3{T\u00151\u001b@ufW\u00154\u000b^g/IP&\u001bI`{\u000e_TY>\rU3}^D\"\u000b_g\u0011_ZF$\u000bH3yZY\"\u000b\fu`I\u0015\u0005/LT$N\u001enKE;\u0007Or{RZ9AT>w\u000e\u0005nC_v}MP%COv}O%|^[3\u0007Bt/YT4\u0005\frzO]2\u0000XzlZA>\u0001B3lST;\u0002I}h^\u000efUA2\u001cBrc\u001bP%\u001cCa\u0007JIG8\u001c\u00163/XRY;NE}lW@3\u000b\fp`VX2\u0000X`/L\\#\u0006\fuzWYw\u001eC\u007ffXLw\nCpzVP9\u001a\u0013nNQ>\u001ao|aOP/\u001ajrlOZ%\u0017\u0014\u007fZF$\u001aDa`NR?*CdaWZ6\n_*/LT$NB|{\u001bT\"\u001aD|}RO2\n\fqv\u001bT9\u0017\fcnHF#\u0006^|z\\]w\u0007B3\n{^M#A\\\u007fnR[\r\u007fTY>\rU@jIC>\rI\u000efUA2\u001cBrc\u001bP%\u001cCa\u0010}^A\"\u001cBza\\\u0015'\u0001@zlB\u0005kNX:\u0017\b{^M#AT~c(ZUT5\u0002I3{T\u0015#\u0001\fajOG>\u000bZv/NF2\u001c\fza]Z%\u0003MgfT[mN$|^G!\u0007Ov|\u0015V2\u001cXziRV6\u001aIWfHV8\u0018Iav~[6\f@vk\u001dMZF>\r\fajZY:S\u000e_8hf\u0010,M`fXg2\u000f@~-\tgOA'\u001d||}O\nk^S6\u001b@gD^L\u0018lNF#\u0001AR|HP%\u001aE|aiP0\u0007_g}ZG\u0015]^D\"\u000b_g/]Z%N^|`O\u00154\u000b^g {S\\$N\\|cRV.NH|xUY8\u000fH3fH\u0015%\u000bJf|^Qy\rlW@$\u001aIaATQ2'H$\\^G!\u0007Ov/RFw\u001bB\u007ffXP9\u001dIw#\u001bG2\u001aYaaR[0N\u0019#?\u000b\u007fTY>\rUPnX]2\u0005/LT$N\u0011|^[3\u0007Bt/X]6\u0002@va\\P)_TY>\rU3aTAw\bCfa_\u00158\u001c\fw`L[;\u0001Mw/N[6\u001bX{`I\\-\u000bH7HZA2\u0019Mj/KZ;\u0007Oj/_\\$\rCejILw\u001dIayRV2NB|{\u001bP9\u000fN\u007fj_\u00155\u0017\f\u007ffXP9\u001dI4\\^G!\u0007Ov/RFw\u0000Cg/KP%\u0003Eg{^Qw\u0001B3{S\\$N\\|}O\u0019w\u001cIgzI[>\u0000K3:\u000b\u0005\u0011_ZF$\u000bH3yZY\"\u000b\fu`I\u0015.ZUT5\u0002I3{T\u00151\u001b@ufW\u00154\u000b^gf]\\4\u000fXv/_\\$\rCejILw\u001cIbz^F#\u0003v^F\u000faTAw\u0007Acc^X2\u0000Xvk".length();
                var1_4 = 14;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = PolicyServlet.b(v0, PolicyServlet.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = ")\u0010\u001e%h\u000b\u0013c\t\n!<\u0014\u001db@\u00111,\\\u0010i\t\u001b5;\u000f\u0006x[\u0004!/\u0014RfH\u0007!-\\";
                    var4_3 = ")\u0010\u001e%h\u000b\u0013c\t\n!<\u0014\u001db@\u00111,\\\u0010i\t\u001b5;\u000f\u0006x[\u0004!/\u0014RfH\u0007!-\\".length();
                    var1_4 = 3;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 117;
                        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++] = PolicyServlet.b(v0, PolicyServlet.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;
            }
        }
        PolicyServlet.b = var5;
        PolicyServlet.DUMMY_ID_PROVIDER_OID = Goid.toString((Goid)new Goid(0L, 0x7FFFFFFFFFFFFFFFL));
    }

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

    private static char[] b(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x21);
        }
        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 -> 61;
                    case 1 -> 9;
                    case 2 -> 7;
                    case 3 -> 101;
                    case 4 -> 92;
                    case 5 -> 30;
                    default -> 33;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

