Search in sources :

Example 1 with RegistryService

use of org.wso2.carbon.registry.api.RegistryService in project core-util by WSO2Telco.

the class BasicAuthenticator method isAuthenticatedUser.

public boolean isAuthenticatedUser(String userName, String password) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class, null);
    RegistryService registryService = (RegistryService) carbonContext.getOSGiService(RegistryService.class, null);
    String tenantDomain = MultitenantUtils.getTenantDomain(userName);
    try {
        UserRealm userRealm = null;
        userRealm = AnonymousSessionUtil.getRealmByTenantDomain(registryService, realmService, tenantDomain);
        if (userRealm == null) {
            log.error("invalid domain or unactivated tenant login");
            return false;
        }
        String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(userName);
        if (userRealm.getUserStoreManager().authenticate(tenantAwareUsername, password)) {
            return true;
        } else {
            log.error("authentication failed. please check your username/password");
            return false;
        }
    } catch (CarbonException | UserStoreException e) {
        log.error("authentication failed for user : " + userName, e);
        return false;
    }
}
Also used : UserRealm(org.wso2.carbon.user.core.UserRealm) RealmService(org.wso2.carbon.user.core.service.RealmService) CarbonException(org.wso2.carbon.CarbonException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) RegistryService(org.wso2.carbon.registry.core.service.RegistryService)

Example 2 with RegistryService

use of org.wso2.carbon.registry.api.RegistryService in project carbon-business-process by wso2.

the class BPMNDataPublisher method getKPIConfiguration.

/**
 * Get DAS config details of given certain process which are configured for analytics from the config registry
 *
 * @param processDefinitionId Process definition ID
 * @return KPI configuration details in JSON format. Ex:<p>
 * {"processDefinitionId":"myProcess3:1:32518","eventStreamName":"t_666_process_stream","eventStreamVersion":"1.0.0"
 * ,"eventStreamDescription":"This is the event stream generated to configure process analytics with DAS, for the
 * processt_666","eventStreamNickName":"t_666_process_stream","eventStreamId":"t_666_process_stream:1.0.0",
 * "eventReceiverName":"t_666_process_receiver","pcProcessId":"t:666",
 * "processVariables":[{"name":"processInstanceId","type":"string","isAnalyzeData":"false",
 * "isDrillDownData":"false"}
 * ,{"name":"valuesAvailability","type":"string","isAnalyzeData":"false","isDrillDownData":"false"}
 * ,{"name":"custid","type":"string","isAnalyzeData":false,"isDrillDownData":false}
 * ,{"name":"amount","type":"long","isAnalyzeData":false,"isDrillDownData":false}
 * ,{"name":"confirm","type":"bool","isAnalyzeData":false,"isDrillDownData":false}]}
 * @throws RegistryException
 */
public JsonNode getKPIConfiguration(String processDefinitionId) throws RegistryException, IOException {
    String resourcePath = AnalyticsPublisherConstants.REG_PATH_BPMN_ANALYTICS + processDefinitionId + "/" + AnalyticsPublisherConstants.ANALYTICS_CONFIG_FILE_NAME;
    try {
        RegistryService registryService = BPMNAnalyticsHolder.getInstance().getRegistryService();
        Registry configRegistry = registryService.getConfigSystemRegistry();
        if (configRegistry.resourceExists(resourcePath)) {
            Resource processRegistryResource = configRegistry.get(resourcePath);
            String dasConfigDetailsJSONStr = new String((byte[]) processRegistryResource.getContent(), StandardCharsets.UTF_8);
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.readTree(dasConfigDetailsJSONStr);
        }
        return null;
    } catch (RegistryException e) {
        String errMsg = "Error in Getting DAS config details of given process definition id :" + processDefinitionId + " from the BPS Config registry-" + resourcePath;
        throw new RegistryException(errMsg, e);
    }
}
Also used : Resource(org.wso2.carbon.registry.api.Resource) Registry(org.wso2.carbon.registry.api.Registry) RegistryService(org.wso2.carbon.registry.core.service.RegistryService) RegistryException(org.wso2.carbon.registry.api.RegistryException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with RegistryService

use of org.wso2.carbon.registry.api.RegistryService in project carbon-business-process by wso2.

the class EndpointConfiguration method getEndpointElementFromRegistry.

private OMElement getEndpointElementFromRegistry(String uepConfPath) throws AxisFault {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    RegistryService registryService = BPELCommonServiceComponent.getRegistryService();
    Registry registry = null;
    OMElement uepOMContent = null;
    String location;
    try {
        if (uepConfPath.startsWith(UnifiedEndpointConstants.VIRTUAL_CONF_REG)) {
            registry = registryService.getConfigSystemRegistry(tenantId);
            location = uepConfPath.substring(uepConfPath.indexOf(UnifiedEndpointConstants.VIRTUAL_CONF_REG) + UnifiedEndpointConstants.VIRTUAL_CONF_REG.length());
            uepOMContent = loadUEPOMFromRegistry(registry, location);
        } else if (uepConfPath.startsWith(UnifiedEndpointConstants.VIRTUAL_GOV_REG)) {
            registry = registryService.getGovernanceSystemRegistry(tenantId);
            location = uepConfPath.substring(uepConfPath.indexOf(UnifiedEndpointConstants.VIRTUAL_GOV_REG) + UnifiedEndpointConstants.VIRTUAL_GOV_REG.length());
            uepOMContent = loadUEPOMFromRegistry(registry, location);
        } else if (uepConfPath.startsWith(UnifiedEndpointConstants.VIRTUAL_REG)) {
            registry = registryService.getLocalRepository(tenantId);
            location = uepConfPath.substring(uepConfPath.indexOf(UnifiedEndpointConstants.VIRTUAL_REG) + UnifiedEndpointConstants.VIRTUAL_REG.length());
            uepOMContent = loadUEPOMFromRegistry(registry, location);
        }
    } catch (RegistryException ex) {
        String error = "Error occurred while getting registry service" + ex.getLocalizedMessage();
        handleError(error);
    }
    return uepOMContent;
}
Also used : OMElement(org.apache.axiom.om.OMElement) Registry(org.wso2.carbon.registry.core.Registry) RegistryService(org.wso2.carbon.registry.core.service.RegistryService) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) UnifiedEndpoint(org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint)

Example 4 with RegistryService

use of org.wso2.carbon.registry.api.RegistryService in project carbon-business-process by wso2.

the class TaskOperationsImpl method getUserListForRole.

private TUser[] getUserListForRole(String roleName, int tenantId, String actualOwnerUserName) throws RegistryException, UserStoreException {
    TUser[] userList = new TUser[0];
    RegistryService registryService = HumanTaskServiceComponent.getRegistryService();
    if (registryService != null && registryService.getUserRealm(tenantId) != null) {
        UserRealm userRealm = registryService.getUserRealm(tenantId);
        String[] assignableUserNameList = userRealm.getUserStoreManager().getUserListOfRole(roleName);
        if (assignableUserNameList != null) {
            userList = new TUser[assignableUserNameList.length];
            for (int i = 0; i < assignableUserNameList.length; i++) {
                TUser user = new TUser();
                user.setTUser(assignableUserNameList[i]);
                if (StringUtils.isEmpty(actualOwnerUserName)) {
                    userList[i] = user;
                } else if (StringUtils.isNotEmpty(actualOwnerUserName) && !actualOwnerUserName.equals(assignableUserNameList[i])) {
                    userList[i] = user;
                }
            }
        }
    } else {
        log.warn("Cannot load User Realm for Tenant Id: " + tenantId);
    }
    return userList;
}
Also used : UserRealm(org.wso2.carbon.user.core.UserRealm) RegistryService(org.wso2.carbon.registry.core.service.RegistryService)

Example 5 with RegistryService

use of org.wso2.carbon.registry.api.RegistryService in project carbon-business-process by wso2.

the class BPMNDeploymentService method getLatestChecksum.

/**
 * Get the checksum of latest deployment for given deployment name
 *
 * @param deploymentName
 * @return
 * @throws BPSFault
 */
public String getLatestChecksum(String deploymentName) throws BPSFault {
    try {
        Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        RegistryService registryService = BPMNServerHolder.getInstance().getRegistryService();
        Registry tenantRegistry = registryService.getConfigSystemRegistry(tenantId);
        String deploymentRegistryPath = BPMNConstants.BPMN_REGISTRY_PATH + BPMNConstants.REGISTRY_PATH_SEPARATOR + deploymentName;
        if (tenantRegistry.resourceExists(deploymentRegistryPath)) {
            Resource deploymentEntry = tenantRegistry.get(deploymentRegistryPath);
            return deploymentEntry.getProperty(BPMNConstants.LATEST_CHECKSUM_PROPERTY);
        } else {
            return null;
        }
    } catch (RegistryException e) {
        String msg = "Error while accessing registry to get latest checksum for package : " + deploymentName;
        throw new BPSFault(msg, e);
    }
}
Also used : BPSFault(org.wso2.carbon.bpmn.core.BPSFault) Resource(org.wso2.carbon.registry.api.Resource) Registry(org.wso2.carbon.registry.api.Registry) RegistryService(org.wso2.carbon.registry.api.RegistryService) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Aggregations

RegistryService (org.wso2.carbon.registry.core.service.RegistryService)8 RegistryException (org.wso2.carbon.registry.api.RegistryException)6 Registry (org.wso2.carbon.registry.api.Registry)5 RegistryService (org.wso2.carbon.registry.api.RegistryService)4 File (java.io.File)3 ProcessEngine (org.activiti.engine.ProcessEngine)3 RepositoryService (org.activiti.engine.RepositoryService)3 BPSFault (org.wso2.carbon.bpmn.core.BPSFault)3 Resource (org.wso2.carbon.registry.api.Resource)3 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)3 UserRealm (org.wso2.carbon.user.core.UserRealm)3 UserStoreException (org.wso2.carbon.user.core.UserStoreException)3 Deployment (org.activiti.engine.repository.Deployment)2 CarbonException (org.wso2.carbon.CarbonException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ZipInputStream (java.util.zip.ZipInputStream)1