@Transactional(readOnly = true) @Override public void before(final PropagationTask task, final ConnectorObject beforeObj) { if (AnyTypeKind.USER == task.getAnyTypeKind()) { User user = userDAO.find(task.getEntityKey()); if (user != null && user.getPassword() != null) { Attribute missing = AttributeUtil.find( PropagationTaskExecutor.MANDATORY_MISSING_ATTR_NAME, task.getAttributes()); ConnInstance connInstance = task.getResource().getConnector(); if (missing != null && missing.getValue() != null && missing.getValue().size() == 1 && missing.getValue().get(0).equals(OperationalAttributes.PASSWORD_NAME) && cipherAlgorithmMatches(getCipherAlgorithm(connInstance), user.getCipherAlgorithm())) { Attribute passwordAttribute = AttributeBuilder.buildPassword( new GuardedString(user.getPassword().toCharArray())); Set<Attribute> attributes = new HashSet<>(task.getAttributes()); attributes.add(passwordAttribute); attributes.remove(missing); Attribute hashedPasswordAttribute = AttributeBuilder.build( AttributeUtil.createSpecialName("HASHED_PASSWORD"), Boolean.TRUE); attributes.add(hashedPasswordAttribute); task.setAttributes(attributes); } } } }
isValid = true; } else { isValid = task.getOperation() != null && !task.getAttributes().isEmpty() && task.getResource() != null; List<? extends TaskExec> executions = task.getExecs(); for (TaskExec execution : executions) { try {
LOG.debug("{} not found on external resource: ignoring delete", task.getConnObjectKey()); result = null; } else { if (task.getEntityKey() != null && task.getAnyTypeKind() != null) { switch (task.getAnyTypeKind()) { case USER: try { resources = userDAO.findAllResourceKeys(task.getEntityKey()); } catch (Exception e) { LOG.error("Could not read user {}", task.getEntityKey(), e); resources = groupDAO.findAllResourceKeys(task.getEntityKey()); } catch (Exception e) { LOG.error("Could not read group {}", task.getEntityKey(), e); default: try { resources = anyObjectDAO.findAllResourceKeys(task.getEntityKey()); } catch (Exception e) { LOG.error("Could not read any object {}", task.getEntityKey(), e); if (task.getAnyTypeKind() == null || !resources.contains(task.getResource().getKey())) { LOG.debug("Delete {} on {}", beforeObj.getUid(), task.getResource().getKey());
@Transactional @Override public void before(final PropagationTask task, final ConnectorObject beforeObj) { if (task.getOperation() == ResourceOperation.DELETE || task.getOperation() == ResourceOperation.NONE) { return; } switch (task.getAnyTypeKind()) { case USER: setName(task); break; case GROUP: setName(task); break; default: LOG.debug("Not about user or group: not doing anything"); } }
@Transactional @Override public void before(final PropagationTask task, final ConnectorObject beforeObj) { if (task.getOperation() == ResourceOperation.DELETE || task.getOperation() == ResourceOperation.NONE) { return; } if (AnyTypeKind.USER != task.getAnyTypeKind()) { return; } Set<Attribute> attrs = new HashSet<>(task.getAttributes()); if (AttributeUtil.find(getEmailAttrName(), attrs) == null) { LOG.warn("Can't find {} attribute to set as __NAME__ attribute value, skipping...", getEmailAttrName()); return; } Name name = AttributeUtil.getNameFromAttributes(attrs); if (name != null) { attrs.remove(name); } attrs.add(new Name(AttributeUtil.find(getEmailAttrName(), attrs).getValue().get(0).toString())); task.setAttributes(attrs); } }
if (taskInfo.getKey() == null) { task = entityFactory.newEntity(PropagationTask.class); task.setResource(resourceDAO.find(taskInfo.getResource())); task.setObjectClassName(taskInfo.getObjectClassName()); task.setAnyTypeKind(taskInfo.getAnyTypeKind()); task.setAnyType(taskInfo.getAnyType()); task.setEntityKey(taskInfo.getEntityKey()); task.setOperation(taskInfo.getOperation()); task.setConnObjectKey(taskInfo.getConnObjectKey()); task.setOldConnObjectKey(taskInfo.getOldConnObjectKey()); } else { task = taskDAO.find(taskInfo.getKey()); task.setAttributes(attributes); List<PropagationActions> actions = getPropagationActions(task.getResource()); String resource = task.getResource().getKey(); Result result; try { provision = task.getResource().getProvision(new ObjectClass(task.getObjectClassName())).orElse(null); orgUnit = task.getResource().getOrgUnit(); connector = connFactory.getConnector(task.getResource()); switch (task.getOperation()) { case CREATE: case UPDATE:
PropagationTaskTO propagationTaskTO = (PropagationTaskTO) taskTO; propagationTaskTO.setOperation(propagationTask.getOperation()); propagationTaskTO.setConnObjectKey(propagationTask.getConnObjectKey()); propagationTaskTO.setOldConnObjectKey(propagationTask.getOldConnObjectKey()); propagationTaskTO.setAttributes(propagationTask.getSerializedAttributes()); propagationTaskTO.setResource(propagationTask.getResource().getKey()); propagationTaskTO.setObjectClassName(propagationTask.getObjectClassName()); propagationTaskTO.setAnyTypeKind(propagationTask.getAnyTypeKind()); propagationTaskTO.setAnyType(propagationTask.getAnyType()); propagationTaskTO.setEntityKey(propagationTask.getEntityKey()); break;
Set<Attribute> attributes = new HashSet<>(task.getAttributes()); Attribute mandatoryMissing = AttributeUtil.find(MANDATORY_MISSING_ATTR_NAME, task.getAttributes()); if (mandatoryMissing != null) { attributes.remove(mandatoryMissing); Attribute mandatoryNullOrEmpty = AttributeUtil.find(MANDATORY_NULL_OR_EMPTY_ATTR_NAME, task.getAttributes()); if (mandatoryNullOrEmpty != null) { attributes.remove(mandatoryNullOrEmpty); LOG.debug("Create {} on {}", attributes, task.getResource().getKey()); result = connector.create( new ObjectClass(task.getObjectClassName()), attributes, null, propagationAttempted); task.getResource().getProvision(task.getAnyType()).ifPresent(provision -> { if (provision.getUidOnCreate() != null) { anyUtilsFactory.getInstance(task.getAnyTypeKind()). addAttr(task.getEntityKey(), provision.getUidOnCreate(), result.getUidValue()); LOG.debug("Update {} on {}", strictlyModified, task.getResource().getKey());
final boolean latest) { String connObjectKey = latest || task.getOldConnObjectKey() == null ? task.getConnObjectKey() : task.getOldConnObjectKey(); try { obj = connector.getObject( new ObjectClass(task.getObjectClassName()), AttributeBuilder.build(connObjectKeyItem.get().getExtAttrName(), connObjectKey), provision.isIgnoreCaseMatch(), Attribute attr = obj.getAttributeByName(item.getExtAttrName()); if (attr == null) { virAttrCache.expire(task.getAnyType(), task.getEntityKey(), item.getIntAttrName()); } else { VirAttrCacheValue cacheValue = new VirAttrCacheValue(); cacheValue.setValues(attr.getValue()); virAttrCache.put(task.getAnyType(), task.getEntityKey(), item.getIntAttrName(), cacheValue);
/** * Check whether an execution has to be stored, for a given task. * * @param task propagation task * @param execution to be decide whether to store or not * @return true if execution has to be store, false otherwise */ protected boolean hasToBeregistered(final PropagationTask task, final TaskExec execution) { boolean result; boolean failed = ExecStatus.valueOf(execution.getStatus()) != ExecStatus.SUCCESS; switch (task.getOperation()) { case CREATE: result = (failed && task.getResource().getCreateTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal()) || task.getResource().getCreateTraceLevel() == TraceLevel.ALL; break; case UPDATE: result = (failed && task.getResource().getUpdateTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal()) || task.getResource().getUpdateTraceLevel() == TraceLevel.ALL; break; case DELETE: result = (failed && task.getResource().getDeleteTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal()) || task.getResource().getDeleteTraceLevel() == TraceLevel.ALL; break; default: result = false; } return result; }
private void setName(final PropagationTask task) { Set<Attribute> attrs = new HashSet<>(task.getAttributes()); if (AttributeUtil.find(getEmailAttrName(), attrs) == null) { LOG.warn("Can't find {} attribute to set as __NAME__ attribute value, skipping...", getEmailAttrName()); return; } Name name = AttributeUtil.getNameFromAttributes(attrs); if (name != null) { attrs.remove(name); } attrs.add(new Name(AttributeUtil.find(getEmailAttrName(), attrs).getValue().get(0).toString())); task.setAttributes(attrs); } }
final boolean latest) { String connObjectKey = latest || task.getOldConnObjectKey() == null ? task.getConnObjectKey() : task.getOldConnObjectKey(); if (connObjectKeyItem.isPresent()) { try { obj = connector.getObject(new ObjectClass(task.getObjectClassName()), AttributeBuilder.build(connObjectKeyItem.get().getExtAttrName(), connObjectKey), orgUnit.isIgnoreCaseMatch(),
@Override public String buildRefDesc(final Task task) { return taskUtilsFactory.getInstance(task).getType().name() + " " + "Task " + task.getKey() + " " + (task instanceof SchedTask ? SchedTask.class.cast(task).getName() : task instanceof PropagationTask ? PropagationTask.class.cast(task).getConnObjectKey() : StringUtils.EMPTY); }
@Transactional(readOnly = true) @Override public void before(final PropagationTask task, final ConnectorObject beforeObj) { if (AnyTypeKind.USER == task.getAnyTypeKind()) { User user = userDAO.find(task.getEntityKey()); if (user != null && user.getPassword() != null) { Attribute missing = AttributeUtil.find( PropagationTaskExecutor.MANDATORY_MISSING_ATTR_NAME, task.getAttributes()); ConnInstance connInstance = task.getResource().getConnector(); String cipherAlgorithm = getCipherAlgorithm(connInstance); if (missing != null && missing.getValue() != null && missing.getValue().size() == 1 && missing.getValue().get(0).equals(OperationalAttributes.PASSWORD_NAME) && cipherAlgorithmMatches(getCipherAlgorithm(connInstance), user.getCipherAlgorithm())) { String password = user.getPassword().toLowerCase(); byte[] decodedPassword = DatatypeConverter.parseHexBinary(password); String base64EncodedPassword = Base64.getEncoder().encodeToString(decodedPassword); String cipherPlusPassword = ("{" + cipherAlgorithm.toLowerCase() + "}" + base64EncodedPassword); Attribute passwordAttribute = AttributeBuilder.buildPassword( new GuardedString(cipherPlusPassword.toCharArray())); Set<Attribute> attributes = new HashSet<>(task.getAttributes()); attributes.add(passwordAttribute); attributes.remove(missing); task.setAttributes(attributes); } } } }
@Transactional(readOnly = true) @Override public void before(final PropagationTask task, final ConnectorObject beforeObj) { Optional<? extends Provision> provision = task.getResource().getProvision(anyTypeDAO.findGroup()); if (AnyTypeKind.USER == task.getAnyTypeKind() && provision.isPresent() && provision.get().getMapping() != null && StringUtils.isNotBlank(provision.get().getMapping().getConnObjectLink())) { User user = userDAO.find(task.getEntityKey()); if (user != null) { List<String> groupConnObjectLinks = new ArrayList<>(); userDAO.findAllGroupKeys(user).forEach(groupKey -> { Group group = groupDAO.find(groupKey); if (group != null && groupDAO.findAllResourceKeys(groupKey).contains(task.getResource().getKey())) { LOG.debug("Evaluating connObjectLink for {}", group); JexlContext jexlContext = new MapContext(); LOG.debug("Group connObjectLinks to propagate for membership: {}", groupConnObjectLinks); Set<Attribute> attributes = new HashSet<>(task.getAttributes()); task.setAttributes(attributes);