Package org.apache.syncope.common.to

Examples of org.apache.syncope.common.to.UserRequestTO


        UserRequest request = userRequestDAO.find(requestId);
        if (request == null) {
            throw new NotFoundException("User request " + requestId);
        }

        UserRequestTO requestToDelete = binder.getUserRequestTO(request);

        auditManager.audit(Category.userRequest, UserRequestSubCategory.delete, Result.success,
                "Successfully deleted user request for user" + request.getUserId());

        userRequestDAO.delete(requestId);
View Full Code Here


        UserTO userTO = UserTestITCase.getUniqueSampleTO("selfcreate@syncope.apache.org");

        // 2. get unauthorized when trying to request user create
        try {
            createUserRequest(userRequestService, new UserRequestTO(userTO));
            fail();
        } catch (SyncopeClientCompositeErrorException e) {
            assertNotNull(e.getException(SyncopeClientExceptionType.UnauthorizedRole));
        }

        // 3. set create request allowed
        configurationTO.setValue("true");

        response = configurationService.create(configurationTO);
        assertNotNull(response);
        assertEquals(org.apache.http.HttpStatus.SC_CREATED, response.getStatus());
        configurationTO = getObject(response, ConfigurationTO.class, configurationService);
        assertNotNull(configurationTO);

        // 4. as anonymous, request user create works
        UserRequestService userRequestService2 = setupCredentials(userRequestService, UserRequestService.class, null, null);
        response = createUserRequest(userRequestService2, new UserRequestTO(userTO));

        // 5. switch back to admin
        super.resetRestTemplate(); // TODO remove after CXF migration is complete

        // 6. try to find user
View Full Code Here

        userMod.setId(userTO.getId());
        userMod.setPassword(initialPassword);

        // 2. try to request user update as admin: failure
        try {
            createUserRequest(userRequestService, new UserRequestTO(userMod));
            fail();
        } catch (SyncopeClientCompositeErrorException e) {
            assertNotNull(e.getException(SyncopeClientExceptionType.UnauthorizedRole));
        }

        // 3. auth as user just created
        UserRequestService userRequestService2 = setupCredentials(userRequestService, UserRequestService.class,
                userTO.getUsername(), initialPassword);

        // 4. update with same password: not matching password policy
        try {
            createUserRequest(userRequestService2, new UserRequestTO(userMod));
            fail();
        } catch (SyncopeClientCompositeErrorException scce) {
            assertNotNull(scce.getException(SyncopeClientExceptionType.InvalidSyncopeUser));
        }

        // 5. now request user update works
        userMod.setPassword("new" + initialPassword);
        createUserRequest(userRequestService2, new UserRequestTO(userMod));

        // 6. switch back to admin
        super.resetRestTemplate();

        // 7. user password has not changed yet
View Full Code Here

        userTO = createUser(userTO);
        assertNotNull(userTO);

        // 2. try to request user delete as admin: failure
        try {
            createUserRequest(userRequestService, new UserRequestTO(userTO.getId()));
            fail();
        } catch (SyncopeClientCompositeErrorException e) {
            assertNotNull(e.getException(SyncopeClientExceptionType.UnauthorizedRole));
        }

        // 3. auth as user just created
        UserRequestService userRequestService2 = setupCredentials(userRequestService, UserRequestService.class,
                userTO.getUsername(), initialPassword);

        // 4. now request user delete works
        createUserRequest(userRequestService2, new UserRequestTO(userTO.getId()));

        // 5. switch back to admin
        super.resetRestTemplate();

        // 6. user still exists
View Full Code Here

        return getRestTemplate().getForObject(baseUrl + "user/request/create/allowed.json", Boolean.class);
    }

    @Override
    public Response create(final UserRequestTO userRequestTO) {
        UserRequestTO created;
        switch (userRequestTO.getType()) {
            case UPDATE:
                created = getRestTemplate().postForObject(baseUrl + "user/request/update", userRequestTO.getUserMod(),
                        UserRequestTO.class);
                break;

            case DELETE:
                created = getRestTemplate().getForObject(baseUrl + "user/request/delete/{userId}", UserRequestTO.class,
                        userRequestTO.getUserId());
                break;

            case CREATE:
            default:
                created = getRestTemplate().postForObject(baseUrl + "user/request/create", userRequestTO.getUserTO(),
                        UserRequestTO.class);
        }

        URI location = URI.create(baseUrl + "user/request/read/" + created.getId() + ".json");
        return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, created.getId()).build();
    }
View Full Code Here

            @Override
            public void populateItem(final Item<ICellPopulator<UserRequestTO>> cellItem, final String componentId,
                    final IModel<UserRequestTO> model) {

                final UserRequestTO request = model.getObject();

                final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference());

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        editUserRequestWin.setPageCreator(new ModalWindow.PageCreator() {

                            private static final long serialVersionUID = -7834632442532690940L;

                            @Override
                            public Page createPage() {
                                return new UserRequestModalPage(Todo.this.getPageReference(), editUserRequestWin,
                                        model.getObject(), UserModalPage.Mode.ADMIN);
                            }
                        });

                        editUserRequestWin.show(target);
                    }
                }, ActionLink.ActionType.EDIT, "UserRequest",
                        model.getObject().getType() != UserRequestType.DELETE);

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        try {
                            userRestClient.delete(model.getObject().getUserId());
                            userRequestRestClient.delete(model.getObject().getId());
                        } catch (SyncopeClientCompositeErrorException e) {
                            LOG.error("While deleting an user", e);
                            error(e.getMessage());
                            return;
                        }

                        info(getString("operation_succeeded"));
                        target.add(feedbackPanel);

                        target.add(userRequestContainer);
                    }
                }, ActionLink.ActionType.DELETE, "Users",
                        model.getObject().getType() == UserRequestType.DELETE);

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        try {
                            userRequestRestClient.delete(request.getId());
                        } catch (SyncopeClientCompositeErrorException e) {
                            LOG.error("While deleting an user request", e);
                            error(e.getMessage());
                            return;
                        }
View Full Code Here

        return userRequestController.isCreateAllowedByConf();
    }

    @Override
    public Response create(final UserRequestTO userRequestTO) {
        UserRequestTO outUserRequestTO = null;
        if (userRequestTO.getType() == UserRequestType.CREATE) {
            outUserRequestTO = userRequestController.create(userRequestTO.getUserTO());
        } else if (userRequestTO.getType() == UserRequestType.UPDATE) {
            outUserRequestTO = userRequestController.update(userRequestTO.getUserMod());
        } else if (userRequestTO.getType() == UserRequestType.DELETE) {
            outUserRequestTO = userRequestController.delete(userRequestTO.getUserId());
        }
        URI location = uriInfo.getAbsolutePathBuilder().path("" + outUserRequestTO.getId()).build();
        return Response.created(location)
                .header(SyncopeConstants.REST_HEADER_ID, outUserRequestTO.getId())
                .build();
    }
View Full Code Here

        SyncopeUser authUser = userDAO.find(SecurityContextHolder.getContext().getAuthentication().getName());
        return userDataBinder.getUserTO(authUser);
    }

    public UserRequestTO getUserRequestTO(final UserRequest request) {
        UserRequestTO result = new UserRequestTO();
        BeanUtils.copyProperties(request, result);

        return result;
    }
View Full Code Here

    public void delete(final Long requestId) {
        getService(UserRequestService.class).delete(requestId);
    }

    public void requestCreate(final UserTO userTO) {
        UserRequestTO userRequestTO = new UserRequestTO();
        userRequestTO.setType(UserRequestType.CREATE);
        userRequestTO.setUserTO(userTO);
        getService(UserRequestService.class).create(userRequestTO);
    }
View Full Code Here

        userRequestTO.setUserTO(userTO);
        getService(UserRequestService.class).create(userRequestTO);
    }

    public void requestUpdate(final UserMod userMod) {
        UserRequestTO userRequestTO = new UserRequestTO();
        userRequestTO.setType(UserRequestType.UPDATE);
        userRequestTO.setUserMod(userMod);
        getService(UserRequestService.class).create(userRequestTO);
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.to.UserRequestTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.