/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.security.rbac.Role
 *  com.l7tech.objectmodel.EntityType
 *  com.l7tech.objectmodel.Goid
 *  jakarta.persistence.criteria.CriteriaBuilder
 *  jakarta.persistence.criteria.CriteriaQuery
 *  jakarta.persistence.criteria.Expression
 *  jakarta.persistence.criteria.Predicate
 *  jakarta.persistence.criteria.Root
 *  jakarta.persistence.criteria.Selection
 *  org.hibernate.HibernateException
 *  org.hibernate.Session
 */
package com.l7tech.server.security.rbac;

import com.l7tech.gateway.common.security.rbac.Role;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.Goid;
import com.l7tech.server.security.rbac.RoleManagerImpl;
import com.l7tech.server.util.ReadOnlyHibernateCallback;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Expression;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.persistence.criteria.Selection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;

class n
extends ReadOnlyHibernateCallback<Collection<Role>> {
    final EntityType val$etype;
    final Goid val$entityId;
    final RoleManagerImpl this$0;
    private static final String[] a;

    n(RoleManagerImpl roleManagerImpl, EntityType entityType, Goid goid) {
        this.this$0 = roleManagerImpl;
        this.val$etype = entityType;
        this.val$entityId = goid;
    }

    @Override
    protected List<Role> doInHibernateReadOnly(Session session) throws HibernateException, SQLException {
        CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
        CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Role.class);
        Root root = criteriaQuery.from(Role.class);
        String[] stringArray = a;
        Predicate predicate = criteriaBuilder.equal((Expression)root.get(stringArray[0]), (Object)this.val$etype.name());
        predicate = criteriaBuilder.and((Expression)predicate, (Expression)criteriaBuilder.equal((Expression)root.get(stringArray[1]), (Object)this.val$entityId));
        criteriaQuery.select((Selection)root).where((Expression)predicate);
        List list = session.createQuery(criteriaQuery).getResultList();
        for (Role role : list) {
            this.this$0.initializeLazilyLoaded(role);
        }
        return list;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "\u001d#,\u0001\r\b:\u0001==&\u0018\u001c\u000b\n\u001d#,\u0001\r\b)\u0017$<";
        int n3 = "\u001d#,\u0001\r\b:\u0001==&\u0018\u001c\u000b\n\u001d#,\u0001\r\b)\u0017$<".length();
        int n4 = 14;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = n.a(116, n.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                a = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x1A);
        }
        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 -> 12;
                    case 1 -> 57;
                    case 2 -> 44;
                    case 3 -> 28;
                    case 4 -> 13;
                    case 5 -> 5;
                    default -> 26;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

