use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.
the class BasicVirtualConnector method init.
@Override
public void init(IcConnectorConfiguration configuration) {
Assert.notNull(configuration);
this.configuration = configuration;
if (!(configuration instanceof IcConnectorConfigurationCzechIdMImpl)) {
throw new IcException(MessageFormat.format("Connector configuration for virtual system must be instance of [{0}]", IcConnectorConfigurationCzechIdMImpl.class.getName()));
}
systemId = ((IcConnectorConfigurationCzechIdMImpl) configuration).getSystemId();
if (systemId == null) {
throw new IcException("System ID cannot be null (for virtual system)");
}
SysSystemDto system = this.systemService.get(systemId);
if (system == null) {
throw new IcException("System cannot be null (for virtual system)");
}
// TODO: This is workaround how mark SysSystem as virtual
if (!system.isVirtual()) {
system.setVirtual(true);
system = this.systemService.save(system);
}
IcConnectorClass connectorAnnotation = this.getClass().getAnnotation(IcConnectorClass.class);
IcConnectorInfo info = CzechIdMIcConvertUtil.convertConnectorClass(connectorAnnotation, this.getClass());
// Load configuration object
virtualConfiguration = (BasicVirtualConfiguration) CzechIdMIcConvertUtil.convertIcConnectorConfiguration(configuration, connectorAnnotation.configurationClass());
// Validate configuration
virtualConfiguration.validate();
connectorKey = info.getConnectorKey().getFullName();
String virtualSystemKey = MessageFormat.format("{0}:systemId={1}", connectorKey, systemId.toString());
String type = VsAccount.class.getName();
// Create/Update form definition and attributes
formDefinition = updateFormDefinition(virtualSystemKey, type, system, virtualConfiguration);
// Update identity and role implementers relations
updateSystemImplementers(this.virtualConfiguration, this.systemId);
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestService method getVirtualConnector.
/**
* Get virtual connector by vs request
*
* @param request
* @return
*/
private VsVirtualConnector getVirtualConnector(VsRequestDto request) {
IcConnectorInfo connectorInfo = //
czechIdMConfigurationService.getAvailableLocalConnectors().stream().filter(//
info -> request.getConnectorKey().equals(info.getConnectorKey().getFullName())).findFirst().orElse(null);
if (connectorInfo == null) {
throw new IcException(MessageFormat.format("We cannot found connector info by connector key [{0}] from virtual system request!", request.getConnectorKey()));
}
IcConnectorInstance connectorKeyInstance = new IcConnectorInstanceImpl(null, connectorInfo.getConnectorKey(), false);
IcConnector connectorInstance = czechIdMConnectorService.getConnectorInstance(connectorKeyInstance, request.getConfiguration());
if (!(connectorInstance instanceof VsVirtualConnector)) {
throw new IcException("Found connector instance is not virtual system connector!");
}
VsVirtualConnector virtualConnector = (VsVirtualConnector) connectorInstance;
return virtualConnector;
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.
the class DefaultVsSystemService method create.
@Override
public SysSystemDto create(VsSystemDto vsSystem) {
Assert.notNull(vsSystem, "Vs system dto cannot be null (for create new virtual system)");
Assert.notNull(vsSystem.getName(), "Vs system name cannot be null (for create new virtual system)");
LOG.info("Create new virtual system with name [{}].", vsSystem.getName());
SysSystemDto system = new SysSystemDto();
// Find connector for VS
Class<? extends VsVirtualConnector> defaultVirtualConnector = BasicVirtualConnector.class;
IcConnectorClass connectorAnnotation = defaultVirtualConnector.getAnnotation(IcConnectorClass.class);
IcConnectorInfo info = CzechIdMIcConvertUtil.convertConnectorClass(connectorAnnotation, (Class<? extends IcConnector>) defaultVirtualConnector);
// Set connector key for VS
system.setConnectorKey(new SysConnectorKeyDto(info.getConnectorKey()));
system.setName(vsSystem.getName());
// Create system
system = this.systemService.save(system, IdmBasePermission.CREATE);
// Find and update attributes for implementers
IdmFormDefinitionDto connectorFormDef = this.systemService.getConnectorFormDefinition(system.getConnectorInstance());
IdmFormAttributeDto implementersFormAttr = connectorFormDef.getMappedAttributeByCode(IMPLEMENTERS_PROPERTY);
formService.saveValues(system, implementersFormAttr, new ArrayList<>(vsSystem.getImplementers()));
IdmFormAttributeDto implementerRolesFormAttr = connectorFormDef.getMappedAttributeByCode(IMPLEMENTER_ROLES_PROPERTY);
formService.saveValues(system, implementerRolesFormAttr, new ArrayList<>(vsSystem.getImplementerRoles()));
IdmFormAttributeDto attributesFormAttr = connectorFormDef.getMappedAttributeByCode(ATTRIBUTES_PROPERTY);
if (!vsSystem.getAttributes().isEmpty()) {
formService.saveValues(system, attributesFormAttr, new ArrayList<>(vsSystem.getAttributes()));
} else {
List<Serializable> defaultAttributes = Lists.newArrayList((Serializable[]) BasicVirtualConfiguration.DEFAULT_ATTRIBUTES);
defaultAttributes.add(RIGHTS_ATTRIBUTE);
formService.saveValues(system, attributesFormAttr, defaultAttributes);
}
this.systemService.checkSystem(system);
// Search attribute definition for rights and set him to multivalue
String virtualSystemKey = MessageFormat.format("{0}:systemId={1}", system.getConnectorKey().getFullName(), system.getId().toString());
String type = VsAccount.class.getName();
IdmFormDefinitionDto definition = this.formService.getDefinition(type, virtualSystemKey);
IdmFormAttributeDto rightsFormAttr = formAttributeService.findAttribute(type, definition.getCode(), RIGHTS_ATTRIBUTE);
if (rightsFormAttr != null) {
rightsFormAttr.setMultiple(true);
formService.saveAttribute(rightsFormAttr);
}
// Generate schema
List<SysSchemaObjectClassDto> schemas = this.systemService.generateSchema(system);
SysSchemaObjectClassDto schemaAccount = schemas.stream().filter(schema -> IcObjectClassInfo.ACCOUNT.equals(schema.getObjectClassName())).findFirst().orElse(null);
Assert.notNull(schemaAccount, "We cannot found schema for ACCOUNT!");
// Create mapping by default attributes
this.createDefaultMapping(system, schemaAccount, vsSystem);
return this.systemService.get(system.getId());
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.
the class ConnIdIcConfigurationService method getAvailableLocalConnectors.
/**
* Return available local connectors for this IC implementation
*
* @return
*/
@Override
public Set<IcConnectorInfo> getAvailableLocalConnectors() {
LOG.info("Get Available local connectors - ConnId");
Set<IcConnectorInfo> localConnectorInfos = new HashSet<>();
List<ConnectorInfoManager> managers = findAllLocalConnectorManagers();
for (ConnectorInfoManager manager : managers) {
List<ConnectorInfo> infos = manager.getConnectorInfos();
if (infos == null) {
continue;
}
for (ConnectorInfo info : infos) {
ConnectorKey key = info.getConnectorKey();
if (key == null) {
continue;
}
IcConnectorKeyImpl keyDto = new IcConnectorKeyImpl(getFramework(), key.getBundleName(), key.getBundleVersion(), key.getConnectorName());
IcConnectorInfoImpl infoDto = new IcConnectorInfoImpl(info.getConnectorDisplayName(), info.getConnectorCategory(), keyDto);
localConnectorInfos.add(infoDto);
}
}
return localConnectorInfos;
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.
the class ConnIdIcConfigurationService method getAvailableRemoteConnectors.
@Override
public Set<IcConnectorInfo> getAvailableRemoteConnectors(IcConnectorServer server) {
Assert.notNull(server);
//
Set<IcConnectorInfo> result = new HashSet<>();
//
List<ConnectorInfo> infos = getAllRemoteConnectors(server);
for (ConnectorInfo info : infos) {
ConnectorKey key = info.getConnectorKey();
if (key == null) {
continue;
}
// transform
IcConnectorKeyImpl keyDto = new IcConnectorKeyImpl(getFramework(), key.getBundleName(), key.getBundleVersion(), key.getConnectorName());
IcConnectorInfoImpl infoDto = new IcConnectorInfoImpl(info.getConnectorDisplayName(), info.getConnectorCategory(), keyDto);
result.add(infoDto);
}
return result;
}
Aggregations