Package org.apache.syncope.core.util

Examples of org.apache.syncope.core.util.AttributableUtil


    @PreAuthorize("hasRole('SCHEMA_UPDATE')")
    public <T extends AbstractSchemaTO> void update(final AttributableType attrType, final SchemaType schemaType,
            final T schemaTO) {

        final AttributableUtil attrUtil = AttributableUtil.getInstance(attrType);

        if (!doesSchemaExist(schemaType, schemaTO.getName(), attrUtil)) {
            throw new NotFoundException(schemaType + "/" + attrType + "/" + schemaTO.getName());
        }

        switch (schemaType) {
            case VIRTUAL:
                AbstractVirSchema virSchema = virSchemaDAO.find(schemaTO.getName(), attrUtil.virSchemaClass());
                if (virSchema == null) {
                    throw new NotFoundException("Virtual Schema '" + schemaTO.getName() + "'");
                }

                binder.update((VirSchemaTO) schemaTO, virSchema);
                virSchemaDAO.save(virSchema);
                break;

            case DERIVED:
                AbstractDerSchema derSchema = derSchemaDAO.find(schemaTO.getName(), attrUtil.derSchemaClass());
                if (derSchema == null) {
                    throw new NotFoundException("Derived schema '" + schemaTO.getName() + "'");
                }

                binder.update((DerSchemaTO) schemaTO, derSchema);
                derSchemaDAO.save(derSchema);
                break;

            case NORMAL:
            default:
                AbstractNormalSchema schema = schemaDAO.find(schemaTO.getName(), attrUtil.schemaClass());
                if (schema == null) {
                    throw new NotFoundException("Schema '" + schemaTO.getName() + "'");
                }

                binder.update((SchemaTO) schemaTO, schema, attrUtil);
View Full Code Here


            }
        }

        if (name != null) {
            try {
                final AttributableUtil attrUtil = AttributableUtil.valueOf(kind);
                return binder.getSchemaTO(schemaDAO.find(name, attrUtil.schemaClass()), attrUtil);
            } catch (Throwable ignore) {
                LOG.debug("Unresolved reference", ignore);
                throw new UnresolvedReferenceException(ignore);
            }
        }
View Full Code Here

     * @throws JobExecutionException in case of synchronization failure.
     */
    protected final void doHandle(final SyncDelta delta, final Collection<SyncResult> syncResults)
            throws JobExecutionException {

        final AttributableUtil attrUtil = getAttributableUtil();

        LOG.debug("Process {} for {} as {}",
                delta.getDeltaType(), delta.getUid().getUidValue(), delta.getObject().getObjectClass());

        final String uid = delta.getPreviousUid() == null
View Full Code Here

    }

    private OrderBySupport parseOrderBy(final SubjectType type, final SearchSupport svs,
            final List<OrderByClause> orderByClauses) {

        final AttributableUtil attrUtil = AttributableUtil.getInstance(type.asAttributableType());

        OrderBySupport orderBySupport = new OrderBySupport();

        for (OrderByClause clause : orderByClauses) {
            OrderBySupport.Item obs = new OrderBySupport.Item();

            Field subjectField = ReflectionUtils.findField(attrUtil.attributableClass(), clause.getField());
            if (subjectField == null) {
                AbstractNormalSchema schema = schemaDAO.find(clause.getField(), attrUtil.schemaClass());
                if (schema != null) {
                    if (schema.isUniqueConstraint()) {
                        orderBySupport.views.add(svs.uniqueAttr());

                        obs.select = new StringBuilder().
View Full Code Here

    }

    private String getQuery(final AttributeCond cond, final boolean not, final List<Object> parameters,
            final SubjectType type, final SearchSupport svs) {

        final AttributableUtil attrUtil = AttributableUtil.getInstance(type.asAttributableType());

        AbstractNormalSchema schema = schemaDAO.find(cond.getSchema(), attrUtil.schemaClass());
        if (schema == null) {
            LOG.warn("Ignoring invalid schema '{}'", cond.getSchema());
            return EMPTY_ATTR_QUERY;
        }

        AbstractAttrValue attrValue = attrUtil.newAttrValue();
        try {
            if (cond.getType() != AttributeCond.Type.LIKE && cond.getType() != AttributeCond.Type.ISNULL
                    && cond.getType() != AttributeCond.Type.ISNOTNULL) {

                schema.getValidator().validate(cond.getExpression(), attrValue);
View Full Code Here

    @SuppressWarnings("rawtypes")
    private String getQuery(final SubjectCond cond, final boolean not, final List<Object> parameters,
            final SubjectType type, final SearchSupport svs) {

        final AttributableUtil attrUtil = AttributableUtil.getInstance(type.asAttributableType());

        Field subjectField = ReflectionUtils.findField(attrUtil.attributableClass(), cond.getSchema());
        if (subjectField == null) {
            LOG.warn("Ignoring invalid schema '{}'", cond.getSchema());
            return EMPTY_ATTR_QUERY;
        }

        AbstractNormalSchema schema = attrUtil.newSchema();
        schema.setName(subjectField.getName());
        for (AttributeSchemaType attrSchemaType : AttributeSchemaType.values()) {
            if (subjectField.getType().isAssignableFrom(attrSchemaType.getType())) {
                schema.setType(attrSchemaType);
            }
        }

        // Deal with subject Integer fields logically mapping to boolean values
        // (SyncopeRole.inheritAttrs, for example)
        boolean foundBooleanMin = false;
        boolean foundBooleanMax = false;
        if (Integer.class.equals(subjectField.getType())) {
            for (Annotation annotation : subjectField.getAnnotations()) {
                if (Min.class.equals(annotation.annotationType())) {
                    foundBooleanMin = ((Min) annotation).value() == 0;
                } else if (Max.class.equals(annotation.annotationType())) {
                    foundBooleanMax = ((Max) annotation).value() == 1;
                }
            }
        }
        if (foundBooleanMin && foundBooleanMax) {
            schema.setType(AttributeSchemaType.Boolean);
        }

        // Deal with subject fields representing relationships to other entities
        // Only _id and _name are suppored
        if (subjectField.getType().getAnnotation(Entity.class) != null) {
            if (BeanUtils.findDeclaredMethodWithMinimalParameters(subjectField.getType(), "getId") != null) {
                cond.setSchema(cond.getSchema() + "_id");
                schema.setType(AttributeSchemaType.Long);
            }
            if (BeanUtils.findDeclaredMethodWithMinimalParameters(subjectField.getType(), "getName") != null) {
                cond.setSchema(cond.getSchema() + "_name");
                schema.setType(AttributeSchemaType.String);
            }
        }

        AbstractAttrValue attrValue = attrUtil.newAttrValue();
        if (cond.getType() != AttributeCond.Type.LIKE && cond.getType() != AttributeCond.Type.ISNULL
                && cond.getType() != AttributeCond.Type.ISNOTNULL) {

            try {
                schema.getValidator().validate(cond.getExpression(), attrValue);
View Full Code Here

                : roleDAO.find(id);
        if (subject == null) {
            throw new NotFoundException(type + " " + id);
        }

        final AttributableUtil attrUtil = AttributableUtil.getInstance(type.asAttributableType());

        AbstractMappingItem accountIdItem = attrUtil.getAccountIdItem(resource);
        if (accountIdItem == null) {
            throw new NotFoundException("AccountId mapping for " + type + " " + id + " on resource '" + resourceName
                    + "'");
        }
        final String accountIdValue = MappingUtil.getAccountIdValue(
                subject, resource, attrUtil.getAccountIdItem(resource));

        final ObjectClass objectClass = SubjectType.USER == type ? ObjectClass.ACCOUNT : ObjectClass.GROUP;

        final Connector connector = connFactory.getConnector(resource);
        final ConnectorObject connectorObject = connector.getObject(objectClass, new Uid(accountIdValue),
                connector.getOperationOptions(attrUtil.getMappingItems(resource, MappingPurpose.BOTH)));
        if (connectorObject == null) {
            throw new NotFoundException("Object " + accountIdValue + " with class " + objectClass
                    + "not found on resource " + resourceName);
        }
View Full Code Here

            profile.setResults(new ArrayList<SyncResult>());
        }

        final AbstractSubject toBeHandled = getSubject(subject.getId());

        final AttributableUtil attrUtil = AttributableUtil.getInstance(toBeHandled);

        final SyncResult result = new SyncResult();
        profile.getResults().add(result);

        result.setId(toBeHandled.getId());
        result.setSubjectType(attrUtil.getType());
        result.setName(getName(toBeHandled));

        final Boolean enabled = toBeHandled instanceof SyncopeUser && profile.getSyncTask().isSyncStatus()
                ? ((SyncopeUser) toBeHandled).isSuspended() ? Boolean.FALSE : Boolean.TRUE
                : null;

        LOG.debug("Propagating {} with ID {} towards {}",
                attrUtil.getType(), toBeHandled.getId(), profile.getSyncTask().getResource());

        Object output = null;
        Result resultStatus = null;
        ConnectorObject beforeObj = null;
        String operation = null;
View Full Code Here

    protected boolean authenticate(final SyncopeUser user, final String password) {
        boolean authenticated = encryptor.verify(password, user.getCipherAlgorithm(), user.getPassword());
        LOG.debug("{} authenticated on internal storage: {}", user.getUsername(), authenticated);

        final AttributableUtil attrUtil = AttributableUtil.getInstance(AttributableType.USER);
        for (Iterator<ExternalResource> itor = getPassthroughResources(user).iterator();
                itor.hasNext() && !authenticated;) {

            ExternalResource resource = itor.next();
            String accountId = null;
            try {
                accountId = MappingUtil.getAccountIdValue(user, resource, attrUtil.getAccountIdItem(resource));
                Uid uid = connFactory.getConnector(resource).authenticate(accountId, password, null);
                if (uid != null) {
                    authenticated = true;
                }
            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.util.AttributableUtil

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.