/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.identity.AuthenticationException
 *  com.l7tech.identity.BadCredentialsException
 *  com.l7tech.identity.CredentialExpiredPasswordDetailsException
 *  com.l7tech.identity.FailAttemptsExceededException
 *  com.l7tech.identity.FailInactivityPeriodExceededException
 *  com.l7tech.identity.Group
 *  com.l7tech.identity.IdentityProvider
 *  com.l7tech.identity.IdentityProviderConfig
 *  com.l7tech.identity.LoginRequireClientCertificateException
 *  com.l7tech.identity.User
 *  com.l7tech.identity.UserDisabledException
 *  com.l7tech.identity.ValidationException
 *  com.l7tech.identity.internal.InternalUser
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.IdentityHeader
 *  com.l7tech.objectmodel.ObjectModelException
 *  com.l7tech.policy.assertion.credential.CredentialFormat
 *  com.l7tech.policy.assertion.credential.LoginCredentials
 *  com.l7tech.security.token.SecurityToken
 *  com.l7tech.security.token.SecurityTokenType
 *  com.l7tech.security.token.UsernamePasswordSecurityToken
 *  com.l7tech.util.Background
 *  com.l7tech.util.Config
 *  com.l7tech.util.ConfigFactory
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.Functions$Nullary
 *  com.l7tech.util.HexUtils
 *  com.l7tech.util.Pair
 *  com.l7tech.util.TimeUnit
 *  com.l7tech.util.ValidatedConfig
 *  org.apache.commons.collections.map.LRUMap
 *  org.jetbrains.annotations.NotNull
 *  org.springframework.context.ApplicationEvent
 */
package com.l7tech.server.admin;

import com.l7tech.identity.AuthenticationException;
import com.l7tech.identity.BadCredentialsException;
import com.l7tech.identity.CredentialExpiredPasswordDetailsException;
import com.l7tech.identity.FailAttemptsExceededException;
import com.l7tech.identity.FailInactivityPeriodExceededException;
import com.l7tech.identity.Group;
import com.l7tech.identity.IdentityProvider;
import com.l7tech.identity.IdentityProviderConfig;
import com.l7tech.identity.LoginRequireClientCertificateException;
import com.l7tech.identity.User;
import com.l7tech.identity.UserDisabledException;
import com.l7tech.identity.ValidationException;
import com.l7tech.identity.internal.InternalUser;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.IdentityHeader;
import com.l7tech.objectmodel.ObjectModelException;
import com.l7tech.policy.assertion.credential.CredentialFormat;
import com.l7tech.policy.assertion.credential.LoginCredentials;
import com.l7tech.security.token.SecurityToken;
import com.l7tech.security.token.SecurityTokenType;
import com.l7tech.security.token.UsernamePasswordSecurityToken;
import com.l7tech.server.admin.GroupCache;
import com.l7tech.server.admin.a;
import com.l7tech.server.admin.b;
import com.l7tech.server.admin.q;
import com.l7tech.server.admin.r;
import com.l7tech.server.admin.s;
import com.l7tech.server.cluster.ClusterMaster;
import com.l7tech.server.event.EntityClassEvent;
import com.l7tech.server.event.admin.Updated;
import com.l7tech.server.event.system.ReadyForMessages;
import com.l7tech.server.identity.AuthenticatingIdentityProvider;
import com.l7tech.server.identity.AuthenticationResult;
import com.l7tech.server.identity.IdentityProviderFactory;
import com.l7tech.server.identity.internal.InternalIdentityProvider;
import com.l7tech.server.identity.internal.InternalUserManager;
import com.l7tech.server.identity.internal.InternalUserPasswordManager;
import com.l7tech.server.logon.LogonService;
import com.l7tech.server.security.PasswordEnforcerManager;
import com.l7tech.server.security.rbac.RbacServices;
import com.l7tech.server.security.rbac.RoleManager;
import com.l7tech.server.security.rbac.RoleManagerIdentitySourceSupport;
import com.l7tech.server.util.PostStartupApplicationListener;
import com.l7tech.util.Background;
import com.l7tech.util.Config;
import com.l7tech.util.ConfigFactory;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.Functions;
import com.l7tech.util.HexUtils;
import com.l7tech.util.Pair;
import com.l7tech.util.TimeUnit;
import com.l7tech.util.ValidatedConfig;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.security.SecureRandom;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.security.auth.login.LoginException;
import org.apache.commons.collections.map.LRUMap;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.ApplicationEvent;

public class AdminSessionManager
extends RoleManagerIdentitySourceSupport
implements PostStartupApplicationListener,
PropertyChangeListener {
    private static final Logger a;
    private static final a b;
    private static final long c;
    private static final long d;
    private static final long e;
    private static final long f;
    private final Config g;
    private final LogonService h;
    private final Timer i;
    private RbacServices j;
    private IdentityProviderFactory k;
    private PasswordEnforcerManager l;
    private final ClusterMaster m;
    private static Functions.Nullary<Boolean> n;
    private final LRUMap o = new LRUMap(1000);
    private static final SecureRandom p;
    private final Object q = new Object();
    private final GroupCache r;
    private Set<IdentityProvider> s;
    private static final long t;
    private final AtomicLong u = new AtomicLong();
    private static final String[] w;

    public AdminSessionManager(Config config, LogonService logonService, Timer timer, ClusterMaster clusterMaster) {
        Background.scheduleRepeated((TimerTask)new s(this), (long)(f * 4L), (long)f);
        this.g = this.a(config);
        this.h = logonService;
        this.i = timer;
        this.m = clusterMaster;
        String[] stringArray = w;
        int n2 = config.getIntProperty(stringArray[19], 100);
        int n3 = config.getIntProperty(stringArray[26], 300000);
        int n4 = config.getIntProperty(stringArray[24], 50);
        this.r = new GroupCache(stringArray[8], n2, n3, n4);
        this.u.set(this.a());
    }

    public void setRoleManager(RoleManager roleManager) {
        this.roleManager = roleManager;
    }

    public void setIdentityProviderFactory(IdentityProviderFactory identityProviderFactory) {
        this.k = identityProviderFactory;
    }

    public void setPasswordEnforcerManager(PasswordEnforcerManager passwordEnforcerManager) {
        this.l = passwordEnforcerManager;
    }

    public void setRbacServices(RbacServices rbacServices) {
        this.j = rbacServices;
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        if (applicationEvent instanceof EntityClassEvent) {
            EntityClassEvent entityClassEvent = (EntityClassEvent)applicationEvent;
            try {
                if (entityClassEvent.getEntityClass() != IdentityProviderConfig.class) return;
                this.b();
                return;
            }
            catch (IllegalStateException illegalStateException) {
                throw AdminSessionManager.a(illegalStateException);
            }
        }
        if (applicationEvent instanceof Updated) {
            Updated updated = (Updated)applicationEvent;
            Object ET = updated.getEntity();
            try {
                if (ET instanceof Group) {
                    this.r.invalidate(((Group)ET).getProviderId());
                }
            }
            catch (IllegalStateException illegalStateException) {
                throw AdminSessionManager.a(illegalStateException);
            }
            try {
                if (!(ET instanceof User)) return;
                this.r.invalidate(((User)ET).getProviderId());
                return;
            }
            catch (IllegalStateException illegalStateException) {
                throw AdminSessionManager.a(illegalStateException);
            }
        }
        try {
            if (!(applicationEvent instanceof ReadyForMessages)) return;
            this.i.scheduleAtFixedRate((TimerTask)new q(this), 1L, TimeUnit.HOURS.toMillis(24L));
            this.i.scheduleAtFixedRate((TimerTask)new r(this), 1L, TimeUnit.HOURS.toMillis(24L));
            return;
        }
        catch (IllegalStateException illegalStateException) {
            throw AdminSessionManager.a(illegalStateException);
        }
    }

    @Override
    public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
        block5: {
            String[] stringArray;
            String string;
            block4: {
                string = propertyChangeEvent.getPropertyName();
                try {
                    if (string == null || !string.equals(w[14])) break block4;
                }
                catch (IllegalStateException illegalStateException) {
                    throw AdminSessionManager.a(illegalStateException);
                }
                stringArray = w;
                int n2 = this.g.getIntProperty(stringArray[26], 300000);
                a.config(stringArray[25] + n2 + stringArray[33]);
                this.r.a(n2);
            }
            try {
                if (string == null || !string.equals(w[37])) break block5;
            }
            catch (IllegalStateException illegalStateException) {
                throw AdminSessionManager.a(illegalStateException);
            }
            long l2 = this.a();
            stringArray = w;
            a.config(stringArray[18] + l2 + stringArray[33]);
            this.u.set(l2);
        }
    }

    public User authorize(Goid goid, String string) throws ObjectModelException {
        Set<IdentityProvider> set = this.getAdminIdentityProviders();
        User user = null;
        for (IdentityProvider identityProvider : set) {
            if (!identityProvider.getConfig().getGoid().equals((Object)goid)) continue;
            try {
                User user2 = identityProvider.getUserManager().findByPrimaryKey(string);
                if (user2 == null) break;
                this.a(user2);
                String[] stringArray = w;
                a.fine(stringArray[40] + identityProvider.getConfig().getName());
                user = user2;
            }
            catch (AuthenticationException authenticationException) {
                String[] stringArray = w;
                a.warning(stringArray[15] + string + stringArray[22] + ExceptionUtils.getMessage((Throwable)authenticationException) + stringArray[33]);
            }
            break;
        }
        return user;
    }

    public AuthenticationResult authenticate(LoginCredentials loginCredentials) throws ObjectModelException, LoginException, FailAttemptsExceededException, FailInactivityPeriodExceededException, UserDisabledException {
        boolean bl2 = this.g.getBooleanProperty(w[9], true);
        return this.authenticate(loginCredentials, bl2);
    }

    /*
     * Unable to fully structure code
     */
    public AuthenticationResult authenticate(LoginCredentials var1_1, boolean var2_2) throws ObjectModelException, LoginException, FailAttemptsExceededException, FailInactivityPeriodExceededException, UserDisabledException {
        block48: {
            block47: {
                block44: {
                    block43: {
                        var3_3 = this.getAdminIdentityProviders();
                        var4_4 = null;
                        var5_5 = null;
                        var6_6 = var1_1.getFormat();
                        if (var6_6 == CredentialFormat.CLEARTEXT) ** GOTO lbl12
                        try {
                            block49: {
                                if (var6_6 != CredentialFormat.CLIENTCERT) break block43;
                                break block49;
                                catch (BadCredentialsException v0) {
                                    throw AdminSessionManager.a((Exception)v0);
                                }
                            }
                            v1 = true;
                            break block44;
                        }
                        catch (BadCredentialsException v2) {
                            throw AdminSessionManager.a((Exception)v2);
                        }
                    }
                    v1 = false;
                }
                var7_7 = v1;
                try {
                    if (!var7_7) {
                        throw new LoginException(AdminSessionManager.w[11] + String.valueOf(var6_6));
                    }
                }
                catch (BadCredentialsException v3) {
                    throw AdminSessionManager.a((Exception)v3);
                }
                var8_8 = false;
                var9_9 = null;
                for (IdentityProvider var11_11 : var3_3) {
                    try {
                        if (var8_8) {
                            break;
                        }
                    }
                    catch (ObjectModelException v4) {
                        throw AdminSessionManager.a((Exception)v4);
                    }
                    try {
                        block45: {
                            if (!var2_2) break block45;
                            try {
                                block50: {
                                    if (var6_6 != CredentialFormat.CLEARTEXT) break block45;
                                    break block50;
                                    catch (BadCredentialsException v5) {
                                        throw AdminSessionManager.a((Exception)v5);
                                    }
                                }
                                if (!var11_11.hasClientCert(var1_1.getLogin())) break block45;
                            }
                            catch (BadCredentialsException v6) {
                                throw AdminSessionManager.a((Exception)v6);
                            }
                            var8_8 = true;
                            var15_17 = AdminSessionManager.w;
                            throw new BadCredentialsException(var15_17[32] + var1_1.getLogin() + var15_17[13]);
                        }
                        var12_12 = null;
                        try {
                            block46: {
                                block51: {
                                    var12_12 = (User)((AuthenticatingIdentityProvider)var11_11).findUserByCredential(var1_1);
                                    if (var12_12 == null) continue;
                                    this.h.hookPreLoginCheck(var12_12);
                                    var13_14 = ((AuthenticatingIdentityProvider)var11_11).authenticate(var1_1, true);
                                    try {
                                        v7 = var13_14 == null ? null : var13_14.getUser();
                                    }
                                    catch (BadCredentialsException v8) {
                                        throw AdminSessionManager.a((Exception)v8);
                                    }
                                    var14_16 = v7;
                                    if (var14_16 == null) continue;
                                    this.a(var14_16);
                                    AdminSessionManager.a.info(AdminSessionManager.w[34] + var11_11.getConfig().getName());
                                    if (!this.l.isPasswordExpired(var14_16)) break block46;
                                    break block51;
                                    catch (BadCredentialsException v9) {
                                        throw AdminSessionManager.a((Exception)v9);
                                    }
                                }
                                try {
                                    block52: {
                                        if (var1_1.getClientCert() != null) break block46;
                                        break block52;
                                        catch (BadCredentialsException v10) {
                                            throw AdminSessionManager.a((Exception)v10);
                                        }
                                    }
                                    throw new CredentialExpiredPasswordDetailsException(AdminSessionManager.w[2], this.l.getPasswordPolicy().getDescription());
                                }
                                catch (BadCredentialsException v11) {
                                    throw AdminSessionManager.a((Exception)v11);
                                }
                            }
                            var4_4 = var13_14;
                            var5_5 = var14_16;
                            break;
                        }
                        catch (BadCredentialsException var13_15) {
                            if (var9_9 != null) continue;
                            var9_9 = var12_12;
                        }
                    }
                    catch (AuthenticationException var12_13) {
                        try {
                            AdminSessionManager.a.info(AdminSessionManager.w[27] + var11_11.getConfig().getName() + AdminSessionManager.w[1] + ExceptionUtils.getMessage((Throwable)var12_13));
                            if (ExceptionUtils.causedBy((Throwable)var12_13, FailAttemptsExceededException.class)) {
                                throw new FailAttemptsExceededException(var12_13.getMessage());
                            }
                        }
                        catch (BadCredentialsException v12) {
                            throw AdminSessionManager.a((Exception)v12);
                        }
                        try {
                            if (ExceptionUtils.causedBy((Throwable)var12_13, FailInactivityPeriodExceededException.class)) {
                                throw new FailInactivityPeriodExceededException(var12_13.getMessage());
                            }
                        }
                        catch (BadCredentialsException v13) {
                            throw AdminSessionManager.a((Exception)v13);
                        }
                        try {
                            if (!ExceptionUtils.causedBy((Throwable)var12_13, UserDisabledException.class)) continue;
                            throw new UserDisabledException(var12_13.getMessage());
                        }
                        catch (BadCredentialsException v14) {
                            throw AdminSessionManager.a((Exception)v14);
                        }
                    }
                }
                try {
                    if (var5_5 == null) break block47;
                    this.h.updateLogonAttempt(var5_5, var4_4);
                    break block48;
                }
                catch (BadCredentialsException v15) {
                    throw AdminSessionManager.a((Exception)v15);
                }
            }
            try {
                if (var9_9 != null) {
                    this.h.updateLogonAttempt(var9_9, null);
                }
            }
            catch (BadCredentialsException v16) {
                throw AdminSessionManager.a((Exception)v16);
            }
            try {
                if (var8_8) {
                    throw new LoginRequireClientCertificateException();
                }
            }
            catch (BadCredentialsException v17) {
                throw AdminSessionManager.a((Exception)v17);
            }
        }
        return var4_4;
    }

    public boolean changePassword(String string, String string2, String string3) throws LoginException, ObjectModelException {
        Set<IdentityProvider> set = this.getAdminIdentityProviders();
        User user = null;
        for (IdentityProvider identityProvider : set) {
            user = identityProvider.getUserManager().findByLogin(string);
            if (user == null) continue;
            try {
                try {
                    if (identityProvider.hasClientCert(string)) {
                        throw new LoginException(w[36]);
                    }
                    break;
                }
                catch (LoginException loginException) {
                    throw AdminSessionManager.a(loginException);
                }
            }
            catch (AuthenticationException authenticationException) {
                a.log(Level.WARNING, w[42], authenticationException);
                user = null;
            }
        }
        try {
            if (user == null) {
                return false;
            }
        }
        catch (AuthenticationException authenticationException) {
            throw AdminSessionManager.a((Exception)((Object)authenticationException));
        }
        return this.changePassword(user, string2, string3);
    }

    public boolean changePassword(User user, String string, String string2) throws ObjectModelException {
        boolean bl2 = false;
        Set<IdentityProvider> set = this.getAdminIdentityProviders();
        IdentityProvider identityProvider = null;
        for (IdentityProvider object2 : set) {
            if (!object2.getConfig().getGoid().equals((Object)user.getProviderId())) continue;
            identityProvider = object2;
            break;
        }
        if (identityProvider != null) {
            LoginCredentials loginCredentials = LoginCredentials.makeLoginCredentials((SecurityToken)new UsernamePasswordSecurityToken(SecurityTokenType.UNKNOWN, user.getLogin(), string.toCharArray()), null);
            try {
                String string3;
                Object object;
                InternalUser internalUser;
                block10: {
                    User user2;
                    AuthenticationResult authenticationException = ((AuthenticatingIdentityProvider)identityProvider).authenticate(loginCredentials, true);
                    try {
                        User user3 = user2 = authenticationException == null ? null : authenticationException.getUser();
                    }
                    catch (AuthenticationException authenticationException2) {
                        throw AdminSessionManager.a((Exception)((Object)authenticationException2));
                    }
                    if (user2 instanceof InternalUser) {
                        internalUser = new InternalUser();
                        object = (InternalUser)user2;
                        internalUser.copyFrom((User)object);
                        internalUser.setVersion(object.getVersion());
                        this.a((User)internalUser);
                        this.l.isPasswordPolicyCompliant((User)internalUser, string2, string);
                        this.l.setUserPasswordPolicyAttributes(internalUser, false);
                        object = (InternalUserManager)((InternalIdentityProvider)identityProvider).getUserManager();
                        InternalUserPasswordManager internalUserPasswordManager = object.getUserPasswordManager();
                        string3 = internalUser.getHashedPassword();
                        boolean bl3 = internalUserPasswordManager.configureUserPasswordHashes(internalUser, string2);
                        try {
                            if (!bl3) {
                                throw new IllegalStateException(w[3]);
                            }
                            break block10;
                        }
                        catch (AuthenticationException authenticationException3) {
                            throw AdminSessionManager.a((Exception)((Object)authenticationException3));
                        }
                    }
                    String[] stringArray = w;
                    throw new IllegalStateException(stringArray[41]);
                }
                internalUser.addPasswordChange(string3);
                object.update((User)internalUser);
                bl2 = true;
            }
            catch (AuthenticationException authenticationException) {
                String[] stringArray = w;
                a.info(stringArray[6] + identityProvider.getConfig().getName() + stringArray[39] + ExceptionUtils.getMessage((Throwable)authenticationException));
            }
        }
        return bl2;
    }

    public synchronized String createSession(User user, Object object) {
        try {
            if (user == null) {
                throw new NullPointerException();
            }
        }
        catch (IllegalStateException illegalStateException) {
            throw AdminSessionManager.a(illegalStateException);
        }
        byte[] byArray = new byte[20];
        p.nextBytes(byArray);
        String string = HexUtils.encodeBase64((byte[])byArray, (boolean)true);
        try {
            this.o.put((Object)string, (Object)new b(user, string, object));
            if (a.isLoggable(Level.FINE)) {
                a.log(Level.FINE, w[21], new String[]{user.getName(), string});
            }
        }
        catch (IllegalStateException illegalStateException) {
            throw AdminSessionManager.a(illegalStateException);
        }
        return string;
    }

    public synchronized Object getSessionInfo(String string) {
        try {
            if (string == null) {
                throw new NullPointerException();
            }
        }
        catch (IllegalStateException illegalStateException) {
            throw AdminSessionManager.a(illegalStateException);
        }
        b b10 = (b)this.o.get((Object)string);
        try {
            if (b10 == null) {
                return null;
            }
        }
        catch (IllegalStateException illegalStateException) {
            throw AdminSessionManager.a(illegalStateException);
        }
        return b10.getSessionInfo();
    }

    public synchronized User resumeSession(String string) throws AuthenticationException, ObjectModelException {
        b b10;
        block7: {
            String string2;
            String string3;
            Level level;
            Logger logger;
            block9: {
                block8: {
                    try {
                        if (string == null) {
                            throw new NullPointerException();
                        }
                    }
                    catch (AuthenticationException authenticationException) {
                        throw AdminSessionManager.a((Exception)((Object)authenticationException));
                    }
                    b10 = (b)this.o.get((Object)string);
                    try {
                        try {
                            if (b10 != null) break block7;
                            logger = a;
                            level = Level.WARNING;
                            string3 = w[23];
                            if (!a.isLoggable(Level.FINER)) break block8;
                        }
                        catch (AuthenticationException authenticationException) {
                            throw AdminSessionManager.a((Exception)((Object)authenticationException));
                        }
                        string2 = string;
                        break block9;
                    }
                    catch (AuthenticationException authenticationException) {
                        throw AdminSessionManager.a((Exception)((Object)authenticationException));
                    }
                }
                string2 = w[29];
            }
            logger.log(level, string3, string2);
            return null;
        }
        User user = b10.getUser();
        this.a(user);
        return user;
    }

    public synchronized void destroySession(String string) {
        this.o.remove((Object)string);
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public boolean isExpired(String string, boolean bl2) {
        b b10;
        boolean bl3;
        block6: {
            b b11;
            bl3 = true;
            try {
                b11 = string == null ? null : (b)this.o.get((Object)string);
            }
            catch (IllegalStateException illegalStateException) {
                throw AdminSessionManager.a(illegalStateException);
            }
            b10 = b11;
            try {
                if (b10 == null) return bl3;
                if (System.currentTimeMillis() - b10.getLastUsed() > this.u.get()) break block6;
            }
            catch (IllegalStateException illegalStateException) {
                throw AdminSessionManager.a(illegalStateException);
            }
            bl3 = false;
            try {
                if (!bl2) return bl3;
                b10.onUsed();
                return bl3;
            }
            catch (IllegalStateException illegalStateException) {
                throw AdminSessionManager.a(illegalStateException);
            }
        }
        String[] stringArray = w;
        a.info(stringArray[16] + b10.getUser().getName() + stringArray[17]);
        this.destroySession(string);
        return bl3;
    }

    @Override
    public Set<IdentityHeader> getGroups(User user, boolean bl2) throws FindException {
        Goid goid = user.getProviderId();
        Set<IdentityProvider> set = this.getAdminIdentityProviders();
        HashSet<IdentityHeader> hashSet = new HashSet<IdentityHeader>();
        for (IdentityProvider identityProvider : set) {
            if (!identityProvider.getConfig().getGoid().equals((Object)goid)) continue;
            try {
                Set<IdentityHeader> set2 = this.r.getCachedValidatedGroups(user, identityProvider, bl2);
                try {
                    if (set2 != null) {
                        hashSet.addAll(set2);
                    }
                }
                catch (ValidationException validationException) {
                    throw AdminSessionManager.a((Exception)((Object)validationException));
                }
            }
            catch (ValidationException validationException) {
                throw new FindException(w[7], (Throwable)validationException);
            }
            return hashSet;
        }
        return Collections.emptySet();
    }

    @Override
    public Set<IdentityHeader> getGroups(@NotNull Group group) throws FindException {
        try {
            if (group == null) {
                AdminSessionManager.b(0);
            }
        }
        catch (FindException findException) {
            throw AdminSessionManager.a((Exception)((Object)findException));
        }
        Goid goid = group.getProviderId();
        Set<IdentityProvider> set = this.getAdminIdentityProviders();
        HashSet<IdentityHeader> hashSet = new HashSet<IdentityHeader>();
        for (IdentityProvider identityProvider : set) {
            if (!identityProvider.getConfig().getGoid().equals((Object)goid)) continue;
            Set<IdentityHeader> set2 = this.r.getCachedGroups(group, identityProvider);
            try {
                if (set2 != null) {
                    hashSet.addAll(set2);
                }
            }
            catch (FindException findException) {
                throw AdminSessionManager.a((Exception)((Object)findException));
            }
            return hashSet;
        }
        return Collections.emptySet();
    }

    public boolean isAdministrativeUser(User user) throws FindException {
        return this.j.isAdministrativeUser((Pair<Goid, String>)new Pair((Object)user.getProviderId(), (Object)user.getId()), user);
    }

    public static void setCertRequirementWavedChecker(Functions.Nullary<Boolean> nullary) {
        block4: {
            block5: {
                try {
                    try {
                        if (nullary == null) break block4;
                        if (n == null) break block5;
                    }
                    catch (IllegalStateException illegalStateException) {
                        throw AdminSessionManager.a(illegalStateException);
                    }
                    throw new IllegalStateException(w[12]);
                }
                catch (IllegalStateException illegalStateException) {
                    throw AdminSessionManager.a(illegalStateException);
                }
            }
            n = nullary;
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    protected Set<IdentityProvider> getAdminIdentityProviders() {
        Set<IdentityProvider> set;
        Object object = this.q;
        synchronized (object) {
            if (this.s == null) {
                this.b();
            }
            set = this.s;
        }
        return set;
    }

    private long a() {
        return this.g.getTimeUnitProperty(w[37], t);
    }

    private void a(User user) throws AuthenticationException, FindException {
        boolean bl2 = this.isAdministrativeUser(user);
        try {
            if (!bl2) {
                throw new AuthenticationException(user.getName() + w[4]);
            }
        }
        catch (AuthenticationException authenticationException) {
            throw AdminSessionManager.a((Exception)((Object)authenticationException));
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private void b() {
        try {
            TreeSet<IdentityProvider> treeSet = new TreeSet<IdentityProvider>(b);
            for (IdentityProvider identityProvider : this.k.findAllIdentityProviders()) {
                IdentityProviderConfig identityProviderConfig = identityProvider.getConfig();
                try {
                    if (!identityProviderConfig.isAdminEnabled()) continue;
                    a.info(w[20] + identityProviderConfig.getName() + w[28]);
                    treeSet.add(identityProvider);
                }
                catch (Exception exception) {
                    throw AdminSessionManager.a(exception);
                }
            }
            Object object = this.q;
            synchronized (object) {
                this.s = Collections.unmodifiableSet(treeSet);
            }
        }
        catch (Exception exception) {
            a.log(Level.WARNING, w[38], exception);
        }
    }

    private Config a(Config config) {
        ValidatedConfig validatedConfig = new ValidatedConfig(config, a);
        String[] stringArray = w;
        validatedConfig.setMinimumValue(stringArray[10], (Number)TimeUnit.MINUTES.toMillis(1L));
        validatedConfig.setMaximumValue(stringArray[37], (Number)e);
        return validatedConfig;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[44];
                var3_1 = 0;
                var2_2 = "%p4zurg#|1zj a0z+zx!~/qv\u0014}(z(L<&j,|(R8;x\"v4\u0002|?\u0011\u0016~*&n*a\"?<-i,a#{w\u001d\u0013l<'96{)j519-r0zy7| }fj)1x1v\":f{60je})ky=x3vfo+<o,\u007f#x<um*3'|:0j63'{4<w,`2m8!p3vfl<'o,p#l.%p4{urg#|1{j a0z+{x!~/qw&|6`/p7\u0016u r(j)\u001cw1v4i89-\u0007j-=|+g/|8!p*}fy6'95r5l.:k!3%w8;~ 3 ~09|!3)qy\u0017\u0013l<'93r*v=4m,|(??4p)v\"1\u0016\u0016m0;z,c's\u001a4z-v\u0019j7<\u007f,v\"45z: k,g?1):u,p?R8;x\"v41?:k'z\"O8&j2|4{\u000e=|+P#m-\u0005k `#q-\u0013*p>:wk`#l*<v+V>o0'`0\u0013q* i5|4k<19&a#{<;m,r*??:k(r2??:ker\"r0;9$p%z*&#e4\u0005z+!97v7j0'|(v(ky\"x3v\"?:=|&x#my=x63's+0x!jf}<0we`#kw/a?=<}e})ky j 3%z+!p#z%~-09$`fs62p+3%m<1|+g/~5&7\u001c6m0;z,c's\n0j6z)q\u001a4z-v\u000b~!\u0001p(v\u001f\u0007j-=v7z<~-<v+3 ~09|!3 p+ul6v4?~*\u0003g)<k,}!?81t,}/l-'x1z0zy&|6`/p7u\u007f*afj*0ke4\u0002a1$\u0013o=4m,}!?*0j6z)qy<w$p2v/<m<36z+<v!3a\u00196m0;z,c's\n0j6z)q\u001a4z-v\u0015v#0\t\u0003q87u,}!?9\u0007j-=|+g/|8!|!33l<'9>#;3y&|1g/q>ux!~/qy&|6`/p7uz*|-v<o9>\";\u000ba3y1l 32pyr$\u0007{4<we`#l*<v+<%p6>p 3(p-u\u007f*f({cubunh'6m0;z,c's\n0j6z)q\u001a4z-v\u000b~!\u0005k,}%v)4u\u0002a)j)&+\u0013o=4m,}!?)'p+p/o8996v5l0:wep'|109(r>?-<t 3a\u001c6m0;z,c's\n0j6z)q\u001a4z-v\u000b~!\u0001p(v\u0019\u0007j-=|+g/|8!p*}fy8<u wfp7u\u0011fy6'9$w+v7uu*t/q*\u000bzq6!96{)h7k>\u0007m> t }2??:keS\bp-\u001bl)\u007ffo8'x(v2z+u>``a?639``h:*ut0`2?7:meq#?7 u)\t!z-\u0012k*f6l\u0006\u0013l<'9b\u0002a1\u0011\u0007j-=|+g/|8!|!3)qy\u0005!m6 i8\u0016~*&n*a\"?:=x+t#?7:mec#m4<m1v\"?= |eg)?0&j0v\"?:0k1z v:4m =\u0013*p>:wk`#l*<v+V>o0'`\u001e\u0005p,9}+42?*0m0cf~=8p+36m6#p!v4l\u0002|?\u000e\u0007j-=v7z<z=uv+3 \u0005~7;v13%w8;~ 36~*&n*a\"??:kef5z+{";
                var4_3 = "%p4zurg#|1zj a0z+zx!~/qv\u0014}(z(L<&j,|(R8;x\"v4\u0002|?\u0011\u0016~*&n*a\"?<-i,a#{w\u001d\u0013l<'96{)j519-r0zy7| }fj)1x1v\":f{60je})ky=x3vfo+<o,\u007f#x<um*3'|:0j63'{4<w,`2m8!p3vfl<'o,p#l.%p4{urg#|1{j a0z+{x!~/qw&|6`/p7\u0016u r(j)\u001cw1v4i89-\u0007j-=|+g/|8!p*}fy6'95r5l.:k!3%w8;~ 3 ~09|!3)qy\u0017\u0013l<'93r*v=4m,|(??4p)v\"1\u0016\u0016m0;z,c's\u001a4z-v\u0019j7<\u007f,v\"45z: k,g?1):u,p?R8;x\"v41?:k'z\"O8&j2|4{\u000e=|+P#m-\u0005k `#q-\u0013*p>:wk`#l*<v+V>o0'`0\u0013q* i5|4k<19&a#{<;m,r*??:k(r2??:ker\"r0;9$p%z*&#e4\u0005z+!97v7j0'|(v(ky\"x3v\"?:=|&x#my=x63's+0x!jf}<0we`#kw/a?=<}e})ky j 3%z+!p#z%~-09$`fs62p+3%m<1|+g/~5&7\u001c6m0;z,c's\n0j6z)q\u001a4z-v\u000b~!\u0001p(v\u001f\u0007j-=v7z<~-<v+3 ~09|!3 p+ul6v4?~*\u0003g)<k,}!?81t,}/l-'x1z0zy&|6`/p7u\u007f*afj*0ke4\u0002a1$\u0013o=4m,}!?*0j6z)qy<w$p2v/<m<36z+<v!3a\u00196m0;z,c's\n0j6z)q\u001a4z-v\u0015v#0\t\u0003q87u,}!?9\u0007j-=|+g/|8!|!33l<'9>#;3y&|1g/q>ux!~/qy&|6`/p7uz*|-v<o9>\";\u000ba3y1l 32pyr$\u0007{4<we`#l*<v+<%p6>p 3(p-u\u007f*f({cubunh'6m0;z,c's\n0j6z)q\u001a4z-v\u000b~!\u0005k,}%v)4u\u0002a)j)&+\u0013o=4m,}!?)'p+p/o8996v5l0:wep'|109(r>?-<t 3a\u001c6m0;z,c's\n0j6z)q\u001a4z-v\u000b~!\u0001p(v\u0019\u0007j-=|+g/|8!p*}fy8<u wfp7u\u0011fy6'9$w+v7uu*t/q*\u000bzq6!96{)h7k>\u0007m> t }2??:keS\bp-\u001bl)\u007ffo8'x(v2z+u>``a?639``h:*ut0`2?7:meq#?7 u)\t!z-\u0012k*f6l\u0006\u0013l<'9b\u0002a1\u0011\u0007j-=|+g/|8!|!3)qy\u0005!m6 i8\u0016~*&n*a\"?:=x+t#?7:mec#m4<m1v\"?= |eg)?0&j0v\"?:0k1z v:4m =\u0013*p>:wk`#l*<v+V>o0'`\u001e\u0005p,9}+42?*0m0cf~=8p+36m6#p!v4l\u0002|?\u000e\u0007j-=v7z<z=uv+3 \u0005~7;v13%w8;~ 36~*&n*a\"??:kef5z+{".length();
                var1_4 = 43;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = AdminSessionManager.b(v0, AdminSessionManager.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u001ep6'vx~)m'-w+g5ed=w=|{d+:$(o(q3'v<.8j%&c= (8m)fhoz>a,fw=|-g6fe<c2lj;a+}2m*\r|(g){\u0005/a";
                    var4_3 = "\u001ep6'vx~)m'-w+g5ed=w=|{d+:$(o(q3'v<.8j%&c= (8m)fhoz>a,fw=|-g6fe<c2lj;a+}2m*\r|(g){\u0005/a".length();
                    var1_4 = 42;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 48;
                        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++] = AdminSessionManager.b(v0, AdminSessionManager.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;
            }
        }
        AdminSessionManager.w = var5;
        AdminSessionManager.a = Logger.getLogger(AdminSessionManager.class.getName());
        AdminSessionManager.b = new a();
        AdminSessionManager.c = TimeUnit.DAYS.toMillis(1L);
        AdminSessionManager.d = TimeUnit.MINUTES.toMillis(1L);
        var0_6 = AdminSessionManager.w;
        AdminSessionManager.e = ConfigFactory.getLongProperty((String)var0_6[43], (long)AdminSessionManager.c);
        AdminSessionManager.f = ConfigFactory.getLongProperty((String)var0_6[5], (long)AdminSessionManager.d);
        AdminSessionManager.p = new SecureRandom();
        AdminSessionManager.t = TimeUnit.MINUTES.toMillis(30L);
    }

    private static /* synthetic */ void b(int n2) {
        String[] stringArray = w;
        throw new IllegalArgumentException(String.format(stringArray[30], stringArray[35], stringArray[0], stringArray[31]));
    }

    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] ^ 0x3E);
        }
        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 -> 107;
                    case 1 -> 50;
                    case 2 -> 116;
                    case 3 -> 120;
                    case 4 -> 52;
                    case 5 -> 104;
                    default -> 62;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

