use of org.identityconnectors.framework.common.objects.Attribute in project syncope by apache.
the class DefaultPullCorrelationRule method getSearchCond.
@Override
public SearchCond getSearchCond(final ConnectorObject connObj, final Provision provision) {
Map<String, Item> mappingItems = provision.getMapping().getItems().stream().collect(Collectors.toMap(Item::getIntAttrName, Function.identity()));
// search for anys by attribute(s) specified in the policy
SearchCond searchCond = null;
for (String schema : conf.getSchemas()) {
Item mappingItem = mappingItems.get(schema);
Attribute attr = mappingItem == null ? null : connObj.getAttributeByName(mappingItem.getExtAttrName());
if (attr == null) {
throw new IllegalArgumentException("Connector object does not contains the attributes to perform the search: " + schema);
}
AttributeCond.Type type;
String expression = null;
if (attr.getValue() == null || attr.getValue().isEmpty() || (attr.getValue().size() == 1 && attr.getValue().get(0) == null)) {
type = AttributeCond.Type.ISNULL;
} else {
type = AttributeCond.Type.EQ;
expression = attr.getValue().size() > 1 ? attr.getValue().toString() : attr.getValue().get(0).toString();
}
SearchCond nodeCond;
// any objects: just key or name can be selected
if ("key".equalsIgnoreCase(schema) || "username".equalsIgnoreCase(schema) || "name".equalsIgnoreCase(schema)) {
AnyCond cond = new AnyCond();
cond.setSchema(schema);
cond.setType(type);
cond.setExpression(expression);
nodeCond = SearchCond.getLeafCond(cond);
} else {
AttributeCond cond = new AttributeCond();
cond.setSchema(schema);
cond.setType(type);
cond.setExpression(expression);
nodeCond = SearchCond.getLeafCond(cond);
}
searchCond = searchCond == null ? nodeCond : SearchCond.getAndCond(searchCond, nodeCond);
}
return searchCond;
}
use of org.identityconnectors.framework.common.objects.Attribute in project syncope by apache.
the class MigrationPullActions method after.
@Transactional
@Override
public void after(final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final EntityTO entity, final ProvisioningReport result) throws JobExecutionException {
if (entity instanceof UserTO) {
// handles ciphered password import
CipherAlgorithm cipherAlgorithm = null;
Attribute cipherAlgorithmAttr = delta.getObject().getAttributeByName(CIPHER_ALGORITHM_ATTR);
if (cipherAlgorithmAttr != null && cipherAlgorithmAttr.getValue() != null && !cipherAlgorithmAttr.getValue().isEmpty()) {
cipherAlgorithm = CipherAlgorithm.valueOf(cipherAlgorithmAttr.getValue().get(0).toString());
}
GuardedString passwordValue = AttributeUtil.getPasswordValue(delta.getObject().getAttributes());
if (cipherAlgorithm != null && passwordValue != null) {
User user = userDAO.find(entity.getKey());
LOG.debug("Setting encoded password for {}", user);
user.setEncodedPassword(SecurityUtil.decrypt(passwordValue), cipherAlgorithm);
}
} else if (entity instanceof GroupTO) {
// handles group membership
Attribute membershipsAttr = delta.getObject().getAttributeByName(MEMBERSHIPS_ATTR);
if (membershipsAttr != null && membershipsAttr.getValue() != null && !membershipsAttr.getValue().isEmpty()) {
LOG.debug("Found {} for group {}", MEMBERSHIPS_ATTR, entity.getKey());
for (Object membership : membershipsAttr.getValue()) {
User member = userDAO.findByUsername(membership.toString());
if (member == null) {
LOG.warn("Could not find member {} for group {}", membership, entity.getKey());
} else {
Set<String> memb = memberships.get(member.getKey());
if (memb == null) {
memb = new HashSet<>();
memberships.put(member.getKey(), memb);
}
memb.add(entity.getKey());
}
}
}
} else {
super.after(profile, delta, entity, result);
}
}
use of org.identityconnectors.framework.common.objects.Attribute in project midpoint by Evolveum.
the class ConnIdUtil method dump.
private static void dump(Filter filter, StringBuilder sb, int indent) {
DebugUtil.indentDebugDump(sb, indent);
if (filter == null) {
sb.append("null");
return;
}
sb.append(filter.toString());
if (filter instanceof AttributeFilter) {
sb.append("(");
Attribute attribute = ((AttributeFilter) filter).getAttribute();
sb.append(attribute.getName());
sb.append(": ");
List<Object> value = attribute.getValue();
sb.append(value);
// if (value != null && !value.isEmpty()) {
// sb.append(" :").append(attribute.getValue().iterator().next().getClass().getSimpleName());
// }
sb.append(")");
}
if (filter instanceof CompositeFilter) {
for (Filter subfilter : ((CompositeFilter) filter).getFilters()) {
sb.append("\n");
dump(subfilter, sb, indent + 1);
}
}
}
use of org.identityconnectors.framework.common.objects.Attribute in project CzechIdMng by bcvsolutions.
the class ConnIdIcConnectorService method createObject.
@Override
public IcUidAttribute createObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, List<IcAttribute> attributes) {
Assert.notNull(connectorInstance, "Connector instance is required.");
Assert.notNull(connectorInstance.getConnectorKey(), "Connector key is required.");
Assert.notNull(connectorConfiguration, "Configuration is required.");
Assert.notNull(attributes, "Attributes are required.");
LOG.debug("Create object - ConnId ({} {})", connectorInstance.getConnectorKey().toString(), attributes.toString());
ConnectorFacade conn = facadeFactory.getConnectorFacade(connectorInstance, connectorConfiguration);
Set<Attribute> connIdAttributes = new HashSet<>(attributes.size());
for (IcAttribute icAttribute : attributes) {
connIdAttributes.add(ConnIdIcConvertUtil.convertIcAttribute(icAttribute));
}
ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
if (objectClassConnId == null) {
objectClassConnId = ObjectClass.ACCOUNT;
}
Uid uid = conn.create(objectClassConnId, connIdAttributes, new OperationOptions(connectorConfiguration.getSystemOperationOptions()));
LOG.debug("Created object - ConnId ({} {}) Uid= {}", connectorInstance.getConnectorKey().toString(), attributes.toString(), uid);
return ConnIdIcConvertUtil.convertConnIdUid(uid);
}
use of org.identityconnectors.framework.common.objects.Attribute in project CzechIdMng by bcvsolutions.
the class ConnIdIcConvertUtil method convertConnIdConnectorObject.
public static IcConnectorObject convertConnIdConnectorObject(ConnectorObject connObject) {
if (connObject == null) {
return null;
}
IcObjectClass icClass = ConnIdIcConvertUtil.convertConnIdObjectClass(connObject.getObjectClass());
Set<Attribute> attributes = connObject.getAttributes();
List<IcAttribute> icAttributes = new ArrayList<>();
if (attributes != null) {
for (Attribute a : attributes) {
icAttributes.add(ConnIdIcConvertUtil.convertConnIdAttribute(a));
}
}
return new IcConnectorObjectImpl(connObject.getUid().getUidValue(), icClass, icAttributes);
}
Aggregations