/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.identity.Group
 *  com.l7tech.identity.Identity
 *  com.l7tech.identity.User
 *  com.l7tech.identity.internal.InternalGroup
 *  com.l7tech.identity.mapping.IdentityMapping
 *  com.l7tech.objectmodel.AttributeHeader
 */
package com.l7tech.server.identity.mapping;

import com.l7tech.identity.Group;
import com.l7tech.identity.Identity;
import com.l7tech.identity.User;
import com.l7tech.identity.internal.InternalGroup;
import com.l7tech.identity.mapping.IdentityMapping;
import com.l7tech.objectmodel.AttributeHeader;
import com.l7tech.server.identity.mapping.AttributeExtractor;
import java.text.MessageFormat;

abstract class a<MT extends IdentityMapping>
implements AttributeExtractor {
    protected final Object[] EMPTY = new Object[0];
    protected MT mapping;
    private static final String[] b;

    protected a(MT MT) {
        this.mapping = MT;
    }

    @Override
    public Object[] extractValues(Identity identity) {
        String string;
        Object[] objectArray;
        String string2;
        IllegalArgumentException illegalArgumentException;
        IllegalArgumentException illegalArgumentException2;
        AttributeHeader attributeHeader = this.mapping.getAttributeConfig().getHeader();
        try {
            if (attributeHeader == AttributeHeader.ID) {
                return this.a(identity.getId());
            }
        }
        catch (IllegalArgumentException illegalArgumentException3) {
            throw a.a(illegalArgumentException3);
        }
        try {
            if (attributeHeader == AttributeHeader.PROVIDER_GOID) {
                return this.a(identity.getProviderId());
            }
        }
        catch (IllegalArgumentException illegalArgumentException4) {
            throw a.a(illegalArgumentException4);
        }
        try {
            if (attributeHeader == AttributeHeader.NAME) {
                return this.a(identity.getName());
            }
        }
        catch (IllegalArgumentException illegalArgumentException5) {
            throw a.a(illegalArgumentException5);
        }
        if (identity instanceof User) {
            User user = (User)identity;
            try {
                if (attributeHeader == AttributeHeader.SUBJECT_DN) {
                    return this.a(user.getSubjectDn());
                }
            }
            catch (IllegalArgumentException illegalArgumentException6) {
                throw a.a(illegalArgumentException6);
            }
            try {
                if (attributeHeader == AttributeHeader.EMAIL) {
                    return this.a(user.getEmail());
                }
            }
            catch (IllegalArgumentException illegalArgumentException7) {
                throw a.a(illegalArgumentException7);
            }
            try {
                if (attributeHeader == AttributeHeader.LOGIN) {
                    return this.a(user.getLogin());
                }
            }
            catch (IllegalArgumentException illegalArgumentException8) {
                throw a.a(illegalArgumentException8);
            }
            try {
                if (attributeHeader == AttributeHeader.FIRST_NAME) {
                    return this.a(user.getFirstName());
                }
            }
            catch (IllegalArgumentException illegalArgumentException9) {
                throw a.a(illegalArgumentException9);
            }
            try {
                if (attributeHeader == AttributeHeader.LAST_NAME) {
                    return this.a(user.getLastName());
                }
            }
            catch (IllegalArgumentException illegalArgumentException10) {
                throw a.a(illegalArgumentException10);
            }
            try {
                if (attributeHeader == AttributeHeader.DEPARTMENT) {
                    return this.a(user.getDepartment());
                }
            }
            catch (IllegalArgumentException illegalArgumentException11) {
                throw a.a(illegalArgumentException11);
            }
            return this.EMPTY;
        }
        if (identity instanceof Group) {
            InternalGroup internalGroup = (InternalGroup)identity;
            try {
                if (attributeHeader == AttributeHeader.DESCRIPTION) {
                    return this.a(internalGroup.getDescription());
                }
            }
            catch (IllegalArgumentException illegalArgumentException12) {
                throw a.a(illegalArgumentException12);
            }
            return this.EMPTY;
        }
        try {
            IllegalArgumentException illegalArgumentException13;
            illegalArgumentException2 = illegalArgumentException13;
            illegalArgumentException = illegalArgumentException13;
            string2 = b[1];
            Object[] objectArray2 = new Object[1];
            Object[] objectArray3 = objectArray2;
            objectArray = objectArray2;
            int n2 = 0;
            string = identity == null ? b[0] : identity.getClass().getSimpleName();
        }
        catch (IllegalArgumentException illegalArgumentException14) {
            throw a.a(illegalArgumentException14);
        }
        objectArray3[n2] = string;
        illegalArgumentException2(MessageFormat.format(string2, objectArray));
        throw illegalArgumentException;
    }

    protected Object[] a(Object object) {
        return new Object[]{object};
    }

    private static IllegalArgumentException a(IllegalArgumentException illegalArgumentException) {
        return illegalArgumentException;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "*HY/&\rYP-0\u00048=\u001d\\0d\fl?\rHod\u0003#0\u001dTc\u0011\u001e)6\u001dZ1d*>+HE";
        int n3 = "*HY/&\rYP-0\u00048=\u001d\\0d\fl?\rHod\u0003#0\u001dTc\u0011\u001e)6\u001dZ1d*>+HE".length();
        int n4 = 4;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = a.a(122, a.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                b = 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] ^ 0x36);
        }
        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 -> 62;
                    case 1 -> 71;
                    case 2 -> 79;
                    case 3 -> 57;
                    case 4 -> 62;
                    case 5 -> 23;
                    default -> 54;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

