Search in sources :

Example 1 with ConnIdObjectClassTO

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

the class ConnectorITCase method buildObjectClassInfo.

@Test
public void buildObjectClassInfo() {
    ConnInstanceTO ws = connectorService.read("5ffbb4ac-a8c3-4b44-b699-11b398a1ba08", Locale.ENGLISH.getLanguage());
    assertNotNull(ws);
    List<ConnIdObjectClassTO> objectClassInfo = connectorService.buildObjectClassInfo(ws, true);
    assertNotNull(objectClassInfo);
    assertEquals(1, objectClassInfo.size());
    assertEquals(ObjectClass.ACCOUNT_NAME, objectClassInfo.get(0).getType());
    assertTrue(objectClassInfo.get(0).getAttributes().contains("promoThirdPartyDisclaimer"));
    ConnInstanceTO ldap = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", Locale.ENGLISH.getLanguage());
    assertNotNull(ldap);
    objectClassInfo = connectorService.buildObjectClassInfo(ldap, true);
    assertNotNull(objectClassInfo);
    Collection<String> objectClasses = objectClassInfo.stream().map(info -> info.getType()).collect(Collectors.toSet());
    assertTrue(objectClasses.contains(ObjectClass.ACCOUNT_NAME));
    assertTrue(objectClasses.contains(ObjectClass.GROUP_NAME));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) SerializationUtils(org.apache.commons.lang3.SerializationUtils) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) HashSet(java.util.HashSet) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) GuardedString(org.identityconnectors.common.security.GuardedString) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) Locale(java.util.Locale) ItemTO(org.apache.syncope.common.lib.to.ItemTO) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AbstractITCase(org.apache.syncope.fit.AbstractITCase) EnumSet(java.util.EnumSet) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) Properties(java.util.Properties) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) MappingTO(org.apache.syncope.common.lib.to.MappingTO) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) UUID(java.util.UUID) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) Response(javax.ws.rs.core.Response) ConnectorCapability(org.apache.syncope.common.lib.types.ConnectorCapability) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) InputStream(java.io.InputStream) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) ConnBundleTO(org.apache.syncope.common.lib.to.ConnBundleTO) ConnPoolConfTO(org.apache.syncope.common.lib.to.ConnPoolConfTO) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) GuardedString(org.identityconnectors.common.security.GuardedString) Test(org.junit.jupiter.api.Test)

Example 2 with ConnIdObjectClassTO

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

the class ConnectorLogic method buildObjectClassInfo.

@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_READ + "')")
public List<ConnIdObjectClassTO> buildObjectClassInfo(final ConnInstanceTO connInstanceTO, final boolean includeSpecial) {
    ConnInstanceTO actual = connInstanceTO;
    ConnInstance existing = connInstanceDAO.find(connInstanceTO.getKey());
    if (existing != null) {
        actual = binder.getConnInstanceTO(existing);
    }
    Set<ObjectClassInfo> objectClassInfo = connFactory.createConnector(connFactory.buildConnInstanceOverride(actual, connInstanceTO.getConf(), null)).getObjectClassInfo();
    return objectClassInfo.stream().map(info -> {
        ConnIdObjectClassTO connIdObjectClassTO = new ConnIdObjectClassTO();
        connIdObjectClassTO.setType(info.getType());
        connIdObjectClassTO.setAuxiliary(info.isAuxiliary());
        connIdObjectClassTO.setContainer(info.isContainer());
        connIdObjectClassTO.getAttributes().addAll(info.getAttributeInfo().stream().filter(attrInfo -> includeSpecial || !AttributeUtil.isSpecialName(attrInfo.getName())).map(AttributeInfo::getName).collect(Collectors.toList()));
        return connIdObjectClassTO;
    }).collect(Collectors.toList());
}
Also used : StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Autowired(org.springframework.beans.factory.annotation.Autowired) ArrayUtils(org.apache.commons.lang3.ArrayUtils) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) StringUtils(org.apache.commons.lang3.StringUtils) ConnInstanceDataBinder(org.apache.syncope.core.provisioning.api.data.ConnInstanceDataBinder) ArrayList(java.util.ArrayList) RealmUtils(org.apache.syncope.core.provisioning.api.utils.RealmUtils) DelegatedAdministrationException(org.apache.syncope.core.spring.security.DelegatedAdministrationException) Locale(java.util.Locale) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) AuthContextUtils(org.apache.syncope.core.spring.security.AuthContextUtils) Method(java.lang.reflect.Method) AttributeInfo(org.identityconnectors.framework.common.objects.AttributeInfo) ConnectorKey(org.identityconnectors.framework.api.ConnectorKey) Set(java.util.Set) ConnInstanceDAO(org.apache.syncope.core.persistence.api.dao.ConnInstanceDAO) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) Collectors(java.util.stream.Collectors) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) CurrentLocale(org.identityconnectors.common.l10n.CurrentLocale) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) List(java.util.List) ObjectClassInfo(org.identityconnectors.framework.common.objects.ObjectClassInfo) Component(org.springframework.stereotype.Component) AttributeUtil(org.identityconnectors.framework.common.objects.AttributeUtil) ConnIdBundleManager(org.apache.syncope.core.provisioning.api.ConnIdBundleManager) ConnectorFactory(org.apache.syncope.core.provisioning.api.ConnectorFactory) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ExternalResourceDAO(org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO) ConnBundleTO(org.apache.syncope.common.lib.to.ConnBundleTO) Transactional(org.springframework.transaction.annotation.Transactional) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) ObjectClassInfo(org.identityconnectors.framework.common.objects.ObjectClassInfo) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with ConnIdObjectClassTO

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

the class VirSchemaDetails method getExtAttrNames.

private List<String> getExtAttrNames() {
    ConnInstanceTO connInstanceTO = new ConnInstanceTO();
    connInstanceTO.setKey(selectedResource.getConnector());
    connInstanceTO.getConf().addAll(selectedResource.getConfOverride());
    Optional<ConnIdObjectClassTO> connIdObjectClass = connRestClient.buildObjectClassInfo(connInstanceTO, false).stream().filter(object -> object.getType().equals(anyTypes.get(anyType.getModelObject()))).findAny();
    return connIdObjectClass.isPresent() ? connIdObjectClass.get().getAttributes() : Collections.<String>emptyList();
}
Also used : StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) Constants(org.apache.syncope.client.console.commons.Constants) HashMap(java.util.HashMap) SyncopeConsoleSession(org.apache.syncope.client.console.SyncopeConsoleSession) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) PageReference(org.apache.wicket.PageReference) Collectors(java.util.stream.Collectors) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) ArrayList(java.util.ArrayList) List(java.util.List) AjaxCheckBoxPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel) EntityTO(org.apache.syncope.common.lib.to.EntityTO) PropertyModel(org.apache.wicket.model.PropertyModel) Map(java.util.Map) IndicatorAjaxFormComponentUpdatingBehavior(org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormComponentUpdatingBehavior) Optional(java.util.Optional) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnectorRestClient(org.apache.syncope.client.console.rest.ConnectorRestClient) Collections(java.util.Collections) ResourceRestClient(org.apache.syncope.client.console.rest.ResourceRestClient) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO)

Example 4 with ConnIdObjectClassTO

use of org.apache.syncope.common.lib.to.ConnIdObjectClassTO 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)

Aggregations

List (java.util.List)4 Collectors (java.util.stream.Collectors)4 ConnIdObjectClassTO (org.apache.syncope.common.lib.to.ConnIdObjectClassTO)4 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)4 ArrayList (java.util.ArrayList)3 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 ConnBundleTO (org.apache.syncope.common.lib.to.ConnBundleTO)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Locale (java.util.Locale)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Response (javax.ws.rs.core.Response)2 SyncopeConsoleSession (org.apache.syncope.client.console.SyncopeConsoleSession)2 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)2 ClientExceptionType (org.apache.syncope.common.lib.types.ClientExceptionType)2 StandardEntitlement (org.apache.syncope.common.lib.types.StandardEntitlement)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1