use of eu.bcvsolutions.idm.ic.api.IcAttribute in project CzechIdMng by bcvsolutions.
the class IdentitySynchronizationExecutor method doUpdateEntity.
/**
* Fill data from IC attributes to entity (EAV and confidential storage too)
*
* @param account
* @param entityType
* @param uid
* @param icAttributes
* @param mappedAttributes
* @param log
* @param logItem
* @param actionLogs
*/
protected void doUpdateEntity(SynchronizationContext context) {
String uid = context.getUid();
SysSyncLogDto log = context.getLog();
SysSyncItemLogDto logItem = context.getLogItem();
List<SysSyncActionLogDto> actionLogs = context.getActionLogs();
List<SysSystemAttributeMappingDto> mappedAttributes = context.getMappedAttributes();
AccAccountDto account = context.getAccount();
List<IcAttribute> icAttributes = context.getIcObject().getAttributes();
SystemEntityType entityType = context.getEntityType();
UUID entityId = getEntityByAccount(account.getId());
IdmIdentityDto identity = null;
if (entityId != null) {
identity = identityService.get(entityId);
}
if (identity != null) {
// Update identity
identity = fillEntity(mappedAttributes, uid, icAttributes, identity, false, context);
identity = this.save(identity, true);
// Update extended attribute (entity must be persisted first)
updateExtendedAttributes(mappedAttributes, uid, icAttributes, identity, false, context);
// Update confidential attribute (entity must be persisted
// first)
updateConfidentialAttributes(mappedAttributes, uid, icAttributes, identity, false, context);
// Identity Updated
addToItemLog(logItem, MessageFormat.format("Identity with id {0} was updated", identity.getId()));
if (logItem != null) {
logItem.setDisplayName(identity.getUsername());
}
// Call provisioning for entity
this.callProvisioningForEntity(identity, entityType, logItem);
return;
} else {
addToItemLog(logItem, "Identity account relation (with ownership = true) was not found!");
initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
return;
}
}
use of eu.bcvsolutions.idm.ic.api.IcAttribute 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);
Assert.notNull(connectorInstance.getConnectorKey());
Assert.notNull(connectorConfiguration);
Assert.notNull(replaceAttributes);
Assert.notNull(uid);
LOG.debug("Update object - ConnId (Uid= {} {} {})", uid, connectorInstance.getConnectorKey().toString(), replaceAttributes.toString());
ConnectorFacade conn = getConnectorFacade(connectorInstance, connectorConfiguration);
Set<Attribute> connIdAttributes = new HashSet<>();
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, null);
LOG.debug("Updated object - ConnId ({} {}) Uid= {})", connectorInstance.getConnectorKey().toString(), replaceAttributes.toString(), updatedUid);
return ConnIdIcConvertUtil.convertConnIdUid(updatedUid);
}
use of eu.bcvsolutions.idm.ic.api.IcAttribute in project CzechIdMng by bcvsolutions.
the class IcAttributeFilter method isPresent.
/**
* Determines if the attribute provided is present in the
* {@link IcConnectorObject}.
*/
public boolean isPresent(IcConnectorObject obj) {
Optional<IcAttribute> optionalAttr = obj.getAttributes().stream().filter(attribute -> {
return getName().equals(this.attr.getName());
}).findFirst();
IcAttribute attr = optionalAttr.isPresent() ? optionalAttr.get() : null;
return attr != null;
}
use of eu.bcvsolutions.idm.ic.api.IcAttribute in project CzechIdMng by bcvsolutions.
the class IcStringFilter method accept.
/**
* @throws ClassCastException
* if the value from the {@link IcConnectorObject}'s attribute of
* the same name as provided is not a string.
*/
@Override
public boolean accept(IcConnectorObject obj) {
boolean ret = false;
IcAttribute attr = obj.getAttributeByName(getName());
if (attr != null) {
ret = accept((String) attr.getValues().get(0));
}
return ret;
}
use of eu.bcvsolutions.idm.ic.api.IcAttribute in project CzechIdMng by bcvsolutions.
the class BasicVirtualConnector method create.
@Override
public IcUidAttribute create(IcObjectClass objectClass, List<IcAttribute> attributes) {
Assert.notNull(objectClass, "Object class cannot be null!");
Assert.notNull(attributes, "Attributes cannot be null!");
if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
throw new IcException("Only ACCOUNT object class is supported now!");
}
IcAttribute uidAttribute = geAttribute(attributes, IcAttributeInfo.NAME);
if (uidAttribute == null) {
throw new IcException("UID attribute was not found!");
}
Object uidValue = uidAttribute.getValue();
if (!(uidValue instanceof String)) {
throw new IcException(MessageFormat.format("UID attribute value [{0}] must be String!", uidValue));
}
// Create and execute request
VsRequestDto request = createRequest(objectClass, attributes, (String) uidValue, VsOperationType.CREATE);
return requestService.execute(request);
}
Aggregations