Search in sources :

Example 31 with SystemConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.

the class UserProfileServiceMock method createPrincipal.

private MidPointPrincipal createPrincipal(PrismObject<UserType> user, OperationResult result) {
    if (user == null) {
        return null;
    }
    PrismObject<SystemConfigurationType> systemConfiguration = null;
    try {
        systemConfiguration = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result);
    } catch (ObjectNotFoundException | SchemaException e) {
        LOGGER.warn("No system configuration: {}", e.getMessage(), e);
    }
    MidPointPrincipal principal = new MidPointPrincipal(user.asObjectable());
    initializePrincipalFromAssignments(principal, systemConfiguration);
    return principal;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 32 with SystemConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.

the class UserProfileServiceMock method initializePrincipalFromAssignments.

private void initializePrincipalFromAssignments(MidPointPrincipal principal, PrismObject<SystemConfigurationType> systemConfiguration) {
    OperationResult result = new OperationResult(UserProfileServiceMock.class.getName() + ".addAuthorizations");
    principal.setApplicableSecurityPolicy(locateSecurityPolicy(principal, systemConfiguration, result));
    if (systemConfiguration != null) {
        principal.setAdminGuiConfiguration(systemConfiguration.asObjectable().getAdminGuiConfiguration());
    }
    AuthorizationType authorizationType = new AuthorizationType();
    authorizationType.getAction().add("FAKE");
    principal.getAuthorities().add(new Authorization(authorizationType));
    ActivationType activation = principal.getUser().getActivation();
    if (activation != null) {
        activationComputer.computeEffective(principal.getUser().getLifecycleState(), activation);
    }
}
Also used : Authorization(com.evolveum.midpoint.security.api.Authorization) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AuthorizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType)

Example 33 with SystemConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.

the class TestLdapComplex method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    modelService.postInit(initResult);
    // System Configuration
    PrismObject<SystemConfigurationType> config;
    try {
        config = repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
    } catch (ObjectAlreadyExistsException e) {
        throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
    }
    LoggingConfigurationManager.configure(ProfilingConfigurationManager.checkSystemProfilingConfiguration(config), config.asObjectable().getVersion(), initResult);
    // administrator
    PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
    repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
    login(userAdministrator);
    // Roles
    repoAddObjectFromFile(ROLE_CAPTAIN_FILE, initResult);
    repoAddObjectFromFile(ROLE_JUDGE_FILE, initResult);
    repoAddObjectFromFile(ROLE_PIRATE_FILE, initResult);
    repoAddObjectFromFile(ROLE_SAILOR_FILE, initResult);
    // templates
    repoAddObjectFromFile(USER_TEMPLATE_FILE, initResult);
    // Resources
    resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult);
    resourceOpenDjType = resourceOpenDj.asObjectable();
    openDJController.setResource(resourceOpenDj);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    openDJController.addEntriesFromLdifFile(ROLES_LDIF_FILE.getPath());
    display("initial LDAP content", openDJController.dumpEntries());
}
Also used : SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 34 with SystemConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.

the class TestLdapUniversity method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    modelService.postInit(initResult);
    // System Configuration
    PrismObject<SystemConfigurationType> config;
    try {
        config = repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
    } catch (ObjectAlreadyExistsException e) {
        throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
    }
    LoggingConfigurationManager.configure(ProfilingConfigurationManager.checkSystemProfilingConfiguration(config), config.asObjectable().getVersion(), initResult);
    // administrator
    PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
    repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
    login(userAdministrator);
    // Resources
    resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult);
    resourceOpenDjType = resourceOpenDj.asObjectable();
    openDJController.setResource(resourceOpenDj);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    display("initial LDAP content", openDJController.dumpEntries());
}
Also used : SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 35 with SystemConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.

the class AbstractLdapTest method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    // System Configuration
    PrismObject<SystemConfigurationType> config;
    try {
        config = repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
    } catch (ObjectAlreadyExistsException e) {
        throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
    }
    modelService.postInit(initResult);
    // to get profiling facilities (until better API is available)
    //        LoggingConfigurationManager.configure(
    //                ProfilingConfigurationManager.checkSystemProfilingConfiguration(config),
    //                config.asObjectable().getVersion(), initResult);
    // administrator
    PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
    repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
    login(userAdministrator);
    // Resources
    if (isImportResourceAtInit()) {
        resource = importAndGetObjectFromFile(ResourceType.class, getResourceFile(), getResourceOid(), initTask, initResult);
        resourceType = resource.asObjectable();
    }
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    //initProfiling - start
    ProfilingDataManager profilingManager = ProfilingDataManager.getInstance();
    Map<ProfilingDataManager.Subsystem, Boolean> subsystems = new HashMap<>();
    subsystems.put(ProfilingDataManager.Subsystem.MODEL, true);
    subsystems.put(ProfilingDataManager.Subsystem.REPOSITORY, true);
    profilingManager.configureProfilingDataManagerForTest(subsystems, true);
    profilingManager.appendProfilingToTest();
    //initProfiling - end
    ciMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING);
    dnMatchingRule = matchingRuleRegistry.getMatchingRule(DistinguishedNameMatchingRule.NAME, DOMUtil.XSD_STRING);
    logTrustManagers();
    if (isAssertOpenFiles()) {
        lsof = new Lsof(TestUtil.getPid());
    }
}
Also used : ProfilingDataManager(com.evolveum.midpoint.util.aspect.ProfilingDataManager) HashMap(java.util.HashMap) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Lsof(com.evolveum.midpoint.test.util.Lsof) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Aggregations

SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)40 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 Task (com.evolveum.midpoint.task.api.Task)14 Test (org.testng.annotations.Test)12 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)11 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)10 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)10 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)9 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)8 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)8 LoggingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)8 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)8 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)7 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)6 ObjectPolicyConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType)6 ValuePolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)6 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4