use of org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator in project carbon-business-process by wso2.
the class TransformerUtils method transformTaskAuthorization.
/**
* Creates the TTaskAuthorisationParams object based on the authorisations the caller has on the
* given task
*
* @param task : The TaskDAO object for the authorisations to be checked.
* @param callerName : The caller user name.
* @return : The TTaskAuthorisationParams object containing the authorisation parameters as
* boolean flags.
*/
public static TTaskAuthorisationParams transformTaskAuthorization(TaskDAO task, String callerName) {
PeopleQueryEvaluator pqe = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getPeopleQueryEvaluator();
OrganizationalEntityDAO caller = pqe.createUserOrgEntityForName(callerName);
TTaskAuthorisationParams authParams = new TTaskAuthorisationParams();
if (TaskType.TASK.equals(task.getType())) {
authParams.setAuthorisedToActivate(OperationAuthorizationUtil.authorisedToActivate(task, caller, pqe));
authParams.setAuthorisedToClaim(OperationAuthorizationUtil.authorisedToClaim(task, caller, pqe));
authParams.setAuthorisedToComment(OperationAuthorizationUtil.authorisedToComment(task, caller, pqe));
authParams.setAuthorisedToComplete(OperationAuthorizationUtil.authorisedToComplete(task, caller, pqe));
authParams.setAuthorisedToDelegate(OperationAuthorizationUtil.authorisedToDelegate(task, caller, pqe));
authParams.setAuthorisedToDeleteFault(OperationAuthorizationUtil.authorisedToDeleteFault(task, caller, pqe));
authParams.setAuthorisedToDeleteComment(OperationAuthorizationUtil.authorisedToDeleteComment(task, caller, pqe));
authParams.setAuthorisedToDeleteOutput(OperationAuthorizationUtil.authorisedToDeleteOutput(task, caller, pqe));
authParams.setAuthorisedToExit(OperationAuthorizationUtil.authorisedToExit(task, caller, pqe));
authParams.setAuthorisedToFail(OperationAuthorizationUtil.authorisedToFail(task, caller, pqe));
authParams.setAuthorisedToForward(OperationAuthorizationUtil.authorisedToForward(task, caller, pqe));
authParams.setAuthorisedToGetComments(OperationAuthorizationUtil.authorisedToGetComments(task, caller, pqe));
authParams.setAuthorisedToGetDescription(OperationAuthorizationUtil.authorisedToGetDescription(task, caller, pqe));
authParams.setAuthorisedToGetInput(OperationAuthorizationUtil.authorisedToGetInput(task, caller, pqe));
authParams.setAuthorisedToNominate(OperationAuthorizationUtil.authorisedToNominate(task, caller, pqe));
authParams.setAuthorisedToRelease(OperationAuthorizationUtil.authorisedToRelease(task, caller, pqe));
authParams.setAuthorisedToResume(OperationAuthorizationUtil.authorisedToResume(task, caller, pqe));
authParams.setAuthorisedToRemove(OperationAuthorizationUtil.authorisedToRemove(task, caller, pqe));
authParams.setAuthorisedToSetFault(OperationAuthorizationUtil.authorisedToSetFault(task, caller, pqe));
authParams.setAuthorisedToSetOutput(OperationAuthorizationUtil.authorisedToSetOutput(task, caller, pqe));
authParams.setAuthorisedToSetPriority(OperationAuthorizationUtil.authorisedToSetPriority(task, caller, pqe));
authParams.setAuthorisedToSkip(OperationAuthorizationUtil.authorisedToSkip(task, caller, pqe));
authParams.setAuthorisedToStart(OperationAuthorizationUtil.authorisedToStart(task, caller, pqe));
authParams.setAuthorisedToStop(OperationAuthorizationUtil.authorisedToStop(task, caller, pqe));
authParams.setAuthorisedToSuspend(OperationAuthorizationUtil.authorisedToSuspend(task, caller, pqe));
authParams.setAuthorisedToUpdateComment(OperationAuthorizationUtil.authorisedToUpdateComment(task, caller, pqe));
} else if (TaskType.NOTIFICATION.equals(task.getType())) {
authParams.setAuthorisedToGetDescription(OperationAuthorizationUtil.authorisedToGetDescription(task, caller, pqe));
authParams.setAuthorisedToRemove(OperationAuthorizationUtil.authorisedToRemove(task, caller, pqe));
}
return authParams;
}
use of org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator in project carbon-business-process by wso2.
the class HumanTaskServer method initPeopleQueryEvaluator.
/**
* @throws HumanTaskServerException :
*/
private void initPeopleQueryEvaluator() throws HumanTaskServerException {
try {
PeopleQueryEvaluator peopleQueryEvaluator = (PeopleQueryEvaluator) Class.forName(serverConfig.getPeopleQueryEvaluatorClass()).newInstance();
taskEngine.setPeopleQueryEvaluator(peopleQueryEvaluator);
} catch (Exception ex) {
String errMsg = "Error instantiating the PeopleQueryEvaluator Class :" + serverConfig.getPeopleQueryEvaluatorClass();
throw new HumanTaskServerException(errMsg, ex);
}
}
use of org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator in project carbon-business-process by wso2.
the class TaskOperationsImpl method getCaller.
private String getCaller() {
// TODO - remove hard coded user name value once moved to task view page.
String userName = "admin";
PeopleQueryEvaluator pqe = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getPeopleQueryEvaluator();
if (StringUtils.isNotEmpty(pqe.getLoggedInUser())) {
userName = pqe.getLoggedInUser();
}
// logged in user.
if (StringUtils.isEmpty(userName)) {
throw new HumanTaskRuntimeException("Cannot determine the user name of the user " + "performing the task operation!");
}
return userName;
}
use of org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator in project carbon-business-process by wso2.
the class TaskOperationsImpl method authoriseToLoadTask.
/**
* Throws an exception if the current user is not allowed to perform loadTask() operation
* @param taskId
*/
private void authoriseToLoadTask(TaskDAO task) throws Exception {
List<GenericHumanRoleDAO.GenericHumanRoleType> allowedRoles = new ArrayList<GenericHumanRoleDAO.GenericHumanRoleType>();
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.ACTUAL_OWNER);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.NOTIFICATION_RECIPIENTS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.STAKEHOLDERS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.TASK_INITIATOR);
HumanTaskEngine taskEngine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
PeopleQueryEvaluator pqe = taskEngine.getPeopleQueryEvaluator();
OrganizationalEntityDAO invoker = taskEngine.getScheduler().execTransaction(new Callable<OrganizationalEntityDAO>() {
@Override
public OrganizationalEntityDAO call() throws Exception {
return HumanTaskServiceComponent.getHumanTaskServer().getDaoConnectionFactory().getConnection().createNewOrgEntityObject(getCaller(), OrganizationalEntityDAO.OrganizationalEntityType.USER);
}
});
if (!OperationAuthorizationUtil.authoriseUser(task, invoker, allowedRoles, pqe)) {
String errorMsg = String.format("The user[%s] cannot perform loadTask()" + " operation as either he is in EXCLUDED_OWNERS role or he is not in task roles [%s]", invoker.getName(), allowedRoles);
log.error(errorMsg);
throw new HumanTaskIllegalAccessException("Access Denied. You are not authorized to perform this task");
}
}
use of org.wso2.carbon.humantask.core.engine.PeopleQueryEvaluator in project carbon-business-process by wso2.
the class LiteralBasedOrgEntityProvider method getOrganizationalEntities.
public List<OrganizationalEntityDAO> getOrganizationalEntities(PeopleQueryEvaluator peopleQueryEvaluator, TFrom tFrom, EvaluationContext evaluationContext) {
TLiteral literal = tFrom.getLiteral();
List<OrganizationalEntityDAO> orgEntityList = new ArrayList<OrganizationalEntityDAO>();
Element domNode = (Element) literal.getDomNode();
if (domNode != null) {
NodeList orgEntityNodes = domNode.getElementsByTagNameNS(HumanTaskConstants.organizationalEntityQname.getNamespaceURI(), HumanTaskConstants.organizationalEntityQname.getLocalPart());
// There should be only one organizational Entity
if (orgEntityNodes.getLength() == 1) {
Node orgEntityNode = orgEntityNodes.item(0);
addOrgEntitiesForOrganizationEntityNode(orgEntityNode, peopleQueryEvaluator, orgEntityList);
} else {
NodeList elements = domNode.getElementsByTagNameNS(HumanTaskConstants.userQname.getNamespaceURI(), HumanTaskConstants.userQname.getLocalPart());
if (elements.getLength() == 1) {
// There should only be one user element
CommonTaskUtil.addOrgEntityForUserNode(elements.item(0), peopleQueryEvaluator, orgEntityList);
}
}
}
return orgEntityList;
}
Aggregations