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;
}
}
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);
}
}
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;
}
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;
}
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);
}
}
Aggregations