Package org.apache.syncope.common.to

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


    @Transactional(readOnly = true)
    public <T extends AbstractAttributableMod> T getAttributableMod(final Long id, final ConnectorObject obj,
            final AbstractAttributableTO original, final SyncTask syncTask, final AttributableUtil attrUtil)
            throws NotFoundException, UnauthorizedRoleException {

        final AbstractAttributableTO updated = getAttributableTOFromConnObject(obj, syncTask, attrUtil);
        updated.setId(id);

        if (AttributableType.USER == attrUtil.getType()) {
            // update password if and only if password is really changed
            final SyncopeUser user = userDataBinder.getUserFromId(id);
            if (StringUtils.isBlank(((UserTO) updated).getPassword())
View Full Code Here


                default:
            }
        }

        // 2. add data from defined template (if any)
        AbstractAttributableTO template = AttributableType.USER == attrUtil.getType()
                ? syncTask.getUserTemplate() : syncTask.getRoleTemplate();

        if (template != null) {
            if (template instanceof UserTO) {
                if (StringUtils.isNotBlank(((UserTO) template).getUsername())) {
                    String evaluated = jexlUtil.evaluate(((UserTO) template).getUsername(), attributableTO);
                    if (StringUtils.isNotBlank(evaluated)) {
                        ((UserTO) attributableTO).setUsername(evaluated);
                    }
                }

                if (StringUtils.isNotBlank(((UserTO) template).getPassword())) {
                    String evaluated = jexlUtil.evaluate(((UserTO) template).getPassword(), attributableTO);
                    if (StringUtils.isNotBlank(evaluated)) {
                        ((UserTO) attributableTO).setPassword(evaluated);
                    }
                }

                Map<Long, MembershipTO> currentMembs = ((UserTO) attributableTO).getMembershipMap();
                for (MembershipTO membTO : ((UserTO) template).getMemberships()) {
                    MembershipTO membTBU;
                    if (currentMembs.containsKey(membTO.getRoleId())) {
                        membTBU = currentMembs.get(membTO.getRoleId());
                    } else {
                        membTBU = new MembershipTO();
                        membTBU.setRoleId(membTO.getRoleId());
                        ((UserTO) attributableTO).addMembership(membTBU);
                    }
                    fillFromTemplate(membTBU, membTO);
                }
            }
            if (template instanceof RoleTO) {
                if (StringUtils.isNotBlank(((RoleTO) template).getName())) {
                    String evaluated = jexlUtil.evaluate(((RoleTO) template).getName(), attributableTO);
                    if (StringUtils.isNotBlank(evaluated)) {
                        ((RoleTO) attributableTO).setName(evaluated);
                    }
                }

                ((RoleTO) attributableTO).setParent(((RoleTO) template).getParent());

                ((RoleTO) attributableTO).setUserOwner(((RoleTO) template).getUserOwner());
                ((RoleTO) attributableTO).setRoleOwner(((RoleTO) template).getRoleOwner());

                ((RoleTO) attributableTO).setEntitlements(((RoleTO) template).getEntitlements());

                ((RoleTO) attributableTO).setAccountPolicy(((RoleTO) template).getAccountPolicy());
                ((RoleTO) attributableTO).setPasswordPolicy(((RoleTO) template).getPasswordPolicy());

                ((RoleTO) attributableTO).setInheritOwner(((RoleTO) template).isInheritOwner());
                ((RoleTO) attributableTO).setInheritAttributes(((RoleTO) template).isInheritAttributes());
                ((RoleTO) attributableTO).setInheritDerivedAttributes(((RoleTO) template).isInheritDerivedAttributes());
                ((RoleTO) attributableTO).setInheritVirtualAttributes(((RoleTO) template).isInheritVirtualAttributes());
                ((RoleTO) attributableTO).setInheritPasswordPolicy(((RoleTO) template).isInheritPasswordPolicy());
                ((RoleTO) attributableTO).setInheritAccountPolicy(((RoleTO) template).isInheritAccountPolicy());
            }

            fillFromTemplate(attributableTO, template);

            for (String resource : template.getResources()) {
                attributableTO.addResource(resource);
            }
        }

        return attributableTO;
View Full Code Here

        final SyncResult result = new SyncResult();
        result.setOperation(ResourceOperation.CREATE);
        result.setSubjectType(attrUtil.getType());
        result.setStatus(SyncResult.Status.SUCCESS);

        AbstractAttributableTO subjectTO = connObjectUtil.getAttributableTO(delta.getObject(), syncTask, attrUtil);

        delta = actions.beforeCreate(this, delta, subjectTO);

        if (dryRun) {
            result.setId(0L);
            if (subjectTO instanceof UserTO) {
                result.setName(((UserTO) subjectTO).getUsername());
            }
            if (subjectTO instanceof RoleTO) {
                result.setName(((RoleTO) subjectTO).getName());
            }
        } else {
            try {
                if (AttributableType.USER == attrUtil.getType()) {
                    Boolean enabled = readEnabled(delta.getObject());
                    WorkflowResult<Map.Entry<Long, Boolean>> created =
                            uwfAdapter.create((UserTO) subjectTO, true, enabled);

                    List<PropagationTask> tasks = propagationManager.getUserCreateTaskIds(created,
                            ((UserTO) subjectTO).getPassword(), subjectTO.getVirtualAttributes(),
                            Collections.singleton(syncTask.getResource().getName()));

                    taskExecutor.execute(tasks);

                    notificationManager.createTasks(created.getResult().getKey(), created.getPerformedTasks());

                    subjectTO = userDataBinder.getUserTO(created.getResult().getKey());

                    result.setId(created.getResult().getKey());
                    result.setName(((UserTO) subjectTO).getUsername());
                }
                if (AttributableType.ROLE == attrUtil.getType()) {
                    WorkflowResult<Long> created = rwfAdapter.create((RoleTO) subjectTO);
                    AttributeTO roleOwner = subjectTO.getAttributeMap().get(StringUtils.EMPTY);
                    if (roleOwner != null) {
                        roleOwnerMap.put(created.getResult(), roleOwner.getValues().iterator().next());
                    }

                    EntitlementUtil.extendAuthContext(created.getResult());

                    List<PropagationTask> tasks = propagationManager.getRoleCreateTaskIds(created,
                            subjectTO.getVirtualAttributes(), Collections.singleton(syncTask.getResource().getName()));

                    taskExecutor.execute(tasks);

                    subjectTO = roleDataBinder.getRoleTO(created.getResult());
View Full Code Here

        List<SyncResult> delResults = new ArrayList<SyncResult>();

        for (Long id : subjects) {
            try {
                AbstractAttributableTO subjectTO = AttributableType.USER == attrUtil.getType()
                        ? userDataBinder.getUserTO(id)
                        : roleDataBinder.getRoleTO(id);
                delta = actions.beforeDelete(this, delta, subjectTO);

                final SyncResult result = new SyncResult();
View Full Code Here

        final SyncResult result = new SyncResult();
        result.setOperation(ResourceOperation.CREATE);
        result.setSubjectType(attrUtil.getType());

        AbstractAttributableTO subjectTO = connObjectUtil.getAttributableTO(delta.getObject(), syncTask, attrUtil);

        delta = actions.beforeCreate(this, delta, subjectTO);

        if (dryRun) {
            result.setId(0L);
            if (subjectTO instanceof UserTO) {
                result.setName(((UserTO) subjectTO).getUsername());
            }
            if (subjectTO instanceof RoleTO) {
                result.setName(((RoleTO) subjectTO).getName());
            }
            result.setStatus(SyncResult.Status.SUCCESS);
        } else {
            try {
                if (AttributableType.USER == attrUtil.getType()) {
                    Boolean enabled = readEnabled(delta.getObject());
                    WorkflowResult<Map.Entry<Long, Boolean>> created =
                            uwfAdapter.create((UserTO) subjectTO, true, enabled);

                    List<PropagationTask> tasks = propagationManager.getUserCreateTaskIds(created,
                            ((UserTO) subjectTO).getPassword(), subjectTO.getVirtualAttributes(),
                            Collections.singleton(syncTask.getResource().getName()));

                    taskExecutor.execute(tasks);

                    notificationManager.createTasks(created.getResult().getKey(), created.getPerformedTasks());

                    subjectTO = userDataBinder.getUserTO(created.getResult().getKey());

                    result.setId(created.getResult().getKey());
                }
                if (AttributableType.ROLE == attrUtil.getType()) {
                    WorkflowResult<Long> created = rwfAdapter.create((RoleTO) subjectTO);
                    AttributeTO roleOwner = subjectTO.getAttributeMap().get(StringUtils.EMPTY);
                    if (roleOwner != null) {
                        roleOwnerMap.put(created.getResult(), roleOwner.getValues().iterator().next());
                    }

                    EntitlementUtil.extendAuthContext(created.getResult());

                    List<PropagationTask> tasks = propagationManager.getRoleCreateTaskIds(created,
                            subjectTO.getVirtualAttributes(), Collections.singleton(syncTask.getResource().getName()));

                    taskExecutor.execute(tasks);

                    subjectTO = roleDataBinder.getRoleTO(created.getResult());
View Full Code Here

        List<SyncResult> delResults = new ArrayList<SyncResult>();

        for (Long id : subjects) {
            try {
                AbstractAttributableTO subjectTO = AttributableType.USER == attrUtil.getType()
                        ? userDataBinder.getUserTO(id)
                        : roleDataBinder.getRoleTO(id);
                delta = actions.beforeDelete(this, delta, subjectTO);

                final SyncResult result = new SyncResult();
View Full Code Here

    @Transactional(readOnly = true)
    public <T extends AbstractAttributableMod> T getAttributableMod(final Long id, final ConnectorObject obj,
            final AbstractAttributableTO original, final SyncTask syncTask, final AttributableUtil attrUtil)
            throws NotFoundException, UnauthorizedRoleException {

        final AbstractAttributableTO updated = getAttributableTOFromConnObject(obj, syncTask, attrUtil);
        updated.setId(id);

        if (AttributableType.USER == attrUtil.getType()) {
            // update password if and only if password is really changed
            final SyncopeUser user = userDataBinder.getUserFromId(id);
            if (StringUtils.isBlank(((UserTO) updated).getPassword())
View Full Code Here

                default:
            }
        }

        // 2. add data from defined template (if any)
        AbstractAttributableTO template = AttributableType.USER == attrUtil.getType()
                ? syncTask.getUserTemplate() : syncTask.getRoleTemplate();

        if (template != null) {
            if (template instanceof UserTO) {
                if (StringUtils.isNotBlank(((UserTO) template).getUsername())) {
                    String evaluated = jexlUtil.evaluate(((UserTO) template).getUsername(), attributableTO);
                    if (StringUtils.isNotBlank(evaluated)) {
                        ((UserTO) attributableTO).setUsername(evaluated);
                    }
                }

                if (StringUtils.isNotBlank(((UserTO) template).getPassword())) {
                    String evaluated = jexlUtil.evaluate(((UserTO) template).getPassword(), attributableTO);
                    if (StringUtils.isNotBlank(evaluated)) {
                        ((UserTO) attributableTO).setPassword(evaluated);
                    }
                }

                Map<Long, MembershipTO> currentMembs = ((UserTO) attributableTO).getMembershipMap();
                for (MembershipTO membTO : ((UserTO) template).getMemberships()) {
                    MembershipTO membTBU;
                    if (currentMembs.containsKey(membTO.getRoleId())) {
                        membTBU = currentMembs.get(membTO.getRoleId());
                    } else {
                        membTBU = new MembershipTO();
                        membTBU.setRoleId(membTO.getRoleId());
                        ((UserTO) attributableTO).addMembership(membTBU);
                    }
                    fillFromTemplate(membTBU, membTO);
                }
            }
            if (template instanceof RoleTO) {
                if (StringUtils.isNotBlank(((RoleTO) template).getName())) {
                    String evaluated = jexlUtil.evaluate(((RoleTO) template).getName(), attributableTO);
                    if (StringUtils.isNotBlank(evaluated)) {
                        ((RoleTO) attributableTO).setName(evaluated);
                    }
                }

                ((RoleTO) attributableTO).setParent(((RoleTO) template).getParent());

                ((RoleTO) attributableTO).setUserOwner(((RoleTO) template).getUserOwner());
                ((RoleTO) attributableTO).setRoleOwner(((RoleTO) template).getRoleOwner());

                ((RoleTO) attributableTO).setEntitlements(((RoleTO) template).getEntitlements());

                ((RoleTO) attributableTO).setAccountPolicy(((RoleTO) template).getAccountPolicy());
                ((RoleTO) attributableTO).setPasswordPolicy(((RoleTO) template).getPasswordPolicy());

                ((RoleTO) attributableTO).setInheritOwner(((RoleTO) template).isInheritOwner());
                ((RoleTO) attributableTO).setInheritAttributes(((RoleTO) template).isInheritAttributes());
                ((RoleTO) attributableTO).setInheritDerivedAttributes(((RoleTO) template).isInheritDerivedAttributes());
                ((RoleTO) attributableTO).setInheritVirtualAttributes(((RoleTO) template).isInheritVirtualAttributes());
                ((RoleTO) attributableTO).setInheritPasswordPolicy(((RoleTO) template).isInheritPasswordPolicy());
                ((RoleTO) attributableTO).setInheritAccountPolicy(((RoleTO) template).isInheritAccountPolicy());
            }

            fillFromTemplate(attributableTO, template);

            for (String resource : template.getResources()) {
                attributableTO.addResource(resource);
            }
        }

        return attributableTO;
View Full Code Here

    @Transactional(readOnly = true)
    public <T extends AbstractAttributableMod> T getAttributableMod(final Long id, final ConnectorObject obj,
            final AbstractAttributableTO original, final SyncTask syncTask, final AttributableUtil attrUtil)
            throws NotFoundException, UnauthorizedRoleException {

        final AbstractAttributableTO updated = getAttributableTOFromConnObject(obj, syncTask, attrUtil);
        updated.setId(id);

        if (AttributableType.USER == attrUtil.getType()) {
            // update password if and only if password is really changed
            final SyncopeUser user = userDataBinder.getUserFromId(id);
            if (StringUtils.isBlank(((UserTO) updated).getPassword())
View Full Code Here

                default:
            }
        }

        // 2. add data from defined template (if any)
        AbstractAttributableTO template = AttributableType.USER == attrUtil.getType()
                ? syncTask.getUserTemplate() : syncTask.getRoleTemplate();

        if (template != null) {
            if (template instanceof UserTO) {
                if (StringUtils.isNotBlank(((UserTO) template).getUsername())) {
                    String evaluated = JexlUtil.evaluate(((UserTO) template).getUsername(), attributableTO);
                    if (StringUtils.isNotBlank(evaluated)) {
                        ((UserTO) attributableTO).setUsername(evaluated);
                    }
                }

                if (StringUtils.isNotBlank(((UserTO) template).getPassword())) {
                    String evaluated = JexlUtil.evaluate(((UserTO) template).getPassword(), attributableTO);
                    if (StringUtils.isNotBlank(evaluated)) {
                        ((UserTO) attributableTO).setPassword(evaluated);
                    }
                }

                Map<Long, MembershipTO> currentMembs = ((UserTO) attributableTO).getMembershipMap();
                for (MembershipTO membTO : ((UserTO) template).getMemberships()) {
                    MembershipTO membTBU;
                    if (currentMembs.containsKey(membTO.getRoleId())) {
                        membTBU = currentMembs.get(membTO.getRoleId());
                    } else {
                        membTBU = new MembershipTO();
                        membTBU.setRoleId(membTO.getRoleId());
                        ((UserTO) attributableTO).addMembership(membTBU);
                    }
                    fillFromTemplate(membTBU, membTO);
                }
            }
            if (template instanceof RoleTO) {
                if (StringUtils.isNotBlank(((RoleTO) template).getName())) {
                    String evaluated = JexlUtil.evaluate(((RoleTO) template).getName(), attributableTO);
                    if (StringUtils.isNotBlank(evaluated)) {
                        ((RoleTO) attributableTO).setName(evaluated);
                    }
                }

                ((RoleTO) attributableTO).setParent(((RoleTO) template).getParent());

                ((RoleTO) attributableTO).setUserOwner(((RoleTO) template).getUserOwner());
                ((RoleTO) attributableTO).setRoleOwner(((RoleTO) template).getRoleOwner());

                ((RoleTO) attributableTO).setEntitlements(((RoleTO) template).getEntitlements());

                ((RoleTO) attributableTO).setAccountPolicy(((RoleTO) template).getAccountPolicy());
                ((RoleTO) attributableTO).setPasswordPolicy(((RoleTO) template).getPasswordPolicy());

                ((RoleTO) attributableTO).setInheritOwner(((RoleTO) template).isInheritOwner());
                ((RoleTO) attributableTO).setInheritAttributes(((RoleTO) template).isInheritAttributes());
                ((RoleTO) attributableTO).setInheritDerivedAttributes(((RoleTO) template).isInheritDerivedAttributes());
                ((RoleTO) attributableTO).setInheritVirtualAttributes(((RoleTO) template).isInheritVirtualAttributes());
                ((RoleTO) attributableTO).setInheritPasswordPolicy(((RoleTO) template).isInheritPasswordPolicy());
                ((RoleTO) attributableTO).setInheritAccountPolicy(((RoleTO) template).isInheritAccountPolicy());
            }

            fillFromTemplate(attributableTO, template);

            for (String resource : template.getResources()) {
                attributableTO.addResource(resource);
            }
        }

        return attributableTO;
View Full Code Here

TOP

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

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.