/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.identity.ldap.GroupMappingConfig
 *  com.l7tech.identity.ldap.LdapGroup
 *  com.l7tech.identity.ldap.LdapUser
 *  com.l7tech.identity.ldap.MemberStrategy
 *  com.l7tech.objectmodel.EntityHeader
 *  com.l7tech.objectmodel.EntityHeaderSet
 *  com.l7tech.objectmodel.EntityType
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.IdentityHeader
 */
package com.l7tech.server.identity.ldap;

import com.l7tech.identity.ldap.GroupMappingConfig;
import com.l7tech.identity.ldap.LdapGroup;
import com.l7tech.identity.ldap.LdapUser;
import com.l7tech.identity.ldap.MemberStrategy;
import com.l7tech.objectmodel.EntityHeader;
import com.l7tech.objectmodel.EntityHeaderSet;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.IdentityHeader;
import com.l7tech.server.identity.ldap.LdapGroupManagerImpl;
import com.l7tech.server.identity.ldap.LdapUtils;
import com.l7tech.server.identity.ldap.k;
import java.util.Collection;
import java.util.Set;
import java.util.logging.Level;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;

class t
extends k {
    final GroupMappingConfig[] val$groupTypes;
    final DirContext val$searchContext;
    final EntityHeaderSet val$headers;
    final int val$depth;
    final Set val$processedGroupNames;
    final Set val$processedGroupIds;
    final LdapGroupManagerImpl this$0;
    private static final String[] a;

    t(LdapGroupManagerImpl ldapGroupManagerImpl, GroupMappingConfig[] groupMappingConfigArray, DirContext dirContext, EntityHeaderSet entityHeaderSet, int n2, Set set, Set set2) {
        this.this$0 = ldapGroupManagerImpl;
        this.val$groupTypes = groupMappingConfigArray;
        this.val$searchContext = dirContext;
        this.val$headers = entityHeaderSet;
        this.val$depth = n2;
        this.val$processedGroupNames = set;
        this.val$processedGroupIds = set2;
    }

    /*
     * Loose catch block
     */
    @Override
    void a(String string, Attributes attributes) throws NamingException {
        String[] stringArray = a;
        Attribute attribute = attributes.get(stringArray[1]);
        for (GroupMappingConfig groupMappingConfig : this.val$groupTypes) {
            LdapGroup ldapGroup;
            Object object;
            String string2;
            Object object2;
            int n2;
            Attribute attribute2;
            String string3 = groupMappingConfig.getObjClass();
            if (!LdapUtils.a(attribute, string3)) continue;
            MemberStrategy memberStrategy = groupMappingConfig.getMemberStrategy();
            try {
                if (MemberStrategy.MEMBERS_BY_OU.equals((Object)memberStrategy)) {
                    this.this$0.a(this.val$searchContext, string, (EntityHeaderSet<IdentityHeader>)this.val$headers, this.val$depth, this.val$processedGroupNames, this.val$processedGroupIds);
                    continue;
                }
            }
            catch (FindException findException) {
                throw t.a(findException);
            }
            if (MemberStrategy.MEMBERS_ARE_LOGIN.equals((Object)memberStrategy)) {
                attribute2 = attributes.get(groupMappingConfig.getMemberAttrName());
                if (attribute2 == null) continue;
                for (n2 = 0; n2 < attribute2.size(); ++n2) {
                    LdapUser ldapUser;
                    object2 = attribute2.get(n2);
                    if (object2 == null) continue;
                    string2 = object2.toString();
                    try {
                        ldapUser = (LdapUser)this.this$0.getUserManager().findByLogin(string2);
                    }
                    catch (FindException findException) {
                        throw (NamingException)new NamingException().initCause(findException);
                    }
                    if (ldapUser != null) {
                        object = new IdentityHeader(this.this$0.e(), ldapUser.getDn(), EntityType.USER, ldapUser.getLogin(), null, ldapUser.getName(), null);
                        this.val$headers.add((EntityHeader)object);
                        continue;
                    }
                    try {
                        if (!this.this$0.a(this.val$depth) || this.val$processedGroupNames.contains(string2)) continue;
                    }
                    catch (FindException findException) {
                        throw t.a(findException);
                    }
                    try {
                        object = this.this$0.findByName(string2);
                        if (object == null) continue;
                        ldapGroup = this.this$0.a((LdapGroup)object, this.val$depth + 1, this.val$processedGroupNames, this.val$processedGroupIds);
                        this.val$headers.addAll((Collection)ldapGroup);
                        this.val$processedGroupNames.add(object.getName());
                        this.val$processedGroupIds.add(object.getDn());
                        continue;
                    }
                    catch (FindException findException) {
                        stringArray = a;
                        LdapGroupManagerImpl.b.log(Level.WARNING, stringArray[9] + string2 + stringArray[6], findException);
                    }
                }
                continue;
            }
            try {
                if (!MemberStrategy.MEMBERS_ARE_DN.equals((Object)memberStrategy) && !MemberStrategy.MEMBERS_ARE_NVPAIR.equals((Object)memberStrategy)) continue;
            }
            catch (FindException findException) {
                throw t.a(findException);
            }
            attribute2 = attributes.get(groupMappingConfig.getMemberAttrName());
            if (attribute2 == null) continue;
            for (n2 = 0; n2 < attribute2.size(); ++n2) {
                EntityHeaderSet<IdentityHeader> entityHeaderSet;
                boolean bl2;
                block36: {
                    object2 = attribute2.get(n2);
                    if (object2 == null) continue;
                    string2 = object2.toString();
                    bl2 = false;
                    try {
                        block37: {
                            object = (LdapUser)this.this$0.getUserManager().findByPrimaryKey(string2);
                            if (object != null) {
                                ldapGroup = new IdentityHeader(this.this$0.e(), object.getDn(), EntityType.USER, object.getLogin(), null, object.getName(), null);
                                try {
                                    if (!this.val$headers.contains((Object)ldapGroup)) {
                                        this.val$headers.add((EntityHeader)ldapGroup);
                                    }
                                }
                                catch (FindException findException) {
                                    throw t.a(findException);
                                }
                                bl2 = true;
                                break block36;
                            }
                            if (!this.this$0.a(this.val$depth)) break block36;
                            ldapGroup = null;
                            if (!this.val$processedGroupIds.contains(string2)) {
                                try {
                                    ldapGroup = this.this$0.findByPrimaryKey(string2);
                                }
                                catch (FindException findException) {
                                    stringArray = a;
                                    LdapGroupManagerImpl.b.finest(stringArray[8] + string2 + stringArray[4] + findException.getMessage());
                                }
                            }
                            try {
                                if (ldapGroup != null || this.val$processedGroupNames.contains(string2)) break block37;
                            }
                            catch (FindException findException) {
                                throw t.a(findException);
                            }
                            try {
                                ldapGroup = this.this$0.findByName(string2);
                            }
                            catch (FindException findException) {
                                stringArray = a;
                                LdapGroupManagerImpl.b.finest(stringArray[7] + string2 + stringArray[5] + findException.getMessage());
                                ldapGroup = null;
                            }
                        }
                        if (ldapGroup != null) {
                            entityHeaderSet = this.this$0.a(ldapGroup, this.val$depth + 1, this.val$processedGroupNames, this.val$processedGroupIds);
                            this.val$headers.addAll(entityHeaderSet);
                            this.val$processedGroupNames.add(ldapGroup.getName());
                            this.val$processedGroupIds.add(ldapGroup.getDn());
                            bl2 = true;
                        }
                    }
                    catch (FindException findException) {
                        stringArray = a;
                        LdapGroupManagerImpl.b.log(Level.FINEST, stringArray[2], findException);
                    }
                }
                if (bl2) continue;
                try {
                    block38: {
                        if (this.this$0.a(this.val$searchContext, string2, (Set<IdentityHeader>)this.val$headers)) continue;
                        break block38;
                        catch (FindException findException) {
                            throw t.a(findException);
                        }
                    }
                    if (!this.this$0.a(this.val$depth)) continue;
                }
                catch (FindException findException) {
                    throw t.a(findException);
                }
                object = this.this$0.a(string2);
                if (this.val$processedGroupNames.contains(object)) continue;
                try {
                    ldapGroup = this.this$0.findByName((String)object);
                    if (ldapGroup == null) continue;
                    entityHeaderSet = this.this$0.a(ldapGroup, this.val$depth + 1, this.val$processedGroupNames, this.val$processedGroupIds);
                    this.val$headers.addAll(entityHeaderSet);
                    this.val$processedGroupNames.add(ldapGroup.getName());
                    this.val$processedGroupIds.add(ldapGroup.getDn());
                    continue;
                }
                catch (FindException findException) {
                    stringArray = a;
                    LdapGroupManagerImpl.b.log(Level.WARNING, stringArray[3] + (String)object + stringArray[0], findException);
                }
            }
        }
    }

    private static FindException a(FindException findException) {
        return findException;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[10];
                var3_1 = 0;
                var2_2 = "#0\u000bk|\u00025\u0014T~h\u007f\u001b#1g\u007f\u0006>\u0018T=v{\u001b?\u001bVx$k\u001b5\u0005\u0000ill\u0007%\u0010H=`pDp\u0003Rd$p\u001e \u0016Io$s\r$\u001fOy!Al\u001a?\u0005\u0000~l{\u000b;\u001eNz$x\u0007\"WNxwj\r4WGokk\u0018pP\u0012$w\u001bp\u0019Oi$\u007fH7\u0005Oht>\f>\u0014$w\u001bp\u0019Oi$\u007fH7\u0005Oht>\u00061\u001aE\u0002#0\u000bw{\r=\u0004\u0000qmu\rp";
                var4_3 = "#0\u000bk|\u00025\u0014T~h\u007f\u001b#1g\u007f\u0006>\u0018T=v{\u001b?\u001bVx$k\u001b5\u0005\u0000ill\u0007%\u0010H=`pDp\u0003Rd$p\u001e \u0016Io$s\r$\u001fOy!Al\u001a?\u0005\u0000~l{\u000b;\u001eNz$x\u0007\"WNxwj\r4WGokk\u0018pP\u0012$w\u001bp\u0019Oi$\u007fH7\u0005Oht>\f>\u0014$w\u001bp\u0019Oi$\u007fH7\u0005Oht>\u00061\u001aE\u0002#0\u000bw{\r=\u0004\u0000qmu\rp".length();
                var1_4 = 2;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = t.a(v0, t.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "#/YiPT%9!Y$!\u00158NkQT*8/_oJ\u001a.p,Sv\u0003\u001a,#>Y`\u0003\u0013;??L$\u0004";
                    var4_3 = "#/YiPT%9!Y$!\u00158NkQT*8/_oJ\u001a.p,Sv\u0003\u001a,#>Y`\u0003\u0013;??L$\u0004".length();
                    var1_4 = 11;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 108;
                        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++] = t.a(v0, t.a(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;
            }
        }
        t.a = var5;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x25);
        }
        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 -> 60;
                    case 1 -> 38;
                    case 2 -> 80;
                    case 3 -> 104;
                    case 4 -> 79;
                    case 5 -> 24;
                    default -> 37;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

