Search in sources :

Example 1 with RoleTO

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

the class RoleITCase method getSampleRoleTO.

public static RoleTO getSampleRoleTO(final String name) {
    RoleTO role = new RoleTO();
    role.setKey(name + getUUIDString());
    role.getRealms().add("/even");
    role.getEntitlements().add(StandardEntitlement.LOG_SET_LEVEL);
    return role;
}
Also used : RoleTO(org.apache.syncope.common.lib.to.RoleTO)

Example 2 with RoleTO

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

the class RoleITCase method update.

@Test
public void update() {
    RoleTO role = getSampleRoleTO("update");
    role = createRole(role);
    assertNotNull(role);
    assertFalse(role.getEntitlements().contains(StandardEntitlement.WORKFLOW_TASK_LIST));
    assertFalse(role.getRealms().contains("/even/two"));
    role.getEntitlements().add(StandardEntitlement.WORKFLOW_TASK_LIST);
    role.getRealms().add("/even/two");
    roleService.update(role);
    role = roleService.read(role.getKey());
    assertTrue(role.getEntitlements().contains(StandardEntitlement.WORKFLOW_TASK_LIST));
    assertTrue(role.getRealms().contains("/even/two"));
}
Also used : RoleTO(org.apache.syncope.common.lib.to.RoleTO) Test(org.junit.jupiter.api.Test)

Example 3 with RoleTO

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

the class Security method buildTabList.

private List<ITab> buildTabList() {
    final List<ITab> tabs = new ArrayList<>();
    tabs.add(new AbstractTab(new ResourceModel("roles")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new RoleDirectoryPanel.Builder(getPageReference()) {

                private static final long serialVersionUID = -5960765294082359003L;
            }.addNewItemPanelBuilder(new RoleWizardBuilder(new RoleTO(), getPageReference()), true).build(panelId);
        }
    });
    tabs.add(new AbstractTab(new ResourceModel("dynRealms")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new DynRealmDirectoryPanel.Builder(getPageReference()) {

                private static final long serialVersionUID = -5960765294082359003L;
            }.build(panelId);
        }
    });
    tabs.add(new AbstractTab(new ResourceModel("applications")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new ApplicationDirectoryPanel.Builder(getPageReference()) {

                private static final long serialVersionUID = -5960765294082359003L;
            }.build(panelId);
        }
    });
    tabs.add(new AbstractTab(new ResourceModel("securityQuestions")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new SecurityQuestionsPanel(panelId, getPageReference());
        }
    });
    return tabs;
}
Also used : RoleWizardBuilder(org.apache.syncope.client.console.wizards.role.RoleWizardBuilder) SecurityQuestionsPanel(org.apache.syncope.client.console.panels.SecurityQuestionsPanel) RoleWizardBuilder(org.apache.syncope.client.console.wizards.role.RoleWizardBuilder) BookmarkablePageLinkBuilder(org.apache.syncope.client.console.BookmarkablePageLinkBuilder) ArrayList(java.util.ArrayList) RoleTO(org.apache.syncope.common.lib.to.RoleTO) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) SecurityQuestionsPanel(org.apache.syncope.client.console.panels.SecurityQuestionsPanel) DynRealmDirectoryPanel(org.apache.syncope.client.console.panels.DynRealmDirectoryPanel) AjaxBootstrapTabbedPanel(de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) RoleDirectoryPanel(org.apache.syncope.client.console.panels.RoleDirectoryPanel) ApplicationDirectoryPanel(org.apache.syncope.client.console.panels.ApplicationDirectoryPanel) RoleDirectoryPanel(org.apache.syncope.client.console.panels.RoleDirectoryPanel) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) ResourceModel(org.apache.wicket.model.ResourceModel)

Example 4 with RoleTO

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

the class RoleDataBinderImpl method getRoleTO.

@Override
public RoleTO getRoleTO(final Role role) {
    RoleTO roleTO = new RoleTO();
    roleTO.setKey(role.getKey());
    roleTO.getEntitlements().addAll(role.getEntitlements());
    roleTO.getRealms().addAll(role.getRealms().stream().map(Realm::getFullPath).collect(Collectors.toList()));
    roleTO.getDynRealms().addAll(role.getDynRealms().stream().map(Entity::getKey).collect(Collectors.toList()));
    if (role.getDynMembership() != null) {
        roleTO.setDynMembershipCond(role.getDynMembership().getFIQLCond());
    }
    roleTO.getPrivileges().addAll(role.getPrivileges().stream().map(Entity::getKey).collect(Collectors.toList()));
    return roleTO;
}
Also used : Entity(org.apache.syncope.core.persistence.api.entity.Entity) RoleTO(org.apache.syncope.common.lib.to.RoleTO) Realm(org.apache.syncope.core.persistence.api.entity.Realm) DynRealm(org.apache.syncope.core.persistence.api.entity.DynRealm)

Example 5 with RoleTO

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

the class RoleLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.ROLE_DELETE + "')")
public RoleTO delete(final String key) {
    Role role = roleDAO.find(key);
    if (role == null) {
        LOG.error("Could not find role '" + key + "'");
        throw new NotFoundException(key);
    }
    RoleTO deleted = binder.getRoleTO(role);
    roleDAO.delete(key);
    return deleted;
}
Also used : Role(org.apache.syncope.core.persistence.api.entity.Role) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) RoleTO(org.apache.syncope.common.lib.to.RoleTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

RoleTO (org.apache.syncope.common.lib.to.RoleTO)18 Test (org.junit.jupiter.api.Test)12 Response (javax.ws.rs.core.Response)8 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)8 UserTO (org.apache.syncope.common.lib.to.UserTO)6 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)4 RoleService (org.apache.syncope.common.rest.api.service.RoleService)4 AbstractITCase (org.apache.syncope.fit.AbstractITCase)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)3 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)3 PagedResult (org.apache.syncope.common.lib.to.PagedResult)3 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)3 AnyTypeKind (org.apache.syncope.common.lib.types.AnyTypeKind)3 ClientExceptionType (org.apache.syncope.common.lib.types.ClientExceptionType)3 AnyQuery (org.apache.syncope.common.rest.api.beans.AnyQuery)3 UserService (org.apache.syncope.common.rest.api.service.UserService)3 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)3