class LoginAuthenticator {

    @VisibleForTesting
    boolean checkSessionUpgrade(SSOToken ssoToken, AuthIndexType indexType, String indexValue)
            throws AuthLoginException, SSOException {

        String value;
        boolean upgrade = false;

        if (ssoToken == null) {
            return true;
        }

        switch (indexType) {
        case USER: {
            value = ssoToken.getProperty("UserToken");
            if (indexValue == null || !indexValue.equals(value)) {
                upgrade = true;
            }
            break;
        }
        case ROLE: {
            final Set<String> roles = AMAuthUtils.getAuthenticatedRoles(ssoToken);
            upgrade = !roles.contains(indexValue);
            break;
        }
        case SERVICE: {
            final Set<String> services = AMAuthUtils.getAuthenticatedServices(ssoToken);
            upgrade = !services.contains(indexValue);
            break;
        }
        case MODULE: {
            final Set<String> modules = AMAuthUtils.getAuthenticatedSchemes(ssoToken);
            upgrade = !modules.contains(indexValue);
            break;
        }
        case LEVEL: {
            int i = Integer.parseInt(indexValue);
            String authLevelProperty = ssoToken.getProperty("AuthLevel");
            int authLevel;
            if (authLevelProperty.contains(":")) {
                String[] realmAuthLevel = authLevelProperty.split(":");
                authLevel = Integer.parseInt(realmAuthLevel[1]);
            } else {
                authLevel = Integer.parseInt(authLevelProperty);
            }
            if (i > authLevel) {
                upgrade = true;
            }
            break;
        }
        case COMPOSITE: {
            upgrade = true;
            break;
        }

        }

        return upgrade;
    }

    @Inject public  LoginAuthenticator(CoreServicesWrapper coreServicesWrapper);

}