Search in sources :

Example 16 with ConnConfProperty

use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.

the class ConnectorRestClient method getExtAttrNames.

public List<String> getExtAttrNames(final String adminRealm, final String objectClass, final String connectorKey, final Collection<ConnConfProperty> conf) {
    ConnInstanceTO connInstanceTO = new ConnInstanceTO();
    connInstanceTO.setAdminRealm(adminRealm);
    connInstanceTO.setKey(connectorKey);
    connInstanceTO.getConf().addAll(conf);
    // SYNCOPE-156: use provided info to give schema names (and type!) by ObjectClass
    Optional<ConnIdObjectClassTO> connIdObjectClass = buildObjectClassInfo(connInstanceTO, false).stream().filter(object -> object.getType().equalsIgnoreCase(objectClass)).findAny();
    return connIdObjectClass.isPresent() ? connIdObjectClass.get().getAttributes() : new ArrayList<>();
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Collection(java.util.Collection) SyncopeConsoleSession(org.apache.syncope.client.console.SyncopeConsoleSession) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) List(java.util.List) Response(javax.ws.rs.core.Response) Pair(org.apache.commons.lang3.tuple.Pair) Optional(java.util.Optional) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) Collections(java.util.Collections) ConnBundleTO(org.apache.syncope.common.lib.to.ConnBundleTO) BeanUtils(org.springframework.beans.BeanUtils) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO)

Example 17 with ConnConfProperty

use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.

the class ConnectorRestClient method create.

public ConnInstanceTO create(final ConnInstanceTO connectorTO) {
    List<ConnConfProperty> filteredConf = filterProperties(connectorTO.getConf());
    connectorTO.getConf().clear();
    connectorTO.getConf().addAll(filteredConf);
    ConnectorService service = getService(ConnectorService.class);
    Response response = service.create(connectorTO);
    return getObject(service, response.getLocation(), ConnInstanceTO.class);
}
Also used : Response(javax.ws.rs.core.Response) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService)

Example 18 with ConnConfProperty

use of org.apache.syncope.common.lib.types.ConnConfProperty in project syncope by apache.

the class ConnConfPropertyListView method populateItem.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void populateItem(final ListItem<ConnConfProperty> item) {
    final ConnConfProperty property = item.getModelObject();
    final String label = StringUtils.isBlank(property.getSchema().getDisplayName()) ? property.getSchema().getName() : property.getSchema().getDisplayName();
    final FieldPanel<? extends Serializable> field;
    boolean required = false;
    boolean isArray = false;
    if (property.getSchema().isConfidential() || Constants.GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType()) || Constants.GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) {
        field = new AjaxPasswordFieldPanel("panel", label, new Model<>(), false);
        ((PasswordTextField) field.getField()).setResetPassword(false);
        required = property.getSchema().isRequired();
    } else {
        Class<?> propertySchemaClass;
        try {
            propertySchemaClass = ClassUtils.getClass(property.getSchema().getType());
            if (ClassUtils.isPrimitiveOrWrapper(propertySchemaClass)) {
                propertySchemaClass = org.apache.commons.lang3.ClassUtils.primitiveToWrapper(propertySchemaClass);
            }
        } catch (ClassNotFoundException e) {
            LOG.error("Error parsing attribute type", e);
            propertySchemaClass = String.class;
        }
        if (ClassUtils.isAssignable(Number.class, propertySchemaClass)) {
            @SuppressWarnings("unchecked") Class<Number> numberClass = (Class<Number>) propertySchemaClass;
            field = new AjaxSpinnerFieldPanel.Builder<>().build("panel", label, numberClass, new Model<>());
            required = property.getSchema().isRequired();
        } else if (ClassUtils.isAssignable(Boolean.class, propertySchemaClass)) {
            field = new AjaxCheckBoxPanel("panel", label, new Model<>());
        } else {
            field = new AjaxTextFieldPanel("panel", label, new Model<>());
            required = property.getSchema().isRequired();
        }
        if (propertySchemaClass.isArray()) {
            isArray = true;
        }
    }
    field.setIndex(item.getIndex());
    field.setTitle(property.getSchema().getHelpMessage(), true);
    final AbstractFieldPanel<? extends Serializable> fieldPanel;
    if (isArray) {
        final MultiFieldPanel multiFieldPanel = new MultiFieldPanel.Builder(new PropertyModel<>(property, "values")).setEventTemplate(true).build("panel", label, field);
        item.add(multiFieldPanel);
        fieldPanel = multiFieldPanel;
    } else {
        setNewFieldModel(field, property.getValues());
        item.add(field);
        fieldPanel = field;
    }
    if (required) {
        fieldPanel.addRequiredLabel();
    }
    if (withOverridable) {
        fieldPanel.showExternAction(addCheckboxToggle(property));
    }
}
Also used : AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) AjaxCheckBoxPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel) AjaxPasswordFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxPasswordFieldPanel) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel)

Aggregations

ConnConfProperty (org.apache.syncope.common.lib.types.ConnConfProperty)18 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)13 Test (org.junit.jupiter.api.Test)12 HashSet (java.util.HashSet)9 Response (javax.ws.rs.core.Response)9 ConnConfPropSchema (org.apache.syncope.common.lib.types.ConnConfPropSchema)8 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)7 ConnectorService (org.apache.syncope.common.rest.api.service.ConnectorService)6 GuardedString (org.identityconnectors.common.security.GuardedString)6 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)5 IOException (java.io.IOException)4 Collection (java.util.Collection)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 ConnBundleTO (org.apache.syncope.common.lib.to.ConnBundleTO)3 ConnIdObjectClassTO (org.apache.syncope.common.lib.to.ConnIdObjectClassTO)3 ConnPoolConfTO (org.apache.syncope.common.lib.to.ConnPoolConfTO)3 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Optional (java.util.Optional)2