Search in sources :

Example 46 with UserType

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());
}
Also used : ItemWrapper(com.evolveum.midpoint.web.component.prism.ItemWrapper) Task(com.evolveum.midpoint.task.api.Task) ObjectWrapperFactory(com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 47 with UserType

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;
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) NonceType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType)

Example 48 with UserType

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 49 with UserType

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());
}
Also used : AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 50 with UserType

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();
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType)

Aggregations

UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)903 Test (org.testng.annotations.Test)767 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)741 Task (com.evolveum.midpoint.task.api.Task)576 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)217 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)192 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)104 PrismObject (com.evolveum.midpoint.prism.PrismObject)100 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)99 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)88 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)85 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)84 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)83 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)77 ArrayList (java.util.ArrayList)74 QName (javax.xml.namespace.QName)74 File (java.io.File)72 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)58 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)55 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)55