use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestIntegrationObjectWrapperFactory method test800EditSchemaJackPropReadAllModifySomeUser.
/**
* MID-3126
*/
@Test
public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception {
final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
cleanupAutzTest(USER_JACK_OID);
assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_OID);
login(USER_JACK_USERNAME);
ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
PrismObject<UserType> user = getUser(USER_JACK_OID);
display("user before", user);
// WHEN
TestUtil.displayWhen(TEST_NAME);
Task task = taskManager.createTaskInstance(TEST_NAME);
ObjectWrapper<UserType> objectWrapper = factory.createObjectWrapper("user display name", "user description", user, ContainerStatus.MODIFYING, task);
// THEN
TestUtil.displayThen(TEST_NAME);
IntegrationTestTools.display("Wrapper after", objectWrapper);
assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean) objectWrapper.isReadonly());
ContainerWrapper<UserType> mainContainerWrapper = objectWrapper.findMainContainerWrapper();
assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) mainContainerWrapper.isReadonly());
ItemWrapper nameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_NAME);
// Is this OK?
assertEquals("Wrong name readOnly", Boolean.TRUE, (Boolean) nameWrapper.isReadonly());
assertEquals("Wrong name visible", Boolean.TRUE, (Boolean) nameWrapper.isVisible());
assertEquals("Wrong name definition.canRead", Boolean.TRUE, (Boolean) nameWrapper.getItemDefinition().canRead());
assertEquals("Wrong name definition.canAdd", Boolean.FALSE, (Boolean) nameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong name definition.canModify", Boolean.FALSE, (Boolean) nameWrapper.getItemDefinition().canModify());
ItemWrapper givenNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_GIVEN_NAME);
// Is this OK?
assertEquals("Wrong givenName readOnly", Boolean.TRUE, (Boolean) givenNameWrapper.isReadonly());
assertEquals("Wrong givenName visible", Boolean.TRUE, (Boolean) givenNameWrapper.isVisible());
assertEquals("Wrong givenName definition.canRead", Boolean.TRUE, (Boolean) givenNameWrapper.getItemDefinition().canRead());
assertEquals("Wrong givenName definition.canAdd", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong givenName definition.canModify", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canModify());
ItemWrapper fullNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_FULL_NAME);
assertEquals("Wrong fullName readOnly", Boolean.FALSE, (Boolean) fullNameWrapper.isReadonly());
assertEquals("Wrong fullName visible", Boolean.TRUE, (Boolean) fullNameWrapper.isVisible());
assertEquals("Wrong fullName definition.canRead", Boolean.TRUE, (Boolean) fullNameWrapper.getItemDefinition().canRead());
assertEquals("Wrong fullName definition.canAdd", Boolean.FALSE, (Boolean) fullNameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong fullName definition.canModify", Boolean.TRUE, (Boolean) fullNameWrapper.getItemDefinition().canModify());
ItemWrapper additionalNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_ADDITIONAL_NAME);
// Is this OK?
assertEquals("Wrong additionalName readOnly", Boolean.TRUE, (Boolean) additionalNameWrapper.isReadonly());
// not visible, because it is empty
assertEquals("Wrong additionalName visible", Boolean.FALSE, (Boolean) additionalNameWrapper.isVisible());
assertEquals("Wrong additionalName definition.canRead", Boolean.TRUE, (Boolean) additionalNameWrapper.getItemDefinition().canRead());
assertEquals("Wrong additionalName definition.canAdd", Boolean.FALSE, (Boolean) additionalNameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong additionalName definition.canModify", Boolean.FALSE, (Boolean) additionalNameWrapper.getItemDefinition().canModify());
ItemWrapper localityNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_LOCALITY);
assertEquals("Wrong locality readOnly", Boolean.TRUE, (Boolean) localityNameWrapper.isReadonly());
assertEquals("Wrong locality visible", Boolean.TRUE, (Boolean) localityNameWrapper.isVisible());
assertEquals("Wrong locality definition.canRead", Boolean.TRUE, (Boolean) localityNameWrapper.getItemDefinition().canRead());
assertEquals("Wrong locality definition.canAdd", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canAdd());
assertEquals("Wrong locality definition.canModify", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canModify());
// WHEN
objectWrapper.setShowEmpty(true);
// THEN
additionalNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_ADDITIONAL_NAME);
// not visible, because it is empty
assertEquals("Wrong additionalName visible", Boolean.TRUE, (Boolean) additionalNameWrapper.isVisible());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class PageSelfRegistration method createCredentials.
private void createCredentials(UserType user, NonceCredentialsPolicyType noncePolicy, Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
NonceType nonceType = createNonce(noncePolicy, task, result);
// PasswordType password = createPassword();
CredentialsType credentials = user.getCredentials();
if (user.getCredentials() == null) {
credentials = new CredentialsType();
user.setCredentials(credentials);
}
credentials.setNonce(nonceType);
// credentials.setPassword(password);
// return credentials;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class AuditedLogoutHandler method auditEvent.
private void auditEvent(HttpServletRequest request, Authentication authentication) {
MidPointPrincipal principal = SecurityUtils.getPrincipalUser(authentication);
PrismObject<UserType> user = principal != null ? principal.getUser().asPrismObject() : null;
Task task = taskManager.createTaskInstance();
task.setOwner(user);
task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI);
AuditEventRecord record = new AuditEventRecord(AuditEventType.TERMINATE_SESSION, AuditEventStage.REQUEST);
record.setInitiator(user);
record.setParameter(WebComponentUtil.getName(user));
record.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI);
record.setTimestamp(System.currentTimeMillis());
record.setOutcome(OperationResultStatus.SUCCESS);
// probably not needed, as audit service would take care of it; but it doesn't hurt so let's keep it here
record.setHostIdentifier(request.getLocalName());
record.setRemoteHostAddress(request.getLocalAddr());
record.setNodeIdentifier(taskManager.getNodeId());
record.setSessionIdentifier(request.getRequestedSessionId());
auditService.audit(record, task);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestSchemaDelta method testSubtractAssignmentFromModifyDelta.
@Test
public void testSubtractAssignmentFromModifyDelta() throws Exception {
final String TEST_NAME = "testSubtractAssignmentFromModifyDelta";
displayTestTile(TEST_NAME);
// GIVEN
PrismObject<UserType> user = PrismTestUtil.parseObject(USER_BILL_FILE);
user.asObjectable().getAssignment().get(0).setId(9999L);
AssignmentType assignment9999 = new AssignmentType();
assignment9999.setId(9999L);
ObjectDelta<UserType> delta = (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, getPrismContext()).item(UserType.F_ASSIGNMENT).delete(assignment9999).asObjectDelta(user.getOid());
// WHEN
PrismContainerDefinition<AssignmentType> assignmentDef = PrismTestUtil.getSchemaRegistry().findContainerDefinitionByCompileTimeClass(AssignmentType.class).clone();
((PrismContainerDefinitionImpl) assignmentDef).setMaxOccurs(1);
PrismContainer<AssignmentType> assignmentContainer = assignmentDef.instantiate();
PrismContainerValue<AssignmentType> assignmentValue = ObjectTypeUtil.createAssignmentTo("00000001-d34d-b33f-f00d-000000000002", ObjectTypes.ROLE, getPrismContext()).asPrismContainerValue();
assignmentValue.setId(9999L);
assignmentContainer.add(assignmentValue);
System.out.println("Delta before operation:\n" + delta.debugDump() + "\n");
System.out.println("Assignment to subtract:\n" + assignmentValue.debugDump() + "\n");
boolean removed = delta.subtract(SchemaConstants.PATH_ASSIGNMENT, assignmentValue, true, false);
// THEN
System.out.println("Delta after operation:\n" + delta.debugDump() + "\n");
System.out.println("Removed: " + removed + "\n");
assertTrue("Not removed", removed);
assertTrue("Remaining delta is not a MODIFY delta", delta.isModify());
assertEquals("Wrong # of remaining modifications", 0, delta.getModifications().size());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class FocusTypeUtil method getPasswordValue.
public static ProtectedStringType getPasswordValue(UserType user) {
if (user == null) {
return null;
}
CredentialsType creds = user.getCredentials();
if (creds == null) {
return null;
}
PasswordType passwd = creds.getPassword();
if (passwd == null) {
return null;
}
return passwd.getValue();
}
Aggregations