Search in sources :

Example 41 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class ConfigurationITCase method read.

@Test
public void read() {
    AttrTO conf = configurationService.get("token.expireTime");
    assertNotNull(conf);
}
Also used : AttrTO(org.apache.syncope.common.lib.to.AttrTO) Test(org.junit.jupiter.api.Test)

Example 42 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class SCIMConfManager method get.

@PreAuthorize("hasRole('" + SCIMEntitlement.SCIM_CONF_GET + "')")
public SCIMConf get() {
    AttrTO confTO = null;
    try {
        confTO = configurationLogic.get(SCIMConf.KEY);
    } catch (Exception e) {
        LOG.error("{} not found, reverting to default", SCIMConf.KEY);
    }
    SCIMConf conf = null;
    if (confTO != null) {
        try {
            conf = POJOHelper.deserialize(new String(Base64.decode(confTO.getValues().get(0))), SCIMConf.class);
        } catch (Exception e) {
            LOG.error("Could not deserialize, reverting to default", e);
        }
    }
    if (conf == null) {
        conf = new SCIMConf();
        set(conf);
    }
    return conf;
}
Also used : AttrTO(org.apache.syncope.common.lib.to.AttrTO) SCIMConf(org.apache.syncope.common.lib.scim.SCIMConf) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 43 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class TestPullActions method beforeProvision.

@Override
public void beforeProvision(final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final EntityTO entity) throws JobExecutionException {
    if (entity instanceof AnyTO) {
        AnyTO any = (AnyTO) entity;
        Optional<AttrTO> attrTO = any.getPlainAttr("fullname");
        if (!attrTO.isPresent()) {
            attrTO = Optional.of(new AttrTO());
            attrTO.get().setSchema("fullname");
            any.getPlainAttrs().add(attrTO.get());
        }
        attrTO.get().getValues().clear();
        attrTO.get().getValues().add(String.valueOf(counter++));
    }
}
Also used : AnyTO(org.apache.syncope.common.lib.to.AnyTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO)

Example 44 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class TestPullActions method beforeUpdate.

@Override
public <M extends AnyPatch> void beforeUpdate(final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final EntityTO entityTO, final M anyPatch) throws JobExecutionException {
    AttrPatch fullnamePatch = null;
    for (AttrPatch attrPatch : anyPatch.getPlainAttrs()) {
        if ("fullname".equals(attrPatch.getAttrTO().getSchema())) {
            fullnamePatch = attrPatch;
        }
    }
    if (fullnamePatch == null) {
        fullnamePatch = new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(new AttrTO.Builder().schema("fullname").build()).build();
    }
    fullnamePatch.getAttrTO().getValues().clear();
    fullnamePatch.getAttrTO().getValues().add(String.valueOf(counter++));
}
Also used : AttrTO(org.apache.syncope.common.lib.to.AttrTO) AttrPatch(org.apache.syncope.common.lib.patch.AttrPatch)

Example 45 with AttrTO

use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.

the class NotificationTaskITCase method notifyByMailWithRetry.

@Test
public void notifyByMailWithRetry() throws Exception {
    // 1. Set higher number of retries
    AttrTO origMaxRetries = configurationService.get("notification.maxRetries");
    configurationService.set(attrTO(origMaxRetries.getSchema(), "10"));
    // 2. Stop mail server to force errors while sending out e-mails
    stopGreenMail();
    try {
        // 3. create notification and user
        String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
        String subject = "Test notification " + getUUIDString();
        Pair<String, String> created = createNotificationTask(true, true, TraceLevel.ALL, sender, subject);
        NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
        assertNotNull(taskTO);
        assertNotNull(taskTO.getNotification());
        int preExecs = taskTO.getExecutions().size();
        // 4. verify notification could not be delivered
        execTask(taskService, TaskType.NOTIFICATION, taskTO.getKey(), NotificationJob.Status.NOT_SENT.name(), 5, false);
        taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
        assertNotNull(taskTO);
        assertFalse(taskTO.isExecuted());
        assertTrue(preExecs <= taskTO.getExecutions().size());
        for (ExecTO exec : taskTO.getExecutions()) {
            assertEquals(NotificationJob.Status.NOT_SENT.name(), exec.getStatus());
        }
    } finally {
        // start mail server again
        startGreenMail();
        // reset number of retries
        configurationService.set(origMaxRetries);
    }
}
Also used : ExecTO(org.apache.syncope.common.lib.to.ExecTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) NotificationTaskTO(org.apache.syncope.common.lib.to.NotificationTaskTO) Test(org.junit.jupiter.api.Test)

Aggregations

AttrTO (org.apache.syncope.common.lib.to.AttrTO)70 Test (org.junit.jupiter.api.Test)31 UserTO (org.apache.syncope.common.lib.to.UserTO)30 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)19 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)17 Map (java.util.Map)15 GroupTO (org.apache.syncope.common.lib.to.GroupTO)15 ArrayList (java.util.ArrayList)14 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)14 List (java.util.List)13 Collections (java.util.Collections)11 StringUtils (org.apache.commons.lang3.StringUtils)11 AnyTO (org.apache.syncope.common.lib.to.AnyTO)10 Optional (java.util.Optional)9 Set (java.util.Set)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 HashMap (java.util.HashMap)8 Collectors (java.util.stream.Collectors)8 EntityTOUtils (org.apache.syncope.common.lib.EntityTOUtils)8 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)8