use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method loginSuperUser.
protected void loginSuperUser(String principalName) throws SchemaException, ObjectNotFoundException {
MidPointPrincipal principal = userProfileService.getPrincipal(principalName);
loginSuperUser(principal);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method setSecurityContextUser.
protected void setSecurityContextUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
Task task = taskManager.createTaskInstance("get administrator");
PrismObject<UserType> object = modelService.getObject(UserType.class, userOid, null, task, task.getResult());
assertNotNull("User " + userOid + " is null", object.asObjectable());
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(new MidPointPrincipal(object.asObjectable()), null));
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestValidityRecomputeTask method test135BarbossaEnableAssignmentSailor.
@Test
public void test135BarbossaEnableAssignmentSailor() throws Exception {
final String TEST_NAME = "test135BarbossaEnableAssignmentSailor";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_SAILOR_OID);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true);
// WHEN
TestUtil.displayWhen(TEST_NAME);
assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true);
assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, ROLE_JUDGE_TITLE);
assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, RESOURCE_DUMMY_DRINK, ROLE_JUDGE_DRINK, ROLE_SAILOR_DRINK);
PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
display("User after", user);
assertLinks(user, 1);
MidPointPrincipal principal = userProfileService.getPrincipal(user);
assertAuthorized(principal, AUTZ_PUNISH_URL);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestValidityRecomputeTask method test134BarbossaEnableAssignmentJudge.
@Test
public void test134BarbossaEnableAssignmentJudge() throws Exception {
final String TEST_NAME = "test134BarbossaEnableAssignmentJudge";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true);
// WHEN
TestUtil.displayWhen(TEST_NAME);
assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true);
assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, ROLE_JUDGE_TITLE);
assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, RESOURCE_DUMMY_DRINK, ROLE_JUDGE_DRINK);
PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
display("User after", user);
assertLinks(user, 1);
MidPointPrincipal principal = userProfileService.getPrincipal(user);
assertAuthorized(principal, AUTZ_PUNISH_URL);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class AbstractModelWebService method setTaskOwner.
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());
}
Aggregations