use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class MappingTest method anyConnObjectLink.
@Test
public void anyConnObjectLink() {
ExternalResource ldap = resourceDAO.find("resource-ldap");
assertNotNull(ldap);
Provision provision = ldap.getProvision(anyTypeDAO.findUser()).get();
assertNotNull(provision);
assertNotNull(provision.getMapping());
assertNotNull(provision.getMapping().getConnObjectLink());
User user = userDAO.findByUsername("rossini");
assertNotNull(user);
Name name = MappingUtils.evaluateNAME(user, provision, user.getUsername());
assertEquals("uid=rossini,ou=people,o=isp", name.getNameValue());
provision.getMapping().setConnObjectLink("'uid=' + username + realm.replaceAll('/', ',o=') + ',ou=people,o=isp'");
name = MappingUtils.evaluateNAME(user, provision, user.getUsername());
assertEquals("uid=rossini,o=even,ou=people,o=isp", name.getNameValue());
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class TaskDataBinderImpl method createSchedTask.
@Override
public SchedTask createSchedTask(final SchedTaskTO taskTO, final TaskUtils taskUtils) {
Class<? extends TaskTO> taskTOClass = taskUtils.taskTOClass();
if (taskTOClass == null || !taskTOClass.equals(taskTO.getClass())) {
throw new IllegalArgumentException(String.format("Expected %s, found %s", taskTOClass, taskTO.getClass()));
}
SchedTask task = taskUtils.newTask();
task.setStartAt(taskTO.getStartAt());
task.setCronExpression(taskTO.getCronExpression());
task.setName(taskTO.getName());
task.setDescription(taskTO.getDescription());
task.setActive(taskTO.isActive());
if (taskUtils.getType() == TaskType.SCHEDULED) {
Implementation implementation = implementationDAO.find(taskTO.getJobDelegate());
if (implementation == null) {
throw new NotFoundException("Implementation " + taskTO.getJobDelegate());
}
task.setJobDelegate(implementation);
} else if (taskTO instanceof ProvisioningTaskTO) {
ProvisioningTaskTO provisioningTaskTO = (ProvisioningTaskTO) taskTO;
ExternalResource resource = resourceDAO.find(provisioningTaskTO.getResource());
if (resource == null) {
throw new NotFoundException("Resource " + provisioningTaskTO.getResource());
}
((ProvisioningTask) task).setResource(resource);
fill((ProvisioningTask) task, provisioningTaskTO);
}
return task;
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class AuthDataAccessor method authenticate.
protected boolean authenticate(final User user, final String password) {
boolean authenticated = ENCRYPTOR.verify(password, user.getCipherAlgorithm(), user.getPassword());
LOG.debug("{} authenticated on internal storage: {}", user.getUsername(), authenticated);
for (Iterator<? extends ExternalResource> itor = getPassthroughResources(user).iterator(); itor.hasNext() && !authenticated; ) {
ExternalResource resource = itor.next();
String connObjectKey = null;
try {
connObjectKey = mappingManager.getConnObjectKeyValue(user, resource.getProvision(anyTypeDAO.findUser()).get()).get();
Uid uid = connFactory.getConnector(resource).authenticate(connObjectKey, password, null);
if (uid != null) {
authenticated = true;
}
} catch (Exception e) {
LOG.debug("Could not authenticate {} on {}", user.getUsername(), resource.getKey(), e);
}
LOG.debug("{} authenticated on {} as {}: {}", user.getUsername(), resource.getKey(), connObjectKey, authenticated);
}
return authenticated;
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class ResourceLogic method connObjectInit.
private Triple<ExternalResource, AnyType, Provision> connObjectInit(final String resourceKey, final String anyTypeKey) {
ExternalResource resource = resourceDAO.authFind(resourceKey);
if (resource == null) {
throw new NotFoundException("Resource '" + resourceKey + "'");
}
AnyType anyType = anyTypeDAO.find(anyTypeKey);
if (anyType == null) {
throw new NotFoundException("AnyType '" + anyTypeKey + "'");
}
Optional<? extends Provision> provision = resource.getProvision(anyType);
if (!provision.isPresent()) {
throw new NotFoundException("Provision on resource '" + resourceKey + "' for type '" + anyTypeKey + "'");
}
return ImmutableTriple.of(resource, anyType, provision.get());
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class ConnectorLogic method readByResource.
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_READ + "')")
@Transactional(readOnly = true)
public ConnInstanceTO readByResource(final String resourceName, final String lang) {
CurrentLocale.set(StringUtils.isBlank(lang) ? Locale.ENGLISH : new Locale(lang));
ExternalResource resource = resourceDAO.find(resourceName);
if (resource == null) {
throw new NotFoundException("Resource '" + resourceName + "'");
}
ConnInstanceTO connInstance = binder.getConnInstanceTO(connFactory.getConnector(resource).getConnInstance());
connInstance.setKey(resource.getConnector().getKey());
return connInstance;
}
Aggregations