org.apache.syncope.common.lib.request.UserCR - java examples

Here are the examples of the java api org.apache.syncope.common.lib.request.UserCR taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

82 Examples 7

19 View Complete Implementation : CamelUserProvisioningManager.java
Copyright Apache License 2.0
Author : apache
@Override
public Pair<String, List<PropagationStatus>> create(final UserCR req, final boolean nullPriorityAsync) {
    return create(req, false, null, Set.of(), nullPriorityAsync);
}

19 View Complete Implementation : AbstractUserWorkflowAdapter.java
Copyright Apache License 2.0
Author : apache
@Override
public UserWorkflowResult<Pair<String, Boolean>> create(final UserCR userCR) {
    return create(userCR, false, null);
}

19 View Complete Implementation : AbstractUserWorkflowAdapter.java
Copyright Apache License 2.0
Author : apache
protected abstract UserWorkflowResult<Pair<String, Boolean>> doCreate(UserCR userCR, boolean disablePwdPolicyCheck, Boolean enabled);

19 View Complete Implementation : AbstractUserWorkflowAdapter.java
Copyright Apache License 2.0
Author : apache
@Override
public UserWorkflowResult<Pair<String, Boolean>> create(final UserCR userCR, final boolean disablePwdPolicyCheck, final Boolean enabled) {
    return doCreate(userCR, disablePwdPolicyCheck, enabled);
}

18 View Complete Implementation : UserLogic.java
Copyright Apache License 2.0
Author : apache
@PreAuthorize("hasRole('" + IdRepoEnreplacedlement.USER_CREATE + "')")
public ProvisioningResult<UserTO> create(final UserCR createReq, final boolean nullPriorityAsync) {
    return doCreate(createReq, false, nullPriorityAsync);
}

18 View Complete Implementation : UserLogic.java
Copyright Apache License 2.0
Author : apache
@PreAuthorize("isAnonymous() or hasRole('" + IdRepoEnreplacedlement.ANONYMOUS + "')")
public ProvisioningResult<UserTO> selfCreate(final UserCR createReq, final boolean nullPriorityAsync) {
    return doCreate(createReq, true, nullPriorityAsync);
}

18 View Complete Implementation : UserServiceImpl.java
Copyright Apache License 2.0
Author : apache
@Override
public Response create(final UserCR createReq) {
    ProvisioningResult<UserTO> created = logic.create(createReq, isNullPriorityAsync());
    return createResponse(created);
}

17 View Complete Implementation : UserRestClient.java
Copyright Apache License 2.0
Author : apache
public static ProvisioningResult<UserTO> create(final UserCR createReq) {
    Response response = getService(UserService.clreplaced).create(createReq);
    return response.readEnreplacedy(new GenericType<ProvisioningResult<UserTO>>() {
    });
}

17 View Complete Implementation : UserSelfRestClient.java
Copyright Apache License 2.0
Author : apache
public static ProvisioningResult<UserTO> create(final UserCR createReq) {
    Response response = getService(UserSelfService.clreplaced).create(createReq);
    return response.readEnreplacedy(new GenericType<ProvisioningResult<UserTO>>() {
    });
}

17 View Complete Implementation : DefaultUserProvisioningManager.java
Copyright Apache License 2.0
Author : apache
@Override
public Pair<String, List<PropagationStatus>> create(final UserCR userCR, final boolean nullPriorityAsync) {
    return create(userCR, false, null, Set.of(), nullPriorityAsync);
}

17 View Complete Implementation : Create.java
Copyright Apache License 2.0
Author : apache
@Override
protected void doExecute(final DelegateExecution execution) {
    UserCR userCR = execution.getVariable(FlowableRuntimeUtils.USER_CR, UserCR.clreplaced);
    // create user
    User user = enreplacedyFactory.newEnreplacedy(User.clreplaced);
    dataBinder.create(user, userCR);
    // report user as result
    execution.setVariable(FlowableRuntimeUtils.USER, user);
    execution.setVariable(FlowableRuntimeUtils.USER_TO, dataBinder.getUserTO(user, true));
}

17 View Complete Implementation : SCIMDataBinder.java
Copyright Apache License 2.0
Author : apache
public UserCR toUserCR(final SCIMUser user) {
    UserTO userTO = toUserTO(user);
    UserCR userCR = new UserCR();
    EnreplacedyTOUtils.toAnyCR(userTO, userCR);
    return userCR;
}

15 View Complete Implementation : AbstractITCase.java
Copyright Apache License 2.0
Author : apache
protected ProvisioningResult<UserTO> createUser(final UserCR req) {
    Response response = userService.create(req);
    if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
        Exception ex = clientFactory.getExceptionMapper().fromResponse(response);
        if (ex != null) {
            throw (RuntimeException) ex;
        }
    }
    return response.readEnreplacedy(new GenericType<ProvisioningResult<UserTO>>() {
    });
}

14 View Complete Implementation : VirAttrITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issueSYNCOPE459() {
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getResources().clear();
    userCR.getResources().add(RESOURCE_NAME_LDAP);
    userCR.getMemberships().clear();
    userCR.getVirAttrs().clear();
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO.getVirAttr("virtualReadOnly"));
}

14 View Complete Implementation : AuthenticationITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void checkFailedLogins() {
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getRoles().add("User manager");
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    String userKey = userTO.getKey();
    UserService userService2 = clientFactory.create(userTO.getUsername(), "preplacedword123").getService(UserService.clreplaced);
    replacedertEquals(0, getFailedLogins(userService2, userKey));
    // authentications failed ...
    try {
        clientFactory.create(userTO.getUsername(), "wrongpwd1");
        fail("This should not happen");
    } catch (AccessControlException e) {
        replacedertNotNull(e);
    }
    try {
        clientFactory.create(userTO.getUsername(), "wrongpwd1");
        fail("This should not happen");
    } catch (AccessControlException e) {
        replacedertNotNull(e);
    }
    replacedertEquals(2, getFailedLogins(userService, userKey));
    UserService userService4 = clientFactory.create(userTO.getUsername(), "preplacedword123").getService(UserService.clreplaced);
    replacedertEquals(0, getFailedLogins(userService4, userKey));
}

14 View Complete Implementation : VirAttrITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issueSYNCOPE436() {
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getMemberships().clear();
    userCR.getResources().clear();
    userCR.getResources().add(RESOURCE_NAME_LDAP);
    userCR.getVirAttrs().add(attr("virtualReadOnly", "readOnly"));
    UserTO userTO = createUser(userCR).getEnreplacedy();
    // finding no values because the virtual attribute is readonly
    replacedertTrue(userTO.getVirAttr("virtualReadOnly").get().getValues().isEmpty());
}

13 View Complete Implementation : DefaultUserWorkflowAdapter.java
Copyright Apache License 2.0
Author : apache
@Override
protected UserWorkflowResult<Pair<String, Boolean>> doCreate(final UserCR userCR, final boolean disablePwdPolicyCheck, final Boolean enabled) {
    User user = enreplacedyFactory.newEnreplacedy(User.clreplaced);
    dataBinder.create(user, userCR);
    // this will make UserValidator not to consider preplacedword policies at all
    if (disablePwdPolicyCheck) {
        user.removeClearPreplacedword();
    }
    String status;
    boolean propagateEnable;
    if (enabled == null) {
        status = "created";
        propagateEnable = true;
    } else {
        status = enabled ? "active" : "suspended";
        propagateEnable = enabled;
        user.setSuspended(!enabled);
    }
    user.setStatus(status);
    user = userDAO.save(user);
    PropagationByResource<String> propByRes = new PropagationByResource<>();
    propByRes.set(ResourceOperation.CREATE, userDAO.findAllResourceKeys(user.getKey()));
    PropagationByResource<Pair<String, String>> propByLinkedAccount = new PropagationByResource<>();
    user.getLinkedAccounts().forEach(account -> propByLinkedAccount.add(ResourceOperation.CREATE, Pair.of(account.getResource().getKey(), account.getConnObjectKeyValue())));
    return new UserWorkflowResult<>(Pair.of(user.getKey(), propagateEnable), propByRes, propByLinkedAccount, "create");
}

13 View Complete Implementation : AuthenticationITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void userRead() {
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getRoles().add("User manager");
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    UserService userService2 = clientFactory.create(userTO.getUsername(), "preplacedword123").getService(UserService.clreplaced);
    UserTO readUserTO = userService2.read("1417acbe-cbf6-4277-9372-e75e04f97000");
    replacedertNotNull(readUserTO);
    UserService userService3 = clientFactory.create("puccini", ADMIN_PWD).getService(UserService.clreplaced);
    try {
        userService3.read("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee");
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        replacedertNotNull(e);
        replacedertEquals(ClientExceptionType.DelegatedAdministration, e.getType());
    }
}

13 View Complete Implementation : ExceptionMapperITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void headersMultiValue() {
    UserCR userCR = new UserCR();
    userCR.setRealm(SyncopeConstants.ROOT_REALM);
    String userId = getUUIDString() + "[email protected]";
    userCR.setUsername(userId);
    userCR.setPreplacedword("preplacedword123");
    userCR.getPlainAttrs().add(attr("userId", "issue654"));
    userCR.getPlainAttrs().add(attr("fullname", userId));
    userCR.getPlainAttrs().add(attr("surname", userId));
    try {
        createUser(userCR);
        fail("This should not happen");
    } catch (SyncopeClientCompositeException e) {
        replacedertEquals(2, e.getExceptions().size());
    }
}

13 View Complete Implementation : JWTITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issueSYNCOPE1420() {
    Long orig = confParamOps.get(SyncopeConstants.MASTER_DOMAIN, "jwt.lifetime.minutes", null, Long.clreplaced);
    try {
        // set for immediate JWT expiration
        confParamOps.set(SyncopeConstants.MASTER_DOMAIN, "jwt.lifetime.minutes", 0);
        UserCR userCR = UserITCase.getUniqueSample("[email protected]");
        UserTO user = createUser(userCR).getEnreplacedy();
        replacedertNotNull(user);
        // login, get JWT with  expiryTime
        String jwt = clientFactory.create(user.getUsername(), "preplacedword123").getJWT();
        JwsJwtCompactConsumer consumer = new JwsJwtCompactConsumer(jwt);
        replacedertTrue(consumer.verifySignatureWith(jwsSignatureVerifier));
        Long expiryTime = consumer.getJwtClaims().getExpiryTime();
        replacedertNotNull(expiryTime);
        // wait for 1 sec, check that JWT is effectively expired
        try {
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
        // ignore
        }
        replacedertTrue(expiryTime < System.currentTimeMillis());
        // login again, get new JWT
        // (even if ExpiredAccessTokenCleanup did not run yet, as it is scheduled every 5 minutes)
        String newJWT = clientFactory.create(user.getUsername(), "preplacedword123").getJWT();
        replacedertNotEquals(jwt, newJWT);
    } finally {
        confParamOps.set(SyncopeConstants.MASTER_DOMAIN, "jwt.lifetime.minutes", orig);
    }
}

13 View Complete Implementation : MembershipITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void deleteUserWithMembership() {
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.setRealm("/even/two");
    userCR.getPlainAttrs().add(new Attr.Builder("aLong").value("1976").build());
    MembershipTO membership = new MembershipTO.Builder("034740a9-fa10-453b-af37-dc7897e98fb1").build();
    membership.getPlainAttrs().add(new Attr.Builder("aLong").value("1977").build());
    userCR.getMemberships().add(membership);
    UserTO user = createUser(userCR).getEnreplacedy();
    replacedertNotNull(user.getKey());
    userService.delete(user.getKey());
}

12 View Complete Implementation : UserSelfServiceImpl.java
Copyright Apache License 2.0
Author : apache
@Override
public Response create(final UserCR createReq) {
    if (!syncopeLogic.isSelfRegAllowed()) {
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.DelegatedAdministration);
        sce.getElements().add("Self registration forbidden by configuration");
        throw sce;
    }
    ProvisioningResult<UserTO> created = logic.selfCreate(createReq, isNullPriorityAsync());
    return createResponse(created);
}

12 View Complete Implementation : CamelUserProvisioningManager.java
Copyright Apache License 2.0
Author : apache
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> create(final UserCR req, final boolean disablePwdPolicyCheck, final Boolean enabled, final Set<String> excludedResources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:createPort");
    Map<String, Object> props = new HashMap<>();
    props.put("disablePwdPolicyCheck", disablePwdPolicyCheck);
    props.put("enabled", enabled);
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:createUser", req, props);
    Exchange exchange = pollingConsumer.receive();
    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }
    return exchange.getIn().getBody(Pair.clreplaced);
}

12 View Complete Implementation : MultitenancyITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void createUser() {
    replacedertNull(adminClient.getService(RealmService.clreplaced).list().get(0).getPreplacedwordPolicy());
    UserCR userCR = new UserCR();
    userCR.setRealm(SyncopeConstants.ROOT_REALM);
    userCR.setUsername(getUUIDString());
    userCR.setPreplacedword("preplacedword");
    Response response = adminClient.getService(UserService.clreplaced).create(userCR);
    replacedertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    UserTO user = response.readEnreplacedy(new GenericType<ProvisioningResult<UserTO>>() {
    }).getEnreplacedy();
    replacedertNotNull(user);
}

11 View Complete Implementation : SearchITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void searchBySecurityAnswer() {
    String securityAnswer = RandomStringUtils.randomAlphanumeric(10);
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.setSecurityQuestion("887028ea-66fc-41e7-b397-620d7ea6dfbb");
    userCR.setSecurityAnswer(securityAnswer);
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO.getSecurityQuestion());
    PagedResult<UserTO> matchingUsers = userService.search(new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).fiql(SyncopeClient.getUserSearchConditionBuilder().is("securityAnswer").equalTo(securityAnswer).query()).build());
    replacedertNotNull(matchingUsers);
    replacedertTrue(matchingUsers.getResult().isEmpty());
}

11 View Complete Implementation : UserSelfITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void preplacedwordResetWithoutSecurityQuestion() {
    // 0. disable security question for preplacedword reset
    confParamOps.set(SyncopeConstants.MASTER_DOMAIN, "preplacedwordReset.securityQuestion", false);
    // 1. create an user with security question and answer
    UserCR user = UserITCase.getUniqueSample("[email protected]");
    createUser(user);
    // 2. verify that new user is able to authenticate
    SyncopeClient authClient = clientFactory.create(user.getUsername(), "preplacedword123");
    UserTO read = authClient.self().getRight();
    replacedertNotNull(read);
    // 3. request preplacedword reset (as anonymous) with no security answer
    SyncopeClient anonClient = clientFactory.create();
    anonClient.getService(UserSelfService.clreplaced).requestPreplacedwordReset(user.getUsername(), null);
    // 4. get token (normally sent via e-mail, now reading as admin)
    String token = userService.read(read.getKey()).getToken();
    replacedertNotNull(token);
    // 5. confirm preplacedword reset
    try {
        anonClient.getService(UserSelfService.clreplaced).confirmPreplacedwordReset("WRONG TOKEN", "newPreplacedword");
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        replacedertEquals(ClientExceptionType.NotFound, e.getType());
        replacedertTrue(e.getMessage().contains("WRONG TOKEN"));
    }
    anonClient.getService(UserSelfService.clreplaced).confirmPreplacedwordReset(token, "newPreplacedword123");
    // 6. verify that preplacedword was reset and token removed
    authClient = clientFactory.create(user.getUsername(), "newPreplacedword123");
    read = authClient.self().getRight();
    replacedertNotNull(read);
    replacedertNull(read.getToken());
    // 7. re-enable security question for preplacedword reset
    confParamOps.set(SyncopeConstants.MASTER_DOMAIN, "preplacedwordReset.securityQuestion", true);
}

10 View Complete Implementation : VirAttrITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issueSYNCOPE16() {
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getVirAttrs().add(attr("virtualdata", "virtualvalue"));
    userCR.getResources().add(RESOURCE_NAME_DBVIRATTR);
    userCR.getMemberships().add(new MembershipTO.Builder("f779c0d4-633b-4be5-8f57-32eb478a3ca5").build());
    // 1. create user
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    // 2. check for virtual attribute value
    userTO = userService.read(userTO.getKey());
    replacedertNotNull(userTO);
    replacedertEquals("virtualvalue", userTO.getVirAttr("virtualdata").get().getValues().get(0));
    UserUR userUR = new UserUR();
    userUR.setKey(userTO.getKey());
    userUR.getVirAttrs().add(attr("virtualdata", "virtualupdated"));
    // 3. update virtual attribute
    userTO = updateUser(userUR).getEnreplacedy();
    replacedertNotNull(userTO);
    // 4. check for virtual attribute value
    userTO = userService.read(userTO.getKey());
    replacedertNotNull(userTO);
    replacedertEquals("virtualupdated", userTO.getVirAttr("virtualdata").get().getValues().get(0));
}

10 View Complete Implementation : VirAttrITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issueSYNCOPE501() {
    // 1. create user and propagate him on resource-db-virattr
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getResources().clear();
    userCR.getMemberships().clear();
    userCR.getVirAttrs().clear();
    userCR.getResources().add(RESOURCE_NAME_DBVIRATTR);
    // virtualdata is mapped with username
    userCR.getVirAttrs().add(attr("virtualdata", "[email protected]"));
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO.getVirAttr("virtualdata"));
    replacedertEquals("[email protected]", userTO.getVirAttr("virtualdata").get().getValues().get(0));
    // 2. update virtual attribute
    UserUR userUR = new UserUR();
    userUR.setKey(userTO.getKey());
    // change virtual attribute value
    userUR.getVirAttrs().add(attr("virtualdata", "[email protected]"));
    userTO = updateUser(userUR).getEnreplacedy();
    replacedertNotNull(userTO);
    // 3. check that user virtual attribute has really been updated
    replacedertFalse(userTO.getVirAttr("virtualdata").get().getValues().isEmpty());
    replacedertEquals("[email protected]", userTO.getVirAttr("virtualdata").get().getValues().get(0));
}

9 View Complete Implementation : DBPasswordPullActionsTest.java
Copyright Apache License 2.0
Author : apache
public clreplaced DBPreplacedwordPullActionsTest extends AbstractTest {

    @Mock
    private SyncDelta syncDelta;

    @Mock
    private ProvisioningProfile<?, ?> profile;

    @Mock
    private UserDAO userDAO;

    @Mock
    private ProvisioningReport result;

    @Mock
    private Connector connector;

    @InjectMocks
    private DBPreplacedwordPullActions dBPreplacedwordPullActions;

    @Mock
    private ConnInstance connInstance;

    private Set<ConnConfProperty> connConfProperties;

    private UserTO userTO;

    private UserCR userCR;

    private UserUR userUR;

    private String encodedPreplacedword;

    private CipherAlgorithm cipher;

    private ConnConfProperty connConfProperty;

    @BeforeEach
    public void initTest() {
        userTO = new UserTO();
        encodedPreplacedword = "s3cureP4ssw0rd";
        cipher = CipherAlgorithm.SHA512;
        ConnConfPropSchema connConfPropSchema = new ConnConfPropSchema();
        connConfPropSchema.setName("cipherAlgorithm");
        connConfProperty = new ConnConfProperty();
        connConfProperty.setSchema(connConfPropSchema);
        connConfProperties = new HashSet<>();
        connConfProperties.add(connConfProperty);
        ReflectionTestUtils.setField(dBPreplacedwordPullActions, "encodedPreplacedword", encodedPreplacedword);
        ReflectionTestUtils.setField(dBPreplacedwordPullActions, "cipher", cipher);
        lenient().when(profile.getConnector()).thenReturn(connector);
        lenient().when(connector.getConnInstance()).thenReturn(connInstance);
        lenient().when(connInstance.getConf()).thenReturn(connConfProperties);
    }

    @Test
    public void beforeProvision() throws JobExecutionException {
        String digest = "SHA256";
        String preplacedword = "t3stPreplacedw0rd";
        userCR = new UserCR.Builder(SyncopeConstants.ROOT_REALM, "user").preplacedword(preplacedword).build();
        connConfProperty.getValues().clear();
        connConfProperty.getValues().add(digest);
        dBPreplacedwordPullActions.beforeProvision(profile, syncDelta, userCR);
        replacedertEquals(CipherAlgorithm.valueOf(digest), ReflectionTestUtils.getField(dBPreplacedwordPullActions, "cipher"));
        replacedertEquals(preplacedword, ReflectionTestUtils.getField(dBPreplacedwordPullActions, "encodedPreplacedword"));
    }

    @Test
    public void beforeUpdate() throws JobExecutionException {
        userUR = new UserUR.Builder(null).preplacedword(new PreplacedwordPatch.Builder().value("an0therTestP4ss").build()).build();
        dBPreplacedwordPullActions.beforeUpdate(profile, syncDelta, userTO, userUR);
        replacedertEquals(cipher, ReflectionTestUtils.getField(dBPreplacedwordPullActions, "cipher"));
        replacedertEquals(encodedPreplacedword, ReflectionTestUtils.getField(dBPreplacedwordPullActions, "encodedPreplacedword"));
    }

    @Test
    public void after(@Mock User user) throws JobExecutionException {
        when(userDAO.find(user.getKey())).thenReturn(user);
        dBPreplacedwordPullActions.after(profile, syncDelta, userTO, result);
        verify(user).setEncodedPreplacedword(anyString(), any(CipherAlgorithm.clreplaced));
        replacedertNull(ReflectionTestUtils.getField(dBPreplacedwordPullActions, "encodedPreplacedword"));
        replacedertNull(ReflectionTestUtils.getField(dBPreplacedwordPullActions, "cipher"));
    }
}

9 View Complete Implementation : AuthenticationITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void checkUserSuspension() {
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.setRealm("/odd");
    userCR.getRoles().add("User manager");
    UserTO userTO = createUser(userCR).getEnreplacedy();
    String userKey = userTO.getKey();
    replacedertNotNull(userTO);
    replacedertEquals(0, getFailedLogins(userService, userKey));
    // authentications failed ...
    try {
        clientFactory.create(userTO.getUsername(), "wrongpwd1");
        fail("This should not happen");
    } catch (AccessControlException e) {
        replacedertNotNull(e);
    }
    try {
        clientFactory.create(userTO.getUsername(), "wrongpwd1");
        fail("This should not happen");
    } catch (AccessControlException e) {
        replacedertNotNull(e);
    }
    try {
        clientFactory.create(userTO.getUsername(), "wrongpwd1");
        fail("This should not happen");
    } catch (AccessControlException e) {
        replacedertNotNull(e);
    }
    replacedertEquals(3, getFailedLogins(userService, userKey));
    // last authentication before suspension
    try {
        clientFactory.create(userTO.getUsername(), "wrongpwd1");
        fail("This should not happen");
    } catch (AccessControlException e) {
        replacedertNotNull(e);
    }
    userTO = userService.read(userTO.getKey());
    replacedertNotNull(userTO);
    replacedertNotNull(userTO.getFailedLogins());
    replacedertEquals(3, userTO.getFailedLogins().intValue());
    replacedertEquals("suspended", userTO.getStatus());
    // Access with correct credentials should fail as user is suspended
    try {
        clientFactory.create(userTO.getUsername(), "preplacedword123");
        fail("This should not happen");
    } catch (AccessControlException e) {
        replacedertNotNull(e);
    }
    StatusR reactivate = new StatusR.Builder().key(userTO.getKey()).type(StatusRType.REACTIVATE).build();
    userTO = userService.status(reactivate).readEnreplacedy(new GenericType<ProvisioningResult<UserTO>>() {
    }).getEnreplacedy();
    replacedertNotNull(userTO);
    replacedertEquals("active", userTO.getStatus());
    SyncopeClient goodPwdClient = clientFactory.create(userTO.getUsername(), "preplacedword123");
    replacedertEquals(0, goodPwdClient.self().getRight().getFailedLogins().intValue());
}

8 View Complete Implementation : UserWizardBuilder.java
Copyright Apache License 2.0
Author : apache
@Override
protected Serializable onApplyInternal(final AnyWrapper<UserTO> modelObject) {
    // captcha check
    if (captcha != null && captcha.evaluate() && !captcha.captchaCheck()) {
        throw new CaptchaNotMatchingException();
    }
    UserTO inner = modelObject.getInnerObject();
    ProvisioningResult<UserTO> result;
    if (inner.getKey() == null) {
        UserCR req = new UserCR();
        EnreplacedyTOUtils.toAnyCR(inner, req);
        req.setStorePreplacedword(modelObject instanceof UserWrapper ? UserWrapper.clreplaced.cast(modelObject).isStorePreplacedwordInSyncope() : StringUtils.isNotBlank(inner.getPreplacedword()));
        result = UserSelfRestClient.create(req);
    } else {
        fixPlainAndVirAttrs(inner, getOriginalItem().getInnerObject());
        UserUR userUR = AnyOperations.diff(inner, getOriginalItem().getInnerObject(), false);
        if (StringUtils.isNotBlank(inner.getPreplacedword())) {
            PreplacedwordPatch preplacedwordPatch = new PreplacedwordPatch.Builder().value(inner.getPreplacedword()).onSyncope(true).resources(inner.getResources()).build();
            userUR.setPreplacedword(preplacedwordPatch);
        }
        // update just if it is changed
        if (userUR.isEmpty()) {
            result = new ProvisioningResult<>();
            result.setEnreplacedy(inner);
        } else {
            result = userSelfRestClient.update(getOriginalItem().getInnerObject().getETagValue(), userUR);
        }
    }
    return result;
}

8 View Complete Implementation : AuthenticationITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void userSchemaAuthorization() {
    String schemaName = "authTestSchema" + getUUIDString();
    // 1. create a schema (as admin)
    PlainSchemaTO schemaTO = new PlainSchemaTO();
    schemaTO.setKey(schemaName);
    schemaTO.setMandatoryCondition("false");
    schemaTO.setType(AttrSchemaType.String);
    PlainSchemaTO newPlainSchemaTO = createSchema(SchemaType.PLAIN, schemaTO);
    replacedertEquals(schemaTO, newPlainSchemaTO);
    // 2. create an user with the role created above (as admin)
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    // 3. read the schema created above (as admin) - success
    schemaTO = schemaService.read(SchemaType.PLAIN, schemaName);
    replacedertNotNull(schemaTO);
    // 4. read the schema created above (as user) - success
    SchemaService schemaService2 = clientFactory.create(userTO.getUsername(), "preplacedword123").getService(SchemaService.clreplaced);
    schemaTO = schemaService2.read(SchemaType.PLAIN, schemaName);
    replacedertNotNull(schemaTO);
    // 5. update the schema create above (as user) - failure
    try {
        schemaService2.update(SchemaType.PLAIN, schemaTO);
        fail("Schema update as user should not work");
    } catch (ForbiddenException e) {
        replacedertNotNull(e);
    }
    replacedertEquals(0, getFailedLogins(userService, userTO.getKey()));
}

8 View Complete Implementation : AuthenticationITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issueSYNCOPE434() {
    replacedumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService));
    // 1. create user with group 'groupForWorkflowApproval'
    // (users with group groupForWorkflowApproval are defined in workflow as subject to approval)
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getMemberships().add(new MembershipTO.Builder("0cbcabd2-4410-4b6b-8f05-a052b451d18f").build());
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    replacedertEquals("createApproval", userTO.getStatus());
    // 2. try to authenticate: fail
    try {
        clientFactory.create(userTO.getUsername(), "preplacedword123").self();
        fail("This should not happen");
    } catch (AccessControlException e) {
        replacedertNotNull(e);
    }
    // 3. approve user
    UserRequestForm form = userRequestService.getForms(new UserRequestFormQuery.Builder().user(userTO.getKey()).build()).getResult().get(0);
    form = userRequestService.claimForm(form.getTaskId());
    form.getProperty("approveCreate").get().setValue(Boolean.TRUE.toString());
    userTO = userRequestService.submitForm(form);
    replacedertNotNull(userTO);
    replacedertEquals("active", userTO.getStatus());
    // 4. try to authenticate again: success
    Pair<Map<String, Set<String>>, UserTO> self = clientFactory.create(userTO.getUsername(), "preplacedword123").self();
    replacedertNotNull(self);
    replacedertNotNull(self.getLeft());
    replacedertNotNull(self.getRight());
}

8 View Complete Implementation : PlainSchemaITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issue259() {
    PlainSchemaTO schemaTO = buildPlainSchemaTO("schema_issue259", AttrSchemaType.Double);
    schemaTO.setUniqueConstraint(true);
    schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
    replacedertNotNull(schemaTO);
    AnyTypeClreplacedTO typeClreplaced = new AnyTypeClreplacedTO();
    typeClreplaced.setKey("issue259");
    typeClreplaced.getPlainSchemas().add(schemaTO.getKey());
    anyTypeClreplacedService.create(typeClreplaced);
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getAuxClreplacedes().add(typeClreplaced.getKey());
    userCR.getPlainAttrs().add(attr(schemaTO.getKey(), "1"));
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    UserUR req = new UserUR.Builder(userTO.getKey()).membership(new MembershipUR.Builder("b1f7c12d-ec83-441f-a50e-1691daaedf3b").build()).build();
    UserTO newUserTO = updateUser(req).getEnreplacedy();
    replacedertNotNull(newUserTO);
}

8 View Complete Implementation : PropagationTaskITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void batch() throws IOException {
    // create user with testdb resource
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getResources().add(RESOURCE_NAME_TESTDB);
    UserTO userTO = createUser(userCR).getEnreplacedy();
    List<PropagationTaskTO> tasks = new ArrayList<>(taskService.<PropagationTaskTO>search(new TaskQuery.Builder(TaskType.PROPAGATION).anyTypeKind(AnyTypeKind.USER).enreplacedyKey(userTO.getKey()).build()).getResult());
    replacedertFalse(tasks.isEmpty());
    BatchRequest batchRequest = adminClient.batch();
    TaskService batchTaskService = batchRequest.getService(TaskService.clreplaced);
    tasks.forEach(task -> batchTaskService.delete(TaskType.PROPAGATION, task.getKey()));
    Response response = batchRequest.commit().getResponse();
    parseBatchResponse(response);
    replacedertFalse(taskService.search(new TaskQuery.Builder(TaskType.PROPAGATION).page(1).size(100).build()).getResult().containsAll(tasks));
}

8 View Complete Implementation : PropagationTaskITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issueSYNCOPE1288() {
    // create a new user
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getResources().add(RESOURCE_NAME_LDAP);
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    // generate some PropagationTasks
    for (int i = 0; i < 9; i++) {
        UserUR userUR = new UserUR();
        userUR.setKey(userTO.getKey());
        userUR.getPlainAttrs().add(new AttrPatch.Builder(new Attr.Builder("userId").value("test" + getUUIDString() + i + "@test.com").build()).operation(PatchOperation.ADD_REPLACE).build());
        userService.update(userUR);
    }
    // ASC order
    PagedResult<TaskTO> unorderedTasks = taskService.search(new TaskQuery.Builder(TaskType.PROPAGATION).resource(RESOURCE_NAME_LDAP).enreplacedyKey(userTO.getKey()).anyTypeKind(AnyTypeKind.USER).page(1).size(10).build());
    Collections.sort(unorderedTasks.getResult(), (t1, t2) -> t1.getStart().compareTo(t2.getStart()));
    replacedertNotNull(unorderedTasks);
    replacedertFalse(unorderedTasks.getResult().isEmpty());
    replacedertEquals(10, unorderedTasks.getResult().size());
    PagedResult<TaskTO> orderedTasks = taskService.search(new TaskQuery.Builder(TaskType.PROPAGATION).resource(RESOURCE_NAME_LDAP).enreplacedyKey(userTO.getKey()).anyTypeKind(AnyTypeKind.USER).page(1).size(10).orderBy("start").build());
    replacedertNotNull(orderedTasks);
    replacedertFalse(orderedTasks.getResult().isEmpty());
    replacedertEquals(10, orderedTasks.getResult().size());
    replacedertTrue(orderedTasks.getResult().equals(unorderedTasks.getResult()));
    // DESC order
    Collections.reverse(unorderedTasks.getResult());
    orderedTasks = taskService.search(new TaskQuery.Builder(TaskType.PROPAGATION).resource(RESOURCE_NAME_LDAP).enreplacedyKey(userTO.getKey()).anyTypeKind(AnyTypeKind.USER).page(1).size(10).orderBy("start DESC").build());
    replacedertTrue(orderedTasks.getResult().equals(unorderedTasks.getResult()));
}

8 View Complete Implementation : UserWizardBuilder.java
Copyright Apache License 2.0
Author : apache
@Override
protected Serializable onApplyInternal(final AnyWrapper<UserTO> modelObject) {
    UserTO inner = modelObject.getInnerObject();
    ProvisioningResult<UserTO> result;
    if (inner.getKey() == null) {
        UserCR req = new UserCR();
        EnreplacedyTOUtils.toAnyCR(inner, req);
        req.setStorePreplacedword(modelObject instanceof UserWrapper ? UserWrapper.clreplaced.cast(modelObject).isStorePreplacedwordInSyncope() : StringUtils.isNotBlank(inner.getPreplacedword()));
        result = UserRestClient.create(req);
    } else {
        fixPlainAndVirAttrs(inner, getOriginalItem().getInnerObject());
        UserUR userUR = AnyOperations.diff(inner, getOriginalItem().getInnerObject(), false);
        if (StringUtils.isNotBlank(inner.getPreplacedword())) {
            PreplacedwordPatch preplacedwordPatch = new PreplacedwordPatch.Builder().value(inner.getPreplacedword()).onSyncope(true).resources(inner.getResources()).build();
            userUR.setPreplacedword(preplacedwordPatch);
        }
        // update just if it is changed
        if (userUR.isEmpty()) {
            result = new ProvisioningResult<>();
            result.setEnreplacedy(inner);
        } else {
            result = userRestClient.update(getOriginalItem().getInnerObject().getETagValue(), userUR);
        }
    }
    return result;
}

7 View Complete Implementation : AuthenticationITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void userSearch() {
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getRoles().add("User reviewer");
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    // 1. user replacedigned to role 1, with search enreplacedlement on realms /odd and /even: won't find anything with
    // root realm
    UserService userService2 = clientFactory.create(userTO.getUsername(), "preplacedword123").getService(UserService.clreplaced);
    PagedResult<UserTO> matchingUsers = userService2.search(new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).fiql(SyncopeClient.getUserSearchConditionBuilder().isNotNull("key").query()).build());
    replacedertNotNull(matchingUsers);
    replacedertFalse(matchingUsers.getResult().isEmpty());
    Set<String> matchingUserKeys = matchingUsers.getResult().stream().map(AnyTO::getKey).collect(Collectors.toSet());
    replacedertTrue(matchingUserKeys.contains("1417acbe-cbf6-4277-9372-e75e04f97000"));
    replacedertFalse(matchingUserKeys.contains("74cd8ece-715a-44a4-a736-e17b46c4e7e6"));
    replacedertFalse(matchingUserKeys.contains("823074dc-d280-436d-a7dd-07399fae48ec"));
    // 2. user replacedigned to role 4, with search enreplacedlement on realm /even/two
    UserService userService3 = clientFactory.create("puccini", ADMIN_PWD).getService(UserService.clreplaced);
    matchingUsers = userService3.search(new AnyQuery.Builder().realm("/even/two").fiql(SyncopeClient.getUserSearchConditionBuilder().isNotNull("loginDate").query()).build());
    replacedertNotNull(matchingUsers);
    replacedertTrue(matchingUsers.getResult().stream().allMatch(matching -> "/even/two".equals(matching.getRealm())));
}

7 View Complete Implementation : PlainSchemaITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issue260() {
    PlainSchemaTO schemaTO = buildPlainSchemaTO("schema_issue260", AttrSchemaType.Double);
    schemaTO.setUniqueConstraint(true);
    schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
    replacedertNotNull(schemaTO);
    AnyTypeClreplacedTO typeClreplaced = new AnyTypeClreplacedTO();
    typeClreplaced.setKey("issue260");
    typeClreplaced.getPlainSchemas().add(schemaTO.getKey());
    anyTypeClreplacedService.create(typeClreplaced);
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getAuxClreplacedes().add(typeClreplaced.getKey());
    userCR.getPlainAttrs().add(attr(schemaTO.getKey(), "1.2"));
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    schemaTO.setUniqueConstraint(false);
    try {
        schemaService.update(SchemaType.PLAIN, schemaTO);
        fail("This should not be reacheable");
    } catch (SyncopeClientException e) {
        replacedertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
    }
}

6 View Complete Implementation : UserLogic.java
Copyright Apache License 2.0
Author : apache
protected ProvisioningResult<UserTO> doCreate(final UserCR userCR, final boolean self, final boolean nullPriorityAsync) {
    Pair<UserCR, List<LogicActions>> before = beforeCreate(userCR);
    if (before.getLeft().getRealm() == null) {
        throw SyncopeClientException.build(ClientExceptionType.InvalidRealm);
    }
    if (!self) {
        Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(IdRepoEnreplacedlement.USER_CREATE), before.getLeft().getRealm());
        securityChecks(effectiveRealms, before.getLeft().getRealm(), null);
    }
    Pair<String, List<PropagationStatus>> created = provisioningManager.create(before.getLeft(), nullPriorityAsync);
    return afterCreate(binder.returnUserTO(binder.getUserTO(created.getKey())), created.getRight(), before.getRight());
}

6 View Complete Implementation : DefaultUserProvisioningManager.java
Copyright Apache License 2.0
Author : apache
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public Pair<String, List<PropagationStatus>> create(final UserCR userCR, final boolean disablePwdPolicyCheck, final Boolean enabled, final Set<String> excludedResources, final boolean nullPriorityAsync) {
    UserWorkflowResult<Pair<String, Boolean>> created = uwfAdapter.create(userCR, disablePwdPolicyCheck, enabled);
    List<PropagationTaskInfo> taskInfos = propagationManager.getUserCreateTasks(created.getResult().getLeft(), userCR.getPreplacedword(), created.getResult().getRight(), created.getPropByRes(), created.getPropByLinkedAccount(), userCR.getVirAttrs(), excludedResources);
    PropagationReporter propagationReporter = taskExecutor.execute(taskInfos, nullPriorityAsync, adminUser);
    return Pair.of(created.getResult().getLeft(), propagationReporter.getStatuses());
}

6 View Complete Implementation : SAML2UserManager.java
Copyright Apache License 2.0
Author : apache
@Transactional(propagation = Propagation.REQUIRES_NEW)
public String create(final SAML2IdPEnreplacedy idp, final SAML2LoginResponseTO responseTO, final String nameID) {
    UserCR userCR = new UserCR();
    userCR.setStorePreplacedword(false);
    if (idp.getUserTemplate() != null) {
        templateUtils.apply(userCR, idp.getUserTemplate());
    }
    List<SAML2IdPActions> actions = getActions(idp);
    for (SAML2IdPActions action : actions) {
        userCR = action.beforeCreate(userCR, responseTO);
    }
    UserTO userTO = new UserTO();
    fill(idp.getKey(), responseTO, userTO);
    EnreplacedyTOUtils.toAnyCR(userTO, userCR);
    if (userCR.getRealm() == null) {
        userCR.setRealm(SyncopeConstants.ROOT_REALM);
    }
    if (userCR.getUsername() == null) {
        userCR.setUsername(nameID);
    }
    Pair<String, List<PropagationStatus>> created = provisioningManager.create(userCR, false);
    userTO = binder.getUserTO(created.getKey());
    for (SAML2IdPActions action : actions) {
        userTO = action.afterCreate(userTO, responseTO);
    }
    return userTO.getUsername();
}

6 View Complete Implementation : MembershipITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void onGroupDelete() {
    // pre: create group with type extension
    TypeExtensionTO typeExtension = new TypeExtensionTO();
    typeExtension.setAnyType(AnyTypeKind.USER.name());
    typeExtension.getAuxClreplacedes().add("csv");
    typeExtension.getAuxClreplacedes().add("other");
    GroupCR groupCR = GroupITCase.getBasicSample("typeExt");
    groupCR.getTypeExtensions().add(typeExtension);
    GroupTO groupTO = createGroup(groupCR).getEnreplacedy();
    replacedertNotNull(groupTO);
    // pre: create user with membership to such group
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    MembershipTO membership = new MembershipTO.Builder(groupTO.getKey()).build();
    membership.getPlainAttrs().add(new Attr.Builder("aLong").value("1454").build());
    userCR.getMemberships().add(membership);
    UserTO user = createUser(userCR).getEnreplacedy();
    // verify that 'aLong' is correctly populated for user's membership
    replacedertEquals(1, user.getMemberships().size());
    membership = user.getMembership(groupTO.getKey()).get();
    replacedertNotNull(membership);
    replacedertEquals(1, membership.getPlainAttr("aLong").get().getValues().size());
    replacedertEquals("1454", membership.getPlainAttr("aLong").get().getValues().get(0));
    // verify that derived attrbutes from 'csv' and 'other' are also populated for user's membership
    replacedertFalse(membership.getDerAttr("csvuserid").get().getValues().isEmpty());
    replacedertFalse(membership.getDerAttr("noschema").get().getValues().isEmpty());
    // now remove the group -> all related memberships should have been removed as well
    groupService.delete(groupTO.getKey());
    // re-read user and verify that no memberships are available any more
    user = userService.read(user.getKey());
    replacedertTrue(user.getMemberships().isEmpty());
}

6 View Complete Implementation : UserSelfITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void createAndApprove() {
    replacedumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService));
    // 1. self-create user with membership: goes 'createApproval' with resources and membership but no propagation
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getMemberships().add(new MembershipTO.Builder("29f96485-729e-4d31-88a1-6fc60e4677f3").build());
    userCR.getResources().add(RESOURCE_NAME_TESTDB);
    SyncopeClient anonClient = clientFactory.create();
    UserTO userTO = anonClient.getService(UserSelfService.clreplaced).create(userCR).readEnreplacedy(new GenericType<ProvisioningResult<UserTO>>() {
    }).getEnreplacedy();
    replacedertNotNull(userTO);
    replacedertEquals("createApproval", userTO.getStatus());
    replacedertFalse(userTO.getMemberships().isEmpty());
    replacedertFalse(userTO.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userTO.getKey());
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        replacedertEquals(ClientExceptionType.NotFound, e.getType());
    }
    // 2. now approve and verify that propagation has happened
    UserRequestForm form = userRequestService.getForms(new UserRequestFormQuery.Builder().user(userTO.getKey()).build()).getResult().get(0);
    form = userRequestService.claimForm(form.getTaskId());
    form.getProperty("approveCreate").get().setValue(Boolean.TRUE.toString());
    userTO = userRequestService.submitForm(form);
    replacedertNotNull(userTO);
    replacedertEquals("active", userTO.getStatus());
    replacedertNotNull(resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userTO.getKey()));
}

6 View Complete Implementation : UserSelfITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void createAndUnclaim() {
    replacedumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService));
    // 1. self-create user with membership: goes 'createApproval' with resources and membership but no propagation
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getMemberships().add(new MembershipTO.Builder("29f96485-729e-4d31-88a1-6fc60e4677f3").build());
    userCR.getResources().add(RESOURCE_NAME_TESTDB);
    SyncopeClient anonClient = clientFactory.create();
    UserTO userTO = anonClient.getService(UserSelfService.clreplaced).create(userCR).readEnreplacedy(new GenericType<ProvisioningResult<UserTO>>() {
    }).getEnreplacedy();
    replacedertNotNull(userTO);
    replacedertEquals("createApproval", userTO.getStatus());
    replacedertFalse(userTO.getMemberships().isEmpty());
    replacedertFalse(userTO.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userTO.getKey());
        fail();
    } catch (SyncopeClientException e) {
        replacedertEquals(ClientExceptionType.NotFound, e.getType());
    }
    // 2. unclaim and verify that propagation has NOT happened
    UserRequestForm form = userRequestService.getForms(new UserRequestFormQuery.Builder().user(userTO.getKey()).build()).getResult().get(0);
    form = userRequestService.unclaimForm(form.getTaskId());
    replacedertNull(form.getreplacedignee());
    replacedertNotNull(userTO);
    replacedertNotEquals("active", userTO.getStatus());
    try {
        resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userTO.getKey());
        fail();
    } catch (Exception e) {
        replacedertNotNull(e);
    }
    // 3. approve and verify that propagation has happened
    form = userRequestService.getForms(new UserRequestFormQuery.Builder().user(userTO.getKey()).build()).getResult().get(0);
    form = userRequestService.claimForm(form.getTaskId());
    form.getProperty("approveCreate").get().setValue(Boolean.TRUE.toString());
    userTO = userRequestService.submitForm(form);
    replacedertNotNull(userTO);
    replacedertEquals("active", userTO.getStatus());
    replacedertNotNull(resourceService.readConnObject(RESOURCE_NAME_TESTDB, AnyTypeKind.USER.name(), userTO.getKey()));
}

5 View Complete Implementation : OIDCUserManager.java
Copyright Apache License 2.0
Author : apache
@Transactional(propagation = Propagation.REQUIRES_NEW)
public String create(final OIDCProvider op, final OIDCLoginResponseTO responseTO, final String email) {
    UserCR userCR = new UserCR();
    userCR.setStorePreplacedword(false);
    if (op.getUserTemplate() != null && op.getUserTemplate().get() != null) {
        templateUtils.apply(userCR, op.getUserTemplate().get());
    }
    List<OIDCProviderActions> actions = getActions(op);
    for (OIDCProviderActions action : actions) {
        userCR = action.beforeCreate(userCR, responseTO);
    }
    UserTO userTO = new UserTO();
    fill(op, responseTO, userTO);
    EnreplacedyTOUtils.toAnyCR(userTO, userCR);
    if (userCR.getRealm() == null) {
        userCR.setRealm(SyncopeConstants.ROOT_REALM);
    }
    if (userCR.getUsername() == null) {
        userCR.setUsername(email);
    }
    Pair<String, List<PropagationStatus>> created = provisioningManager.create(userCR, false);
    userTO = binder.getUserTO(created.getKey());
    for (OIDCProviderActions action : actions) {
        userTO = action.afterCreate(userTO, responseTO);
    }
    return userTO.getUsername();
}

5 View Complete Implementation : PlainSchemaITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issue258() {
    PlainSchemaTO schemaTO = new PlainSchemaTO();
    schemaTO.setKey("schema_issue258");
    schemaTO.setType(AttrSchemaType.Double);
    schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
    replacedertNotNull(schemaTO);
    AnyTypeClreplacedTO typeClreplaced = new AnyTypeClreplacedTO();
    typeClreplaced.setKey("issue258");
    typeClreplaced.getPlainSchemas().add(schemaTO.getKey());
    anyTypeClreplacedService.create(typeClreplaced);
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getAuxClreplacedes().add(typeClreplaced.getKey());
    userCR.getPlainAttrs().add(attr(schemaTO.getKey(), "1.2"));
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    schemaTO.setType(AttrSchemaType.Long);
    try {
        schemaService.update(SchemaType.PLAIN, schemaTO);
        fail("This should not be reacheable");
    } catch (SyncopeClientException e) {
        replacedertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
    }
}

5 View Complete Implementation : VirAttrITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void virAttrCache() {
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.getVirAttrs().clear();
    Attr virAttr = new Attr();
    virAttr.setSchema("virtualdata");
    virAttr.getValues().add("virattrcache");
    userCR.getVirAttrs().add(virAttr);
    userCR.getMemberships().clear();
    userCR.getResources().clear();
    userCR.getResources().add(RESOURCE_NAME_DBVIRATTR);
    // 1. create user
    UserTO actual = createUser(userCR).getEnreplacedy();
    replacedertNotNull(actual);
    // 2. check for virtual attribute value
    actual = userService.read(actual.getKey());
    replacedertEquals("virattrcache", actual.getVirAttr("virtualdata").get().getValues().get(0));
    // 3. update virtual attribute directly
    JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
    String value = queryForObject(jdbcTemplate, MAX_WAIT_SECONDS, "SELECT USERNAME FROM testpull WHERE ID=?", String.clreplaced, actual.getKey());
    replacedertEquals("virattrcache", value);
    jdbcTemplate.update("UPDATE testpull set USERNAME='virattrcache2' WHERE ID=?", actual.getKey());
    value = queryForObject(jdbcTemplate, MAX_WAIT_SECONDS, "SELECT USERNAME FROM testpull WHERE ID=?", String.clreplaced, actual.getKey());
    replacedertEquals("virattrcache2", value);
    // 4. check for cached attribute value
    actual = userService.read(actual.getKey());
    replacedertEquals("virattrcache", actual.getVirAttr("virtualdata").get().getValues().get(0));
    UserUR userUR = new UserUR();
    userUR.setKey(actual.getKey());
    userUR.getVirAttrs().add(attr("virtualdata", "virtualupdated"));
    // 5. update virtual attribute
    actual = updateUser(userUR).getEnreplacedy();
    replacedertNotNull(actual);
    // 6. check for virtual attribute value
    actual = userService.read(actual.getKey());
    replacedertNotNull(actual);
    replacedertEquals("virtualupdated", actual.getVirAttr("virtualdata").get().getValues().get(0));
}

4 View Complete Implementation : AuthenticationITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void issueSYNCOPE164() throws Exception {
    // 1. create user with db resource
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    userCR.setRealm("/even/two");
    userCR.setPreplacedword("preplacedword123");
    userCR.getResources().add(RESOURCE_NAME_TESTDB);
    UserTO user = createUser(userCR).getEnreplacedy();
    replacedertNotNull(user);
    // 2. unlink the resource from the created user
    ResourceDR resourceDR = new ResourceDR.Builder().key(user.getKey()).action(ResourceDereplacedociationAction.UNLINK).resource(RESOURCE_NAME_TESTDB).build();
    replacedertNotNull(parseBatchResponse(userService.dereplacedociate(resourceDR)));
    // 3. change preplacedword on Syncope
    UserUR userUR = new UserUR();
    userUR.setKey(user.getKey());
    userUR.setPreplacedword(new PreplacedwordPatch.Builder().value("preplacedword234").build());
    user = updateUser(userUR).getEnreplacedy();
    replacedertNotNull(user);
    // 4. check that the db resource has still the initial preplacedword value
    JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
    String value = queryForObject(jdbcTemplate, MAX_WAIT_SECONDS, "SELECT PreplacedWORD FROM test WHERE ID=?", String.clreplaced, user.getUsername());
    replacedertEquals(Encryptor.getInstance().encode("preplacedword123", CipherAlgorithm.SHA1), value.toUpperCase());
    // 5. successfully authenticate with old (on db resource) and new (on internal storage) preplacedword values
    Pair<Map<String, Set<String>>, UserTO> self = clientFactory.create(user.getUsername(), "preplacedword123").self();
    replacedertNotNull(self);
    self = clientFactory.create(user.getUsername(), "preplacedword234").self();
    replacedertNotNull(self);
}

4 View Complete Implementation : PlainSchemaITCase.java
Copyright Apache License 2.0
Author : apache
@Test
public void binaryValidation() throws IOException {
    // pdf - with validator
    PlainSchemaTO schemaTOpdf = new PlainSchemaTO();
    schemaTOpdf.setKey("BinaryPDF");
    schemaTOpdf.setType(AttrSchemaType.Binary);
    schemaTOpdf.setMimeType("application/pdf");
    schemaTOpdf.setValidator("BinaryValidator");
    schemaTOpdf.setAnyTypeClreplaced("minimal user");
    createSchema(SchemaType.PLAIN, schemaTOpdf);
    // json - with validator
    PlainSchemaTO schemaTOjson = new PlainSchemaTO();
    schemaTOjson.setKey("BinaryJSON");
    schemaTOjson.setType(AttrSchemaType.Binary);
    schemaTOjson.setMimeType("application/json");
    schemaTOjson.setValidator("BinaryValidator");
    schemaTOjson.setAnyTypeClreplaced("minimal user");
    createSchema(SchemaType.PLAIN, schemaTOjson);
    // json - no validator
    PlainSchemaTO schemaTOjson2 = new PlainSchemaTO();
    schemaTOjson2.setKey("BinaryJSON2");
    schemaTOjson2.setType(AttrSchemaType.Binary);
    schemaTOjson2.setMimeType("application/json");
    schemaTOjson2.setAnyTypeClreplaced("minimal user");
    createSchema(SchemaType.PLAIN, schemaTOjson2);
    UserCR userCR = UserITCase.getUniqueSample("[email protected]");
    UserTO userTO = createUser(userCR).getEnreplacedy();
    replacedertNotNull(userTO);
    UserUR userUR = new UserUR();
    userUR.setKey(userTO.getKey());
    // validation OK - application/pdf -> application/pdf
    userUR.getPlainAttrs().add(new AttrPatch.Builder(attr("BinaryPDF", Base64.getEncoder().encodeToString(IOUtils.readBytesFromStream(getClreplaced().getResourcereplacedtream("/test.pdf"))))).operation(PatchOperation.ADD_REPLACE).build());
    updateUser(userUR);
    replacedertNotNull(userService.read(userTO.getKey()).getPlainAttr("BinaryPDF"));
    userUR = new UserUR();
    userUR.setKey(userTO.getKey());
    // validation KO - text/html -> application/pdf
    try {
        userUR.getPlainAttrs().add(new AttrPatch.Builder(attr("BinaryPDF", Base64.getEncoder().encodeToString(IOUtils.readBytesFromStream(getClreplaced().getResourcereplacedtream("/test.html"))))).operation(PatchOperation.ADD_REPLACE).build());
        updateUser(userUR);
        fail("This should not be reacheable");
    } catch (SyncopeClientException e) {
        replacedertEquals(ClientExceptionType.InvalidValues, e.getType());
    }
    userUR = new UserUR();
    userUR.setKey(userTO.getKey());
    // validation ok - application/json -> application/json
    userUR.getPlainAttrs().add(new AttrPatch.Builder(attr("BinaryJSON", Base64.getEncoder().encodeToString(IOUtils.readBytesFromStream(getClreplaced().getResourcereplacedtream("/test.json"))))).operation(PatchOperation.ADD_REPLACE).build());
    updateUser(userUR);
    replacedertNotNull(userService.read(userTO.getKey()).getPlainAttr("BinaryJSON"));
    userUR = new UserUR();
    userUR.setKey(userTO.getKey());
    // no validation - application/xml -> application/json
    userUR.getPlainAttrs().add(new AttrPatch.Builder(attr("BinaryJSON2", Base64.getEncoder().encodeToString(IOUtils.readBytesFromStream(getClreplaced().getResourcereplacedtream("/test.xml"))))).operation(PatchOperation.ADD_REPLACE).build());
    updateUser(userUR);
    replacedertNotNull(userService.read(userTO.getKey()).getPlainAttr("BinaryJSON2"));
}