本文整理了Java中com.evolveum.midpoint.task.api.Task.setOwner()
方法的一些代码示例,展示了Task.setOwner()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.setOwner()
方法的具体详情如下:
包路径:com.evolveum.midpoint.task.api.Task
类名称:Task
方法名:setOwner
[英]Sets the task owner. BEWARE: sets the owner only for in-memory information. So do not call this method for persistent tasks! (until fixed)
[中]设置任务所有者。注意:仅为内存中的信息设置所有者。所以不要为持久性任务调用此方法!(直到修复)
代码示例来源:origin: Evolveum/midpoint
protected void setTaskOwner(Task task) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
throw new SystemException("Failed to get authentication object");
}
UserType userType = ((MidPointPrincipal)(SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getUser();
if (userType == null) {
throw new SystemException("Failed to get user from authentication object");
}
task.setOwner(userType.asPrismObject());
}
代码示例来源:origin: Evolveum/midpoint
protected Task createTask(String operationName) {
Task task = super.createTask(operationName);
PrismObject<UserType> defaultActor = getDefaultActor();
if (defaultActor != null) {
task.setOwner(defaultActor);
}
task.setChannel(DEFAULT_CHANNEL);
return task;
}
代码示例来源:origin: Evolveum/midpoint
protected Task createTask(String operationName, MidPointPrincipal principal) {
Task task = super.createTask(operationName);
task.setOwner(principal.getUser().asPrismObject());
task.setChannel(DEFAULT_CHANNEL);
return task;
}
代码示例来源:origin: Evolveum/midpoint
protected <O extends ObjectType> void assertAllow(String opname, Attempt attempt) throws Exception {
Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertAllow."+opname);
task.setOwner(getSecurityContextPrincipalUser());
task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI);
OperationResult result = task.getResult();
try {
logAttempt(opname);
attempt.run(task, result);
} catch (SecurityViolationException e) {
failAllow(opname, e);
}
result.computeStatus();
TestUtil.assertSuccess(result);
logAllow(opname);
}
代码示例来源:origin: Evolveum/midpoint
protected <O extends ObjectType> void assertDeny(String opname, Attempt attempt) throws Exception {
Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertDeny."+opname);
task.setOwner(getSecurityContextPrincipalUser());
task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI);
OperationResult result = task.getResult();
try {
logAttempt(opname);
attempt.run(task, result);
failDeny(opname);
} catch (SecurityViolationException e) {
// this is expected
logDeny(opname);
result.computeStatus();
TestUtil.assertFailure(result);
}
}
代码示例来源:origin: Evolveum/midpoint
protected <O extends ObjectType> void asAdministrator(Attempt attempt) throws Exception {
Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".asAdministrator");
OperationResult result = task.getResult();
MidPointPrincipal origPrincipal = getSecurityContextPrincipal();
login(USER_ADMINISTRATOR_USERNAME);
task.setOwner(getSecurityContextPrincipalUser());
task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI);
try {
attempt.run(task, result);
} catch (Throwable e) {
login(origPrincipal);
throw e;
}
login(origPrincipal);
result.computeStatus();
TestUtil.assertSuccess(result);
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test200StartRemediationDeny() throws Exception {
final String TEST_NAME = "test200StartRemediationDeny";
TestUtil.displayTestTitle(this, TEST_NAME);
login(getUserFromRepo(USER_ELAINE_OID));
// GIVEN
Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN+THEN
TestUtil.displayWhen(TEST_NAME);
try {
certificationService.startRemediation(campaignOid, task, result);
} catch (SecurityViolationException e) {
System.out.println("Got expected deny exception: " + e.getMessage());
}
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test499CheckAfterClose() throws Exception {
final String TEST_NAME = "test920CheckAfterClose";
TestUtil.displayTestTitle(this, TEST_NAME);
login(userAdministrator.asPrismObject());
// GIVEN
Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN
waitForCampaignTasks(campaignOid, 20000, result);
// THEN
userAdministrator = getUser(USER_ADMINISTRATOR_OID).asObjectable();
display("administrator", userAdministrator);
AssignmentType assignment = findAssignmentByTargetRequired(userAdministrator.asPrismObject(), ROLE_COO_OID);
assertCertificationMetadata(assignment.getMetadata(), SchemaConstants.MODEL_CERTIFICATION_OUTCOME_ACCEPT,
new HashSet<>(asList(USER_ADMINISTRATOR_OID, USER_ELAINE_OID, USER_CHEESE_OID)), singleton("administrator: ok"));
}
代码示例来源:origin: Evolveum/midpoint
@Test(enabled = true)
public void test061UserModifyAddRoleAutoSkip() throws Exception {
final String TEST_NAME = "test061UserModifyAddRoleAutoSkip";
TestUtil.displayTestTitle(this, TEST_NAME);
login(userAdministrator);
Task task = taskManager.createTaskInstance(TestUserChangeApprovalLegacy.class.getName() + "."+TEST_NAME);
task.setOwner(userAdministrator);
OperationResult result = task.getResult();
// WHEN
assignRole(USER_JACK_OID, ROLE_R10_SKIP_OID, task, result);
// THEN
PrismObject<UserType> jack = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
assertAssignedRole(jack, ROLE_R10_OID, task, result);
result.computeStatusIfUnknown();
assertSuccess(result);
}
代码示例来源:origin: Evolveum/midpoint
protected void deleteUserFromModel(String name) throws SchemaException, ObjectNotFoundException, CommunicationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
OperationResult result = new OperationResult("dummy");
Task t = taskManager.createTaskInstance();
t.setOwner(repositoryService.getObject(UserType.class, USER_ADMINISTRATOR_OID, null, result));
if (!findUserInRepoUnchecked(name, result).isEmpty()) {
PrismObject<UserType> user = findUserInRepo(name, result);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
deltas.add(prismContext.deltaFactory().object().createDeleteDelta(UserType.class, user.getOid()));
modelService.executeChanges(deltas, new ModelExecuteOptions(), t, result);
LOGGER.info("User " + name + " was deleted");
} else {
LOGGER.info("User {} was not found", name);
}
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test320CheckAfterClose() throws Exception {
final String TEST_NAME = "test320CheckAfterClose";
TestUtil.displayTestTitle(this, TEST_NAME);
login(userAdministrator.asPrismObject());
// GIVEN
Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN
waitForCampaignTasks(campaignOid, 20000, result);
// THEN
roleCoo = getRole(ROLE_COO_OID).asObjectable();
display("COO", roleCoo);
AssignmentType inducement = findInducementByTarget(ROLE_COO_OID, ROLE_SUPERUSER_OID);
assertCertificationMetadata(inducement.getMetadata(), SchemaConstants.MODEL_CERTIFICATION_OUTCOME_ACCEPT, singleton(USER_ADMINISTRATOR_OID), singleton("administrator: I'm so procrastinative..."));
}
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test210CheckAfterClose() throws Exception {
final String TEST_NAME = "test210CheckAfterClose";
TestUtil.displayTestTitle(this, TEST_NAME);
login(userAdministrator.asPrismObject());
// GIVEN
Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN
waitForCampaignTasks(campaignOid, 20000, result);
// THEN
userAdministrator = getUser(USER_ADMINISTRATOR_OID).asObjectable();
display("administrator", userAdministrator);
AssignmentType assignment = findAssignmentByTargetRequired(userAdministrator.asPrismObject(), ROLE_SUPERUSER_OID);
assertCertificationMetadata(assignment.getMetadata(), SchemaConstants.MODEL_CERTIFICATION_OUTCOME_ACCEPT, singleton(USER_ADMINISTRATOR_OID), singleton("administrator: no comment"));
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test030AttemptToActivateCorrectRoleC34() throws Exception {
final String TEST_NAME = "test030AttemptToActivateCorrectRoleC34";
TestUtil.displayTestTitle(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN+THEN
TestUtil.displayWhen(TEST_NAME);
TestUtil.displayThen(TEST_NAME);
Holder<LensContext<?>> contextHolder = new Holder<>();
activateRoleAssertFailure(roleCorrectOid, contextHolder, result, task);
PrismObject<RoleType> role = getRole(roleCorrectOid);
display("role after", role);
dumpRules(contextHolder);
assertEquals("Wrong policy situation", singletonList(SITUATION_INCOMPLETE_ROLE), role.asObjectable().getPolicySituation());
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test020AttemptToActivateIncompleteRoleC234() throws Exception {
final String TEST_NAME = "test020AttemptToActivateIncompleteRoleC234";
TestUtil.displayTestTitle(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN+THEN
TestUtil.displayWhen(TEST_NAME);
TestUtil.displayThen(TEST_NAME);
Holder<LensContext<?>> contextHolder = new Holder<>();
activateRoleAssertFailure(roleHighRiskEmptyOid, contextHolder, result, task);
PrismObject<RoleType> role = getRole(roleHighRiskEmptyOid);
display("role after", role);
dumpRules(contextHolder);
assertEquals("Wrong policy situation", singletonList(SITUATION_INCOMPLETE_ROLE), role.asObjectable().getPolicySituation());
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test010AttemptToActivateIncompleteRoleC1345() throws Exception {
final String TEST_NAME = "test010AttemptToActivateIncompleteRoleC1345";
TestUtil.displayTestTitle(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN+THEN
TestUtil.displayWhen(TEST_NAME);
TestUtil.displayThen(TEST_NAME);
Holder<LensContext<?>> contextHolder = new Holder<>();
activateRoleAssertFailure(roleEmptyOid, contextHolder, result, task);
PrismObject<RoleType> role = getRole(roleEmptyOid);
display("role after", role);
dumpRules(contextHolder);
assertEquals("Wrong policy situation", singletonList(SITUATION_INCOMPLETE_ROLE), role.asObjectable().getPolicySituation());
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test040AssignOwnerAndApproverToCorrectRole() throws Exception {
final String TEST_NAME = "test040AssignOwnerAndApproverToCorrectRole";
TestUtil.displayTestTitle(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN+THEN
TestUtil.displayWhen(TEST_NAME);
TestUtil.displayThen(TEST_NAME);
ModelExecuteOptions noApprovals = createPartialProcessing(new PartialProcessingOptionsType().approvals(SKIP));
assignRole(USER_ADMINISTRATOR_OID, roleCorrectOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result);
assignRole(USER_ADMINISTRATOR_OID, roleCorrectOid, SchemaConstants.ORG_OWNER, noApprovals, task, result);
// recompute the role to set correct policy situation
recomputeFocus(RoleType.class, roleCorrectOid, task, result);
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test900CleanupCampaignsDeny() throws Exception {
final String TEST_NAME = "test900CleanupCampaignsDeny";
TestUtil.displayTestTitle(this, TEST_NAME);
login(getUserFromRepo(USER_ELAINE_OID));
// GIVEN
Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN+THEN
TestUtil.displayWhen(TEST_NAME);
CleanupPolicyType policy = new CleanupPolicyType().maxRecords(0);
certificationService.cleanupCampaigns(policy, task, result);
display("result", result);
SearchResultList<PrismObject<AccessCertificationCampaignType>> campaigns = getAllCampaigns(result);
display("campaigns", campaigns);
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test060AssignOwnerAndApproverToCorrectHighRiskRole() throws Exception {
final String TEST_NAME = "test060AssignOwnerAndApproverToCorrectHighRiskRole";
TestUtil.displayTestTitle(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN+THEN
TestUtil.displayWhen(TEST_NAME);
TestUtil.displayThen(TEST_NAME);
ModelExecuteOptions noApprovals = createPartialProcessing(new PartialProcessingOptionsType().approvals(SKIP));
assignRole(USER_ADMINISTRATOR_OID, roleCorrectHighRiskOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result);
assignRole(userJackOid, roleCorrectHighRiskOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result);
assignRole(USER_ADMINISTRATOR_OID, roleCorrectHighRiskOid, SchemaConstants.ORG_OWNER, noApprovals, task, result);
// recompute the role to set correct policy situation
recomputeFocus(RoleType.class, roleCorrectHighRiskOid, task, result);
}
代码示例来源:origin: Evolveum/midpoint
public void launch(AccessCertificationCampaignType campaign, OperationResult parentResult) throws SchemaException, ObjectNotFoundException {
LOGGER.debug("Launching closing task handler for campaign {} as asynchronous task", toShortString(campaign));
OperationResult result = parentResult.createSubresult(CLASS_DOT + "launch");
result.addParam("campaignOid", campaign.getOid());
Task task = taskManager.createTaskInstance();
task.setHandlerUri(HANDLER_URI);
task.setName(new PolyStringType("Closing " + campaign.getName()));
task.setObjectRef(ObjectTypeUtil.createObjectRef(campaign, prismContext));
task.setOwner(repositoryService.getObject(UserType.class, SystemObjectsType.USER_ADMINISTRATOR.value(), null, result));
taskManager.switchToBackground(task, result);
result.setBackgroundTaskOid(task.getOid());
if (result.isInProgress()) {
result.recordStatus(OperationResultStatus.IN_PROGRESS, "Closing task "+task+" was successfully started, please use Server Tasks to see its status.");
}
LOGGER.trace("Closing task for {} switched to background, control thread returning with task {}", toShortString(campaign), task);
}
代码示例来源:origin: Evolveum/midpoint
@Test
public void test710JackAssignRoleEmpty() throws Exception {
final String TEST_NAME = "test710JackAssignRoleEmpty";
displayTestTitle(TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
Task task = createTask(TEST_NAME);
task.setOwner(getUser(USER_ADMINISTRATOR_OID));
OperationResult result = task.getResult();
PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User jack before", userBefore);
// WHEN
displayWhen(TEST_NAME);
assignRole(USER_JACK_OID, ROLE_EMPTY_OID, getDefaultOptions(), task, result);
// THEN
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result);
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}
内容来源于网络,如有侵权,请联系作者删除!