use of org.identityconnectors.framework.common.objects.Attribute in project syncope by apache.
the class TaskTest method savePropagationTask.
@Test
public void savePropagationTask() {
ExternalResource resource = resourceDAO.find("ws-target-resource-1");
assertNotNull(resource);
User user = userDAO.find("74cd8ece-715a-44a4-a736-e17b46c4e7e6");
assertNotNull(user);
PropagationTask task = entityFactory.newEntity(PropagationTask.class);
task.setResource(resource);
task.setAnyTypeKind(AnyTypeKind.USER);
task.setAnyType(AnyTypeKind.USER.name());
task.setOperation(ResourceOperation.CREATE);
task.setConnObjectKey("one@two.com");
Set<Attribute> attributes = new HashSet<>();
attributes.add(AttributeBuilder.build("testAttribute", "testValue1", "testValue2"));
attributes.add(AttributeBuilder.buildPassword("password".toCharArray()));
task.setAttributes(attributes);
task = taskDAO.save(task);
assertNotNull(task);
PropagationTask actual = taskDAO.find(task.getKey());
assertEquals(task, actual);
}
use of org.identityconnectors.framework.common.objects.Attribute in project CzechIdMng by bcvsolutions.
the class ConnIdIcConvertUtil method convertIcFilter.
public static Filter convertIcFilter(IcFilter filter) {
if (filter == null) {
return null;
}
if (filter instanceof IcAndFilter) {
List<IcFilter> subFilters = (List<IcFilter>) ((IcAndFilter) filter).getFilters();
LinkedList<Filter> subFiltersConnId = new LinkedList<>();
if (!subFilters.isEmpty()) {
subFilters.forEach(subFilter -> {
subFiltersConnId.add(ConnIdIcConvertUtil.convertIcFilter(subFilter));
});
}
return new AndFilter(subFiltersConnId);
}
if (filter instanceof IcOrFilter) {
List<IcFilter> subFilters = (List<IcFilter>) ((IcOrFilter) filter).getFilters();
LinkedList<Filter> subFiltersConnId = new LinkedList<>();
if (!subFilters.isEmpty()) {
subFilters.forEach(subFilter -> {
subFiltersConnId.add(ConnIdIcConvertUtil.convertIcFilter(subFilter));
});
}
return new OrFilter(subFiltersConnId);
}
if (filter instanceof IcNotFilter) {
return new NotFilter(ConnIdIcConvertUtil.convertIcFilter(((IcNotFilter) filter).getFilter()));
}
if (filter instanceof IcAttributeFilter) {
Attribute attr = ConnIdIcConvertUtil.convertIcAttribute(((IcAttributeFilter) filter).getAttribute());
if (filter instanceof IcEqualsFilter) {
return new EqualsFilter(attr);
}
if (filter instanceof IcContainsFilter) {
return new ContainsFilter(attr);
}
if (filter instanceof IcEndsWithFilter) {
return new EndsWithFilter(attr);
}
if (filter instanceof IcContainsAllValuesFilter) {
return new ContainsAllValuesFilter(attr);
}
if (filter instanceof IcStartsWithFilter) {
return new StartsWithFilter(attr);
}
if (filter instanceof IcGreaterThanFilter) {
return new GreaterThanFilter(attr);
}
if (filter instanceof IcLessThanFilter) {
return new LessThanFilter(attr);
}
}
return null;
}
use of org.identityconnectors.framework.common.objects.Attribute in project CzechIdMng by bcvsolutions.
the class ConnIdIcConnectorService method updateObject.
@Override
public IcUidAttribute updateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid, List<IcAttribute> replaceAttributes) {
Assert.notNull(connectorInstance, "Connector instance is required.");
Assert.notNull(connectorInstance.getConnectorKey(), "Connector key is required.");
Assert.notNull(connectorConfiguration, "Configuration is required.");
Assert.notNull(replaceAttributes, "Replace attributes are required.");
Assert.notNull(uid, "Uid is required.");
LOG.debug("Update object - ConnId (Uid= {} {} {})", uid, connectorInstance.getConnectorKey().toString(), replaceAttributes.toString());
ConnectorFacade conn = facadeFactory.getConnectorFacade(connectorInstance, connectorConfiguration);
Set<Attribute> connIdAttributes = new HashSet<>(replaceAttributes.size());
for (IcAttribute icAttribute : replaceAttributes) {
connIdAttributes.add(ConnIdIcConvertUtil.convertIcAttribute(icAttribute));
}
ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
if (objectClassConnId == null) {
objectClassConnId = ObjectClass.ACCOUNT;
}
Uid updatedUid = conn.update(objectClassConnId, ConnIdIcConvertUtil.convertIcUid(uid), connIdAttributes, new OperationOptions(connectorConfiguration.getSystemOperationOptions()));
LOG.debug("Updated object - ConnId ({} {}) Uid= {})", connectorInstance.getConnectorKey().toString(), replaceAttributes.toString(), updatedUid);
return ConnIdIcConvertUtil.convertConnIdUid(updatedUid);
}
use of org.identityconnectors.framework.common.objects.Attribute in project midpoint by Evolveum.
the class ConnIdUtil method dump.
public static String dump(Set<Attribute> attributes) {
StringBuilder sb = new StringBuilder();
for (Attribute attr : attributes) {
DebugUtil.indentDebugDump(sb, 1);
sb.append(attr.getClass().getSimpleName()).append("(");
sb.append("name=").append(attr.getName());
List<Object> value = attr.getValue();
sb.append(", value=").append(value);
if (value != null && !value.isEmpty()) {
sb.append(", type=").append(value.iterator().next().getClass().getSimpleName());
}
sb.append(")\n");
}
return sb.toString();
}
use of org.identityconnectors.framework.common.objects.Attribute in project midpoint by Evolveum.
the class ValueOperation method interpret.
@Override
public <T> Filter interpret(ObjectFilter objectFilter, ConnIdNameMapper icfNameMapper) throws SchemaException {
ValueFilter valueFilter = (ValueFilter) objectFilter;
if (valueFilter.getParentPath().isEmpty()) {
throw new UnsupportedOperationException("Empty path is not supported (filter: " + objectFilter + ")");
}
if (valueFilter.getParentPath().equivalent(ShadowType.F_ATTRIBUTES)) {
try {
QName propName = valueFilter.getDefinition().getItemName();
String icfName = icfNameMapper.convertAttributeNameToConnId(propName, getInterpreter().getObjectDefinition(), "(attribute in the filter)");
if (objectFilter instanceof EqualFilter) {
EqualFilter<T> eq = (EqualFilter<T>) objectFilter;
Collection<Object> convertedValues = convertValues(propName, eq.getValues());
if (convertedValues == null || convertedValues.isEmpty()) {
Attribute attr = AttributeBuilder.build(icfName);
return FilterBuilder.equalTo(attr);
} else {
Attribute attr = AttributeBuilder.build(icfName, convertedValues);
if (valueFilter.getDefinition().isSingleValue()) {
return FilterBuilder.equalTo(attr);
} else {
// "Values stored under specified key on the resource contain this single value."
return FilterBuilder.containsAllValues(attr);
}
}
} else if (objectFilter instanceof SubstringFilter) {
SubstringFilter substring = (SubstringFilter) objectFilter;
Collection<Object> convertedValues = convertValues(propName, substring.getValues());
if (convertedValues == null || convertedValues.isEmpty()) {
throw new IllegalArgumentException("Substring filter with null value makes no sense");
} else {
if (convertedValues.size() != 1) {
throw new IllegalArgumentException("Substring filter with multiple values makes no sense");
// maybe it does, through OR clauses
}
if (substring.isAnchorStart() && !substring.isAnchorEnd()) {
return FilterBuilder.startsWith(AttributeBuilder.build(icfName, convertedValues.iterator().next()));
} else if (!substring.isAnchorStart() && substring.isAnchorEnd()) {
return FilterBuilder.endsWith(AttributeBuilder.build(icfName, convertedValues.iterator().next()));
} else if (!substring.isAnchorStart() && !substring.isAnchorEnd()) {
return FilterBuilder.contains(AttributeBuilder.build(icfName, convertedValues.iterator().next()));
} else {
return FilterBuilder.equalTo(AttributeBuilder.build(icfName, convertedValues.iterator().next()));
}
}
} else if (objectFilter instanceof ComparativeFilter) {
ComparativeFilter comparativeFilter = (ComparativeFilter) objectFilter;
Collection<Object> convertedValues = convertValues(propName, comparativeFilter.getValues());
if (convertedValues == null || convertedValues.isEmpty()) {
throw new IllegalArgumentException("Comparative filter with null value makes no sense");
} else {
if (convertedValues.size() != 1) {
throw new IllegalArgumentException("Comparative filter with multiple values makes no sense");
}
Attribute attribute = AttributeBuilder.build(icfName, convertedValues.iterator().next());
if (comparativeFilter instanceof GreaterFilter) {
if (comparativeFilter.isEquals()) {
return FilterBuilder.greaterThanOrEqualTo(attribute);
} else {
return FilterBuilder.greaterThan(attribute);
}
} else if (comparativeFilter instanceof LessFilter) {
if (comparativeFilter.isEquals()) {
return FilterBuilder.lessThanOrEqualTo(attribute);
} else {
return FilterBuilder.lessThan(attribute);
}
} else {
throw new UnsupportedOperationException("Unsupported filter type: " + objectFilter);
}
}
} else {
throw new UnsupportedOperationException("Unsupported filter type: " + objectFilter);
}
} catch (SchemaException ex) {
throw ex;
}
} else if (valueFilter.getParentPath().equivalent(ShadowType.F_ACTIVATION)) {
if (objectFilter instanceof EqualFilter) {
QName propName = valueFilter.getDefinition().getItemName();
EqualFilter<T> eq = (EqualFilter<T>) objectFilter;
List<PrismPropertyValue<T>> values = eq.getValues();
if (values == null || values.size() != 1) {
throw new SchemaException("Unexpected number of values in filter " + objectFilter);
}
PrismPropertyValue<T> pval = values.get(0);
String icfName;
Object convertedValue;
if (propName.equals(ActivationType.F_ADMINISTRATIVE_STATUS)) {
icfName = OperationalAttributes.ENABLE_NAME;
convertedValue = pval.getValue() == ActivationStatusType.ENABLED;
} else if (propName.equals(ActivationType.F_LOCKOUT_STATUS)) {
icfName = OperationalAttributes.LOCK_OUT_NAME;
convertedValue = pval.getValue() == LockoutStatusType.LOCKED;
} else {
throw new UnsupportedOperationException("Unsupported activation property " + propName + " in filter: " + objectFilter);
}
Attribute attr = AttributeBuilder.build(icfName, convertedValue);
if (valueFilter.getDefinition().isSingleValue()) {
return FilterBuilder.equalTo(attr);
} else {
return FilterBuilder.containsAllValues(attr);
}
} else {
throw new UnsupportedOperationException("Unsupported filter type in filter: " + objectFilter);
}
} else {
throw new UnsupportedOperationException("Unsupported parent path " + valueFilter.getParentPath() + " in filter: " + objectFilter);
}
}
Aggregations