use of org.finos.legend.engine.authentication.provider.DatabaseAuthenticationFlowProvider in project legend-engine by finos.
the class RelationalStoreExecutorBuilder method build.
@Override
public StoreExecutor build(StoreExecutorConfiguration storeExecutorConfiguration) {
if (!(storeExecutorConfiguration instanceof RelationalExecutionConfiguration)) {
String message = String.format("Invalid argument. Expected %s but found %s", RelationalExecutionConfiguration.class.getCanonicalName(), storeExecutorConfiguration.getClass().getCanonicalName());
throw new RuntimeException(message);
}
RelationalExecutionConfiguration relationalExecutionConfiguration = (RelationalExecutionConfiguration) storeExecutorConfiguration;
if (relationalExecutionConfiguration.tempPath == null) {
relationalExecutionConfiguration.tempPath = DEFAULT_TEMP_PATH;
}
if (relationalExecutionConfiguration.temporarytestdb == null) {
relationalExecutionConfiguration.temporarytestdb = new TemporaryTestDbConfiguration(DEFAULT_PORT);
}
Optional<DatabaseAuthenticationFlowProvider> flowProviderHolder = this.configureDatabaseAuthenticationFlowProvider(relationalExecutionConfiguration);
RelationalStoreState state = new RelationalStoreState(relationalExecutionConfiguration.temporarytestdb, relationalExecutionConfiguration, flowProviderHolder);
return new RelationalStoreExecutor(state);
}
use of org.finos.legend.engine.authentication.provider.DatabaseAuthenticationFlowProvider in project legend-engine by finos.
the class RelationalStoreExecutorBuilder method configureDatabaseAuthenticationFlowProvider.
private Optional<DatabaseAuthenticationFlowProvider> configureDatabaseAuthenticationFlowProvider(RelationalExecutionConfiguration relationalExecutionConfig) {
if (relationalExecutionConfig == null) {
return Optional.empty();
}
Class<? extends DatabaseAuthenticationFlowProvider> flowProviderClass = relationalExecutionConfig.getFlowProviderClass();
DatabaseAuthenticationFlowProviderConfiguration flowProviderConfiguration = relationalExecutionConfig.getFlowProviderConfiguration();
if (flowProviderClass == null) {
// TODO : Implement more strict validation when the flow provider feature is fully rolled out
return Optional.empty();
}
Optional<DatabaseAuthenticationFlowProvider> flowProviderHolder = DatabaseAuthenticationFlowProviderSelector.getProvider(flowProviderClass.getCanonicalName());
DatabaseAuthenticationFlowProvider flowProvider = flowProviderHolder.orElseThrow(() -> new RuntimeException(String.format("Database authentication provider not found in the classpath. Provider class-%s", flowProviderClass.getCanonicalName())));
if (flowProviderConfiguration != null) {
flowProvider.configure(flowProviderConfiguration);
}
return Optional.of(flowProvider);
}
use of org.finos.legend.engine.authentication.provider.DatabaseAuthenticationFlowProvider in project legend-engine by finos.
the class RelationalStoreExecutorBuilder method build.
@Override
public RelationalStoreExecutor build() {
TemporaryTestDbConfiguration temporaryTestDbConfiguration = new TemporaryTestDbConfiguration(DEFAULT_PORT);
RelationalExecutionConfiguration relationalExecutionConfiguration = new RelationalExecutionConfiguration(DEFAULT_TEMP_PATH);
Optional<DatabaseAuthenticationFlowProvider> flowProviderHolder = this.configureDatabaseAuthenticationFlowProvider(relationalExecutionConfiguration);
RelationalStoreState state = new RelationalStoreState(temporaryTestDbConfiguration, relationalExecutionConfiguration, flowProviderHolder);
return new RelationalStoreExecutor(state);
}
use of org.finos.legend.engine.authentication.provider.DatabaseAuthenticationFlowProvider in project legend-engine by finos.
the class TestRelationalConnectionManager method testResolveEmptyCredentialForUnsupportedFlow.
@Test
public void testResolveEmptyCredentialForUnsupportedFlow() throws JsonProcessingException {
String connectionStr = "{\n" + " \"_type\": \"RelationalDatabaseConnection\",\n" + " \"type\": \"H2\",\n" + " \"authenticationStrategy\" : {\n" + " \"_type\" : \"test\"\n" + " },\n" + " \"datasourceSpecification\" : {\n" + " \"_type\" : \"static\",\n" + " \"host\" : \"127.0.0.1\",\n" + " \"port\" : \"111\"\n" + " }\n" + "}";
RelationalDatabaseConnection connectionSpec = ObjectMapperFactory.getNewStandardObjectMapperWithPureProtocolExtensionSupports().readValue(connectionStr, RelationalDatabaseConnection.class);
DatabaseAuthenticationFlowProvider flowProvider = new NoOpFlowProvider();
Identity identity = DefaultIdentityFactory.INSTANCE.makeUnknownIdentity();
Optional<CredentialSupplier> credential = RelationalConnectionManager.getCredential(flowProvider, connectionSpec, identity);
assertFalse(credential.isPresent());
}
Aggregations