Search in sources :

Example 11 with XXServiceConfigMap

use of org.apache.ranger.entity.XXServiceConfigMap in project ranger by apache.

the class ServiceDBStore method isServiceAdminUser.

public boolean isServiceAdminUser(String serviceName, String userName) {
    boolean ret = false;
    XXServiceConfigMap cfgSvcAdminUsers = daoMgr.getXXServiceConfigMap().findByServiceNameAndConfigKey(serviceName, SERVICE_ADMIN_USERS);
    String svcAdminUsers = cfgSvcAdminUsers != null ? cfgSvcAdminUsers.getConfigvalue() : null;
    if (svcAdminUsers != null) {
        for (String svcAdminUser : svcAdminUsers.split(",")) {
            if (userName.equals(svcAdminUser)) {
                ret = true;
                break;
            }
        }
    }
    return ret;
}
Also used : XXServiceConfigMap(org.apache.ranger.entity.XXServiceConfigMap) VXString(org.apache.ranger.view.VXString)

Example 12 with XXServiceConfigMap

use of org.apache.ranger.entity.XXServiceConfigMap in project ranger by apache.

the class ServiceDBStore method deleteService.

@Override
public void deleteService(Long id) throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceDBStore.deleteService(" + id + ")");
    }
    RangerService service = getService(id);
    if (service == null) {
        throw new Exception("no service exists with ID=" + id);
    }
    // Manage zone
    // RANGER-3016
    disassociateZonesForService(service);
    List<Long> policyIds = daoMgr.getXXPolicy().findPolicyIdsByServiceId(service.getId());
    if (CollectionUtils.isNotEmpty(policyIds)) {
        long totalDeletedPolicies = 0;
        for (Long policyID : policyIds) {
            RangerPolicy rangerPolicy = getPolicy(policyID);
            deletePolicy(rangerPolicy, service);
            totalDeletedPolicies = totalDeletedPolicies + 1;
            // its a bulk policy delete call flush and clear
            if (totalDeletedPolicies % RangerBizUtil.policyBatchSize == 0) {
                bizUtil.bulkModeOnlyFlushAndClear();
            }
        }
        bizUtil.bulkModeOnlyFlushAndClear();
    }
    XXServiceConfigMapDao configDao = daoMgr.getXXServiceConfigMap();
    List<XXServiceConfigMap> configs = configDao.findByServiceId(service.getId());
    for (XXServiceConfigMap configMap : configs) {
        configDao.remove(configMap);
    }
    // Purge x_rms data
    daoMgr.getXXRMSServiceResource().purge(service.getId());
    Long version = service.getVersion();
    if (version == null) {
        version = Long.valueOf(1);
        LOG.info("Found Version Value: `null`, so setting value of version to 1, While updating object, version should not be null.");
    } else {
        version = Long.valueOf(version.longValue() + 1);
    }
    service.setVersion(version);
    svcService.delete(service);
    dataHistService.createObjectDataHistory(service, RangerDataHistService.ACTION_DELETE);
    List<XXTrxLog> trxLogList = svcService.getTransactionLog(service, RangerServiceService.OPERATION_DELETE_CONTEXT);
    bizUtil.createTrxLog(trxLogList);
}
Also used : XXServiceConfigMap(org.apache.ranger.entity.XXServiceConfigMap) RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) RangerService(org.apache.ranger.plugin.model.RangerService) XXTrxLog(org.apache.ranger.entity.XXTrxLog) XXServiceConfigMapDao(org.apache.ranger.db.XXServiceConfigMapDao) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) JSONException(org.codehaus.jettison.json.JSONException)

Example 13 with XXServiceConfigMap

use of org.apache.ranger.entity.XXServiceConfigMap in project ranger by apache.

the class ServiceDBStore method hasServiceConfigForPluginChanged.

boolean hasServiceConfigForPluginChanged(List<XXServiceConfigMap> dbConfigMaps, Map<String, String> validConfigs) {
    boolean ret = false;
    Map<String, String> configs = new HashMap<String, String>();
    if (CollectionUtils.isNotEmpty(dbConfigMaps)) {
        for (XXServiceConfigMap dbConfigMap : dbConfigMaps) {
            if (StringUtils.startsWith(dbConfigMap.getConfigkey(), RANGER_PLUGIN_CONFIG_PREFIX)) {
                configs.put(dbConfigMap.getConfigkey(), dbConfigMap.getConfigvalue());
            }
        }
    }
    if (MapUtils.isNotEmpty(validConfigs)) {
        for (String key : validConfigs.keySet()) {
            if (StringUtils.startsWith(key, RANGER_PLUGIN_CONFIG_PREFIX)) {
                if (!StringUtils.equals(configs.get(key), validConfigs.get(key))) {
                    return true;
                } else {
                    configs.remove(key);
                }
            }
        }
    }
    if (configs.size() > 0) {
        return true;
    }
    return ret;
}
Also used : XXServiceConfigMap(org.apache.ranger.entity.XXServiceConfigMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) VXString(org.apache.ranger.view.VXString)

Example 14 with XXServiceConfigMap

use of org.apache.ranger.entity.XXServiceConfigMap in project ranger by apache.

the class KmsKeyMgr method getKMSPassword.

private String getKMSPassword(String srvName) throws Exception {
    XXService rangerService = rangerDaoManagerBase.getXXService().findByName(srvName);
    XXServiceConfigMap xxConfigMap = rangerDaoManagerBase.getXXServiceConfigMap().findByServiceAndConfigKey(rangerService.getId(), KMS_PASSWORD);
    String encryptedPwd = xxConfigMap.getConfigvalue();
    String pwd = PasswordUtils.decryptPassword(encryptedPwd);
    return pwd;
}
Also used : XXServiceConfigMap(org.apache.ranger.entity.XXServiceConfigMap) XXService(org.apache.ranger.entity.XXService)

Example 15 with XXServiceConfigMap

use of org.apache.ranger.entity.XXServiceConfigMap in project ranger by apache.

the class PatchForAtlasToAddEntityLabelAndBusinessMetadata_J10034 method getDefaultPolicyUsers.

private List<String> getDefaultPolicyUsers(XXService xxService) {
    XXPortalUser xxServiceCreator = daoMgr.getXXPortalUser().getById(xxService.getAddedByUserId());
    XXServiceConfigMap cfgMap = daoMgr.getXXServiceConfigMap().findByServiceNameAndConfigKey(xxService.getName(), "username");
    XXPortalUser xxServiceCfgUser = daoMgr.getXXPortalUser().findByLoginId(cfgMap.getConfigvalue());
    List<String> users = new ArrayList<String>();
    if (xxServiceCreator != null) {
        users.add(xxServiceCreator.getLoginId());
    }
    if (xxServiceCfgUser != null) {
        users.add(xxServiceCfgUser.getLoginId());
    }
    return users;
}
Also used : XXServiceConfigMap(org.apache.ranger.entity.XXServiceConfigMap) XXPortalUser(org.apache.ranger.entity.XXPortalUser) ArrayList(java.util.ArrayList)

Aggregations

XXServiceConfigMap (org.apache.ranger.entity.XXServiceConfigMap)18 RangerService (org.apache.ranger.plugin.model.RangerService)9 XXServiceConfigMapDao (org.apache.ranger.db.XXServiceConfigMapDao)8 XXService (org.apache.ranger.entity.XXService)7 VXString (org.apache.ranger.view.VXString)6 ArrayList (java.util.ArrayList)5 Date (java.util.Date)4 HashMap (java.util.HashMap)4 XXPortalUser (org.apache.ranger.entity.XXPortalUser)4 Test (org.junit.Test)4 XXPortalUserDao (org.apache.ranger.db.XXPortalUserDao)3 XXServiceDefDao (org.apache.ranger.db.XXServiceDefDao)3 XXServiceVersionInfoDao (org.apache.ranger.db.XXServiceVersionInfoDao)3 XXServiceDef (org.apache.ranger.entity.XXServiceDef)3 XXServiceVersionInfo (org.apache.ranger.entity.XXServiceVersionInfo)3 XXTrxLog (org.apache.ranger.entity.XXTrxLog)3 LinkedHashMap (java.util.LinkedHashMap)2 UserSessionBase (org.apache.ranger.common.UserSessionBase)2 XXUser (org.apache.ranger.entity.XXUser)2 PasswordUtils (org.apache.ranger.plugin.util.PasswordUtils)2