use of org.identityconnectors.framework.api.ConnectorFacade in project CzechIdMng by bcvsolutions.
the class ConnIdIcConnectorService method authenticateObject.
@Override
public IcUidAttribute authenticateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, String username, GuardedString password) {
Assert.notNull(connectorInstance, "Connector instance is required.");
Assert.notNull(connectorInstance.getConnectorKey(), "Connector key is required.");
Assert.notNull(connectorConfiguration, "Configuration is required.");
Assert.notNull(username, "Username is required.");
LOG.debug("Authenticate object - ConnId (username= {} {})", username, connectorInstance.getConnectorKey().toString());
ConnectorFacade conn = facadeFactory.getConnectorFacade(connectorInstance, connectorConfiguration);
ObjectClass objectClassConnId = ConnIdIcConvertUtil.convertIcObjectClass(objectClass);
if (objectClassConnId == null) {
objectClassConnId = ObjectClass.ACCOUNT;
}
try {
IcUidAttribute uid = ConnIdIcConvertUtil.convertConnIdUid(conn.authenticate(objectClassConnId, username, new org.identityconnectors.common.security.GuardedString(password.asString().toCharArray()), new OperationOptions(connectorConfiguration.getSystemOperationOptions())));
LOG.debug("Authenticated object - ConnId (Uid= {})", uid);
return uid;
} catch (InvalidCredentialException ex) {
throw new ResultCodeException(IcResultCode.AUTH_FAILED, ex);
}
}
use of org.identityconnectors.framework.api.ConnectorFacade in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method configure.
@Override
public synchronized void configure(@NotNull PrismContainerValue<?> configurationOriginal, List<QName> generateObjectClasses, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, SchemaException, ConfigurationException {
OperationResult result = parentResult.createSubresult(ConnectorInstance.OPERATION_CONFIGURE);
LOGGER.trace("Configuring connector {}, provided configuration:\n{}", connectorType, configurationOriginal.debugDumpLazily(1));
try {
this.generateObjectClasses = generateObjectClasses;
// Get default configuration for the connector. This is important,
// as it contains types of connector configuration properties.
// Make sure that the proper configuration schema is applied. This
// will cause that all the "raw" elements are parsed
PrismContainerValue<?> configurationCloned = configurationOriginal.clone();
configurationCloned.applyDefinition(getConfigurationContainerDefinition());
ConnIdConfigurationTransformer configTransformer = new ConnIdConfigurationTransformer(connectorType, connectorInfo, protector);
// Transform XML configuration from the resource to the ConnId connector configuration
try {
apiConfig = configTransformer.transformConnectorConfiguration(configurationCloned);
} catch (SchemaException e) {
result.recordFatalError(e.getMessage(), e);
throw e;
}
logTransformedConfiguration();
apiConfig.setInstanceName(getInstanceName());
ConnectorFacade oldConnIdConnectorFacade = connIdConnectorFacade;
// Create new connector instance using the transformed configuration
connIdConnectorFacade = ConnectorFacadeFactory.getInstance().newInstance(apiConfig);
if (oldConnIdConnectorFacade != null) {
// Make sure old connector instance is disposed. We do not want to waste resources.
// In case that old and new facade are the same, this will cause all existing
// ConnId connector instances to dispose (i.e. connector pool is emptied).
// But this is exactly what we want on reconfigure. We want the connections to
// be closed and re-opened.
LOGGER.debug("Disposing old ConnId ConnectorFacade for instance: {} (connector reconfiguration)", instanceName);
oldConnIdConnectorFacade.dispose();
}
result.recordSuccess();
PrismProperty<Boolean> legacySchemaConfigProperty = configurationCloned.findProperty(new ItemName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_LEGACY_SCHEMA_XML_ELEMENT_NAME));
if (legacySchemaConfigProperty != null) {
legacySchema = legacySchemaConfigProperty.getRealValue();
}
LOGGER.trace("Legacy schema (config): {}", legacySchema);
} catch (Throwable ex) {
Throwable midpointEx = processConnIdException(ex, this, result);
result.computeStatus("Removing attribute values failed");
// exception
if (midpointEx instanceof CommunicationException) {
throw (CommunicationException) midpointEx;
} else if (midpointEx instanceof GenericFrameworkException) {
throw (GenericFrameworkException) midpointEx;
} else if (midpointEx instanceof SchemaException) {
throw (SchemaException) midpointEx;
} else if (midpointEx instanceof ConfigurationException) {
throw (ConfigurationException) midpointEx;
} else if (midpointEx instanceof RuntimeException) {
throw (RuntimeException) midpointEx;
} else if (midpointEx instanceof Error) {
throw (Error) midpointEx;
} else {
throw new SystemException("Got unexpected exception: " + ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
}
}
Aggregations