use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ResourceLogic method check.
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_READ + "')")
@Transactional(readOnly = true)
public void check(final ResourceTO resourceTO) {
ConnInstance connInstance = connInstanceDAO.find(resourceTO.getConnector());
if (connInstance == null) {
throw new NotFoundException("Connector '" + resourceTO.getConnector() + "'");
}
connFactory.createConnector(connFactory.buildConnInstanceOverride(connInstanceDataBinder.getConnInstanceTO(connInstance), resourceTO.getConfOverride(), resourceTO.isOverrideCapabilities() ? resourceTO.getCapabilitiesOverride() : null)).test();
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ConnectorLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_DELETE + "')")
public ConnInstanceTO delete(final String key) {
ConnInstance connInstance = connInstanceDAO.authFind(key);
if (connInstance == null) {
throw new NotFoundException("Connector '" + key + "'");
}
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.CONNECTOR_DELETE), connInstance.getAdminRealm().getFullPath());
securityChecks(effectiveRealms, connInstance.getAdminRealm().getFullPath(), connInstance.getKey());
if (!connInstance.getResources().isEmpty()) {
SyncopeClientException associatedResources = SyncopeClientException.build(ClientExceptionType.AssociatedResources);
connInstance.getResources().forEach(resource -> {
associatedResources.getElements().add(resource.getKey());
});
throw associatedResources;
}
ConnInstanceTO deleted = binder.getConnInstanceTO(connInstance);
connInstanceDAO.delete(key);
return deleted;
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance 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());
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ConnectorLogic method read.
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_READ + "')")
@Transactional(readOnly = true)
public ConnInstanceTO read(final String key, final String lang) {
CurrentLocale.set(StringUtils.isBlank(lang) ? Locale.ENGLISH : new Locale(lang));
ConnInstance connInstance = connInstanceDAO.authFind(key);
if (connInstance == null) {
throw new NotFoundException("Connector '" + key + "'");
}
return binder.getConnInstanceTO(connInstance);
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ResourceTest method createWithPasswordPolicy.
@Test
public void createWithPasswordPolicy() {
final String resourceName = "resourceWithPasswordPolicy";
PasswordPolicy policy = policyDAO.find("986d1236-3ac5-4a19-810c-5ab21d79cba1");
ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
resource.setKey(resourceName);
resource.setPasswordPolicy(policy);
ConnInstance connector = connInstanceDAO.find("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
assertNotNull(connector);
resource.setConnector(connector);
ExternalResource actual = resourceDAO.save(resource);
assertNotNull(actual);
actual = resourceDAO.find(actual.getKey());
assertNotNull(actual);
assertNotNull(actual.getPasswordPolicy());
resourceDAO.delete(resourceName);
assertNull(resourceDAO.find(resourceName));
assertNotNull(policyDAO.find("986d1236-3ac5-4a19-810c-5ab21d79cba1"));
}
Aggregations