Search in sources :

Example 1 with PermissionDefinition

use of com.serotonin.m2m2.module.PermissionDefinition in project ma-modules-public by infiniteautomation.

the class PermissionsRestController method listPermissions.

@ApiOperation(value = "List permissions and their system setting keys")
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<List<PermissionDefinitionModel>> listPermissions() {
    List<PermissionDefinitionModel> permissions = new ArrayList<>();
    permissions.add(new PermissionDefinitionModel(SystemSettingsDao.PERMISSION_DATASOURCE, "systemSettings.permissions.datasourceManagement"));
    for (PermissionDefinition def : ModuleRegistry.getDefinitions(PermissionDefinition.class)) {
        permissions.add(new PermissionDefinitionModel(def));
    }
    return new ResponseEntity<>(permissions, HttpStatus.OK);
}
Also used : PermissionDefinitionModel(com.serotonin.m2m2.web.mvc.rest.v1.model.PermissionDefinitionModel) PermissionDefinition(com.serotonin.m2m2.module.PermissionDefinition) ResponseEntity(org.springframework.http.ResponseEntity) ArrayList(java.util.ArrayList) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PermissionDefinition

use of com.serotonin.m2m2.module.PermissionDefinition in project ma-core-public by infiniteautomation.

the class ModuleRegistry method ensurePermissionDefinitions.

private static void ensurePermissionDefinitions() {
    if (PERMISSION_DEFINITIONS == null) {
        synchronized (LOCK) {
            if (PERMISSION_DEFINITIONS == null) {
                Map<String, PermissionDefinition> map = new HashMap<String, PermissionDefinition>();
                for (PermissionDefinition def : Module.getDefinitions(preDefaults, PermissionDefinition.class)) {
                    map.put(def.getPermissionTypeName(), def);
                }
                for (Module module : MODULES.values()) {
                    for (PermissionDefinition def : module.getDefinitions(PermissionDefinition.class)) map.put(def.getPermissionTypeName(), def);
                }
                for (PermissionDefinition def : Module.getDefinitions(postDefaults, PermissionDefinition.class)) {
                    map.put(def.getPermissionTypeName(), def);
                }
                PERMISSION_DEFINITIONS = map;
            }
        }
    }
}
Also used : LegacyPointDetailsViewPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.LegacyPointDetailsViewPermissionDefinition) PurgeAllEventsActionPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.PurgeAllEventsActionPermissionDefinition) PurgeWithPurgeSettingsActionPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.PurgeWithPurgeSettingsActionPermissionDefinition) CoreFileStoreReadPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.CoreFileStoreReadPermissionDefinition) CoreFileStoreWritePermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.CoreFileStoreWritePermissionDefinition) ConfigurationBackupActionPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.ConfigurationBackupActionPermissionDefinition) PublicFileStoreWritePermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.PublicFileStoreWritePermissionDefinition) DocsFileStoreWritePermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.DocsFileStoreWritePermissionDefinition) SqlRestoreActionPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.SqlRestoreActionPermissionDefinition) PurgeAllPointValuesActionPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.PurgeAllPointValuesActionPermissionDefinition) UsersViewPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.UsersViewPermissionDefinition) SuperadminPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.SuperadminPermissionDefinition) EventsViewPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.EventsViewPermissionDefinition) DocsFileStoreReadPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.DocsFileStoreReadPermissionDefinition) SqlBackupActionPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.SqlBackupActionPermissionDefinition) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap)

Example 3 with PermissionDefinition

use of com.serotonin.m2m2.module.PermissionDefinition in project ma-core-public by infiniteautomation.

the class SystemSettingsDao method getAllSystemSettingsAsCodes.

/**
 * Return all settings (if no setting is saved return default value) whilst converting to Export Codes where necessary
 *
 * @return
 */
public Map<String, Object> getAllSystemSettingsAsCodes() {
    Map<String, Object> settings = new HashMap<String, Object>(DEFAULT_VALUES.size());
    // Add The Permissions with empty values since they don't necessarily have defaults
    for (PermissionDefinition def : ModuleRegistry.getDefinitions(PermissionDefinition.class)) {
        settings.put(def.getPermissionTypeName(), "");
    }
    // Start with all the defaults
    Iterator<String> it = DEFAULT_VALUES.keySet().iterator();
    String key;
    while (it.hasNext()) {
        key = it.next();
        if (!key.toLowerCase().contains("password") && !key.startsWith(DATABASE_SCHEMA_VERSION))
            settings.put(key, DEFAULT_VALUES.get(key));
    }
    // Then replace anything with what is stored in the database
    ejt.query("select settingName,settingValue from systemSettings", new RowCallbackHandler() {

        public void processRow(ResultSet rs) throws SQLException {
            String settingName = rs.getString(1);
            // Don't export any passwords or schema numbers
            if ((!settingName.toLowerCase().contains("password") && !settingName.startsWith(DATABASE_SCHEMA_VERSION))) {
                String settingValue = rs.getString(2);
                if (settingValue != null) {
                    // Convert Numbers to Integers
                    try {
                        settings.put(settingName, Integer.parseInt(settingValue));
                    } catch (NumberFormatException e) {
                        // Are we a boolean
                        if (settingValue.equalsIgnoreCase("y")) {
                            settings.put(settingName, new Boolean(true));
                        } else if (settingValue.equalsIgnoreCase("n")) {
                            settings.put(settingName, new Boolean(false));
                        } else {
                            // Must be a string
                            settings.put(settingName, settingValue);
                        }
                    }
                } else {
                    // and also so that there is an indication that a null setting exists
                    if (settings.get(settingName) == null)
                        settings.put(settingName, null);
                }
            }
        }
    });
    // Convert the Integers to Codes
    it = settings.keySet().iterator();
    while (it.hasNext()) {
        key = it.next();
        Object value = settings.get(key);
        if (value instanceof Integer) {
            String code = convertToCodeFromValue(key, (Integer) value);
            if (code != null)
                settings.put(key, code);
        }
    }
    return settings;
}
Also used : SuperadminPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.SuperadminPermissionDefinition) PermissionDefinition(com.serotonin.m2m2.module.PermissionDefinition) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler)

Example 4 with PermissionDefinition

use of com.serotonin.m2m2.module.PermissionDefinition in project ma-core-public by infiniteautomation.

the class MangoCustomMethodSecurityExpressionRoot method hasPermissionType.

/**
 * Does the user have any of the given permissions assigned to the type
 * @param permissionType
 * @return
 */
public boolean hasPermissionType(String permissionType) {
    User user = (User) this.getPrincipal();
    if (user.isAdmin())
        return true;
    Set<String> userPermissions = Permissions.explodePermissionGroups(user.getPermissions());
    for (PermissionDefinition def : ModuleRegistry.getDefinitions(PermissionDefinition.class)) {
        String groups = SystemSettingsDao.getValue(def.getPermissionTypeName());
        Set<String> permissions = Permissions.explodePermissionGroups(groups);
        // TODO Use Collections.disjoint?
        for (String permission : permissions) {
            if (userPermissions.contains(permission))
                return true;
        }
    }
    return false;
}
Also used : PermissionDefinition(com.serotonin.m2m2.module.PermissionDefinition) User(com.serotonin.m2m2.vo.User)

Example 5 with PermissionDefinition

use of com.serotonin.m2m2.module.PermissionDefinition in project ma-core-public by infiniteautomation.

the class SystemSettingsDwr method getSettings.

@DwrPermission(admin = true)
public Map<String, Object> getSettings() {
    Map<String, Object> settings = new HashMap<>();
    // Info
    settings.put(SystemSettingsDao.INSTANCE_DESCRIPTION, SystemSettingsDao.getValue(SystemSettingsDao.INSTANCE_DESCRIPTION));
    // Email
    settings.put(SystemSettingsDao.EMAIL_SMTP_HOST, SystemSettingsDao.getValue(SystemSettingsDao.EMAIL_SMTP_HOST));
    settings.put(SystemSettingsDao.EMAIL_SMTP_PORT, SystemSettingsDao.getIntValue(SystemSettingsDao.EMAIL_SMTP_PORT));
    settings.put(SystemSettingsDao.EMAIL_FROM_ADDRESS, SystemSettingsDao.getValue(SystemSettingsDao.EMAIL_FROM_ADDRESS));
    settings.put(SystemSettingsDao.EMAIL_FROM_NAME, SystemSettingsDao.getValue(SystemSettingsDao.EMAIL_FROM_NAME));
    settings.put(SystemSettingsDao.EMAIL_AUTHORIZATION, SystemSettingsDao.getBooleanValue(SystemSettingsDao.EMAIL_AUTHORIZATION));
    settings.put(SystemSettingsDao.EMAIL_SMTP_USERNAME, SystemSettingsDao.getValue(SystemSettingsDao.EMAIL_SMTP_USERNAME));
    settings.put(SystemSettingsDao.EMAIL_SMTP_PASSWORD, SystemSettingsDao.getValue(SystemSettingsDao.EMAIL_SMTP_PASSWORD));
    settings.put(SystemSettingsDao.EMAIL_TLS, SystemSettingsDao.getBooleanValue(SystemSettingsDao.EMAIL_TLS));
    settings.put(SystemSettingsDao.EMAIL_CONTENT_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.EMAIL_CONTENT_TYPE));
    // System event types
    settings.put("systemEventTypes", SystemEventType.EVENT_TYPES);
    // System event types
    settings.put("auditEventTypes", AuditEventType.EVENT_TYPES);
    // Http
    settings.put(SystemSettingsDao.HTTP_CLIENT_USE_PROXY, SystemSettingsDao.getBooleanValue(SystemSettingsDao.HTTP_CLIENT_USE_PROXY));
    settings.put(SystemSettingsDao.HTTP_CLIENT_PROXY_SERVER, SystemSettingsDao.getValue(SystemSettingsDao.HTTP_CLIENT_PROXY_SERVER));
    settings.put(SystemSettingsDao.HTTP_CLIENT_PROXY_PORT, SystemSettingsDao.getIntValue(SystemSettingsDao.HTTP_CLIENT_PROXY_PORT));
    settings.put(SystemSettingsDao.HTTP_CLIENT_PROXY_USERNAME, SystemSettingsDao.getValue(SystemSettingsDao.HTTP_CLIENT_PROXY_USERNAME));
    settings.put(SystemSettingsDao.HTTP_CLIENT_PROXY_PASSWORD, SystemSettingsDao.getValue(SystemSettingsDao.HTTP_CLIENT_PROXY_PASSWORD));
    // Misc
    settings.put(SystemSettingsDao.POINT_DATA_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.POINT_DATA_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.POINT_DATA_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.POINT_DATA_PURGE_PERIODS));
    settings.put(DataPurge.ENABLE_POINT_DATA_PURGE, SystemSettingsDao.getBooleanValue(DataPurge.ENABLE_POINT_DATA_PURGE, true));
    settings.put(SystemSettingsDao.POINT_DATA_PURGE_COUNT, SystemSettingsDao.getBooleanValue(SystemSettingsDao.POINT_DATA_PURGE_COUNT));
    settings.put(SystemSettingsDao.DATA_POINT_EVENT_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.DATA_POINT_EVENT_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.DATA_POINT_EVENT_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.DATA_POINT_EVENT_PURGE_PERIODS));
    settings.put(SystemSettingsDao.DATA_SOURCE_EVENT_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.DATA_SOURCE_EVENT_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.DATA_SOURCE_EVENT_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.DATA_SOURCE_EVENT_PURGE_PERIODS));
    settings.put(SystemSettingsDao.SYSTEM_EVENT_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.SYSTEM_EVENT_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.SYSTEM_EVENT_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.SYSTEM_EVENT_PURGE_PERIODS));
    settings.put(SystemSettingsDao.PUBLISHER_EVENT_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.PUBLISHER_EVENT_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.PUBLISHER_EVENT_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.PUBLISHER_EVENT_PURGE_PERIODS));
    settings.put(SystemSettingsDao.AUDIT_EVENT_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.AUDIT_EVENT_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.AUDIT_EVENT_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.AUDIT_EVENT_PURGE_PERIODS));
    settings.put(SystemSettingsDao.NONE_ALARM_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.NONE_ALARM_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.NONE_ALARM_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.NONE_ALARM_PURGE_PERIODS));
    settings.put(SystemSettingsDao.INFORMATION_ALARM_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.INFORMATION_ALARM_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.INFORMATION_ALARM_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.INFORMATION_ALARM_PURGE_PERIODS));
    settings.put(SystemSettingsDao.IMPORTANT_ALARM_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.IMPORTANT_ALARM_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.IMPORTANT_ALARM_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.IMPORTANT_ALARM_PURGE_PERIODS));
    settings.put(SystemSettingsDao.WARNING_ALARM_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.WARNING_ALARM_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.WARNING_ALARM_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.WARNING_ALARM_PURGE_PERIODS));
    settings.put(SystemSettingsDao.URGENT_ALARM_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.URGENT_ALARM_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.URGENT_ALARM_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.URGENT_ALARM_PURGE_PERIODS));
    settings.put(SystemSettingsDao.CRITICAL_ALARM_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.CRITICAL_ALARM_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.CRITICAL_ALARM_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.CRITICAL_ALARM_PURGE_PERIODS));
    settings.put(SystemSettingsDao.LIFE_SAFETY_ALARM_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.LIFE_SAFETY_ALARM_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.LIFE_SAFETY_ALARM_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.LIFE_SAFETY_ALARM_PURGE_PERIODS));
    settings.put(SystemSettingsDao.EVENT_PURGE_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.EVENT_PURGE_PERIOD_TYPE));
    settings.put(SystemSettingsDao.EVENT_PURGE_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.EVENT_PURGE_PERIODS));
    settings.put(SystemSettingsDao.UI_PERFORMANCE, SystemSettingsDao.getIntValue(SystemSettingsDao.UI_PERFORMANCE));
    settings.put(SystemSettingsDao.FUTURE_DATE_LIMIT_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.FUTURE_DATE_LIMIT_PERIOD_TYPE));
    settings.put(SystemSettingsDao.FUTURE_DATE_LIMIT_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.FUTURE_DATE_LIMIT_PERIODS));
    // Language
    settings.put(SystemSettingsDao.LANGUAGE, SystemSettingsDao.getValue(SystemSettingsDao.LANGUAGE));
    // Colours
    settings.put(SystemSettingsDao.CHART_BACKGROUND_COLOUR, SystemSettingsDao.getValue(SystemSettingsDao.CHART_BACKGROUND_COLOUR));
    settings.put(SystemSettingsDao.PLOT_BACKGROUND_COLOUR, SystemSettingsDao.getValue(SystemSettingsDao.PLOT_BACKGROUND_COLOUR));
    settings.put(SystemSettingsDao.PLOT_GRIDLINE_COLOUR, SystemSettingsDao.getValue(SystemSettingsDao.PLOT_GRIDLINE_COLOUR));
    // Backup Settings
    settings.put(SystemSettingsDao.BACKUP_FILE_LOCATION, SystemSettingsDao.getValue(SystemSettingsDao.BACKUP_FILE_LOCATION));
    settings.put(SystemSettingsDao.BACKUP_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.BACKUP_PERIOD_TYPE));
    settings.put(SystemSettingsDao.BACKUP_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.BACKUP_PERIODS));
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("MMM-dd-yyyy HH:mm:ss");
        String lastRunString = SystemSettingsDao.getValue(SystemSettingsDao.BACKUP_LAST_RUN_SUCCESS);
        if (lastRunString != null) {
            Date lastRunDate = BackupWorkItem.dateFormatter.parse(lastRunString);
            lastRunString = sdf.format(lastRunDate);
            settings.put(SystemSettingsDao.BACKUP_LAST_RUN_SUCCESS, lastRunString);
        } else {
            settings.put(SystemSettingsDao.BACKUP_LAST_RUN_SUCCESS, "unknown");
        }
    } catch (Exception e) {
        settings.put(SystemSettingsDao.BACKUP_LAST_RUN_SUCCESS, "unknown");
    }
    settings.put(SystemSettingsDao.BACKUP_HOUR, SystemSettingsDao.getIntValue(SystemSettingsDao.BACKUP_HOUR));
    settings.put(SystemSettingsDao.BACKUP_MINUTE, SystemSettingsDao.getIntValue(SystemSettingsDao.BACKUP_MINUTE));
    settings.put(SystemSettingsDao.BACKUP_FILE_COUNT, SystemSettingsDao.getIntValue(SystemSettingsDao.BACKUP_FILE_COUNT));
    // Have to have a default value due to the lack of use of DEFAULT_VALUES for bools
    settings.put(SystemSettingsDao.BACKUP_ENABLED, SystemSettingsDao.getBooleanValue(SystemSettingsDao.BACKUP_ENABLED));
    // Have to have a default value due to the lack of use of DEFAULT_VALUES for bools
    settings.put(SystemSettingsDao.ALLOW_ANONYMOUS_CHART_VIEW, SystemSettingsDao.getBooleanValue(SystemSettingsDao.ALLOW_ANONYMOUS_CHART_VIEW, false));
    // Database Backup Settings
    settings.put(SystemSettingsDao.DATABASE_BACKUP_FILE_LOCATION, SystemSettingsDao.getValue(SystemSettingsDao.DATABASE_BACKUP_FILE_LOCATION));
    settings.put(SystemSettingsDao.DATABASE_BACKUP_PERIOD_TYPE, SystemSettingsDao.getIntValue(SystemSettingsDao.DATABASE_BACKUP_PERIOD_TYPE));
    settings.put(SystemSettingsDao.DATABASE_BACKUP_PERIODS, SystemSettingsDao.getIntValue(SystemSettingsDao.DATABASE_BACKUP_PERIODS));
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("MMM-dd-yyyy HH:mm:ss");
        String lastRunString = SystemSettingsDao.getValue(SystemSettingsDao.DATABASE_BACKUP_LAST_RUN_SUCCESS);
        if (lastRunString != null) {
            Date lastRunDate = BackupWorkItem.dateFormatter.parse(lastRunString);
            lastRunString = sdf.format(lastRunDate);
            settings.put(SystemSettingsDao.DATABASE_BACKUP_LAST_RUN_SUCCESS, lastRunString);
        } else {
            settings.put(SystemSettingsDao.DATABASE_BACKUP_LAST_RUN_SUCCESS, "unknown");
        }
    } catch (Exception e) {
        settings.put(SystemSettingsDao.DATABASE_BACKUP_LAST_RUN_SUCCESS, "unknown");
    }
    settings.put(SystemSettingsDao.DATABASE_BACKUP_HOUR, SystemSettingsDao.getIntValue(SystemSettingsDao.DATABASE_BACKUP_HOUR));
    settings.put(SystemSettingsDao.DATABASE_BACKUP_MINUTE, SystemSettingsDao.getIntValue(SystemSettingsDao.DATABASE_BACKUP_MINUTE));
    settings.put(SystemSettingsDao.DATABASE_BACKUP_FILE_COUNT, SystemSettingsDao.getIntValue(SystemSettingsDao.DATABASE_BACKUP_FILE_COUNT));
    // Have to have a default value due to the lack of use of DEFAULT_VALUES for bools
    settings.put(SystemSettingsDao.DATABASE_BACKUP_ENABLED, SystemSettingsDao.getBooleanValue(SystemSettingsDao.DATABASE_BACKUP_ENABLED));
    // Permissions
    settings.put(SystemSettingsDao.PERMISSION_DATASOURCE, SystemSettingsDao.getValue(SystemSettingsDao.PERMISSION_DATASOURCE, ""));
    List<Map<String, String>> modulePermissions = new ArrayList<>();
    settings.put("modulePermissions", modulePermissions);
    for (PermissionDefinition def : ModuleRegistry.getDefinitions(PermissionDefinition.class)) {
        if (!def.getPermissionTypeName().equals(SuperadminPermissionDefinition.PERMISSION)) {
            Map<String, String> permission = new HashMap<>();
            permission.put("name", def.getPermissionTypeName());
            permission.put("label", Translations.getTranslations(Common.getLocale()).translate(def.getPermissionKey()));
            permission.put("value", SystemSettingsDao.getValue(def.getPermissionTypeName()));
            modulePermissions.add(permission);
        }
    }
    // Thread Pool Settings
    settings.put(SystemSettingsDao.HIGH_PRI_CORE_POOL_SIZE, SystemSettingsDao.getIntValue(SystemSettingsDao.HIGH_PRI_CORE_POOL_SIZE));
    settings.put(SystemSettingsDao.HIGH_PRI_MAX_POOL_SIZE, SystemSettingsDao.getIntValue(SystemSettingsDao.HIGH_PRI_MAX_POOL_SIZE));
    settings.put(SystemSettingsDao.MED_PRI_CORE_POOL_SIZE, SystemSettingsDao.getIntValue(SystemSettingsDao.MED_PRI_CORE_POOL_SIZE));
    settings.put(SystemSettingsDao.LOW_PRI_CORE_POOL_SIZE, SystemSettingsDao.getIntValue(SystemSettingsDao.LOW_PRI_CORE_POOL_SIZE));
    // Virtual Serial Ports
    settings.put("virtualSerialPorts", VirtualSerialPortConfigDao.instance.getAll());
    // Site analytics
    settings.put(SystemSettingsDao.SITE_ANALYTICS_HEAD, SystemSettingsDao.getValue(SystemSettingsDao.SITE_ANALYTICS_HEAD));
    settings.put(SystemSettingsDao.SITE_ANALYTICS_BODY, SystemSettingsDao.getValue(SystemSettingsDao.SITE_ANALYTICS_BODY));
    // Upgrade states
    settings.put(SystemSettingsDao.UPGRADE_VERSION_STATE, SystemSettingsDao.getIntValue(SystemSettingsDao.UPGRADE_VERSION_STATE));
    // Point Hierarchy
    settings.put(SystemSettingsDao.EXPORT_HIERARCHY_PATH, SystemSettingsDao.getBooleanValue(SystemSettingsDao.EXPORT_HIERARCHY_PATH));
    settings.put(SystemSettingsDao.HIERARCHY_PATH_SEPARATOR, SystemSettingsDao.getValue(SystemSettingsDao.HIERARCHY_PATH_SEPARATOR));
    return settings;
}
Also used : SuperadminPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.SuperadminPermissionDefinition) PermissionDefinition(com.serotonin.m2m2.module.PermissionDefinition) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date) InvalidArgumentException(com.serotonin.InvalidArgumentException) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

PermissionDefinition (com.serotonin.m2m2.module.PermissionDefinition)4 SuperadminPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.SuperadminPermissionDefinition)3 HashMap (java.util.HashMap)3 ArrayList (java.util.ArrayList)2 InvalidArgumentException (com.serotonin.InvalidArgumentException)1 ConfigurationBackupActionPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.ConfigurationBackupActionPermissionDefinition)1 CoreFileStoreReadPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.CoreFileStoreReadPermissionDefinition)1 CoreFileStoreWritePermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.CoreFileStoreWritePermissionDefinition)1 DocsFileStoreReadPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.DocsFileStoreReadPermissionDefinition)1 DocsFileStoreWritePermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.DocsFileStoreWritePermissionDefinition)1 EventsViewPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.EventsViewPermissionDefinition)1 LegacyPointDetailsViewPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.LegacyPointDetailsViewPermissionDefinition)1 PublicFileStoreWritePermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.PublicFileStoreWritePermissionDefinition)1 PurgeAllEventsActionPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.PurgeAllEventsActionPermissionDefinition)1 PurgeAllPointValuesActionPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.PurgeAllPointValuesActionPermissionDefinition)1 PurgeWithPurgeSettingsActionPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.PurgeWithPurgeSettingsActionPermissionDefinition)1 SqlBackupActionPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.SqlBackupActionPermissionDefinition)1 SqlRestoreActionPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.SqlRestoreActionPermissionDefinition)1 UsersViewPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.UsersViewPermissionDefinition)1 User (com.serotonin.m2m2.vo.User)1