@Test public void shouldApplyReceivedCredentialsToConnections() { final CredentialProvider credentialProvider = mock(CredentialProvider.class); when(locator.providerWithId("providerId")).thenReturn(credentialProvider); final CredentialFlowState flowState = new OAuth2CredentialFlowState.Builder().providerId("providerId") .returnUrl(URI.create("/ui#state")).code("code").state("state").build(); final Connection connection = new Connection.Builder() .connector(new Connector.Builder().putProperty("key", new ConfigurationProperty.Builder().build()).build()) .build(); when(credentialProvider.applyTo(new Connection.Builder().createFrom(connection).isDerived(true).build(), flowState)) .then(a -> new Connection.Builder().createFrom(a.getArgument(0)) .putConfiguredProperty("key", "value").build()); final Connection finishedConnection = credentials.apply(connection, flowState); assertThat(finishedConnection).isNotNull(); assertThat(finishedConnection.getConfiguredProperties()).contains(entry("key", "value")); assertThat(finishedConnection.isDerived()).isTrue(); }
public Connection apply(final Connection updatedConnection, final CredentialFlowState flowState) { final CredentialProvider credentialProvider = providerFrom(flowState); final Connection withDerivedFlag = new Connection.Builder().createFrom(updatedConnection).isDerived(true).build(); final Connection appliedConnection = credentialProvider.applyTo(withDerivedFlag, flowState); final Map<String, String> configuredProperties = appliedConnection.getConfiguredProperties(); final Map<String, ConfigurationProperty> properties = updatedConnection.getConnector() .orElseGet(() -> dataManager.fetch(Connector.class, updatedConnection.getConnectorId())).getProperties(); final Map<String, String> encryptedConfiguredProperties = encryptionComponent.encryptPropertyValues(configuredProperties, properties); return new Connection.Builder().createFrom(appliedConnection).configuredProperties(encryptedConfiguredProperties).build(); }
Credentials { public Connection apply(final Connection updatedConnection, final CredentialFlowState flowState) { final CredentialProvider credentialProvider = providerFrom(flowState); final Connection withDerivedFlag = new Connection.Builder().createFrom(updatedConnection).isDerived(true).build(); final Connection appliedConnection = credentialProvider.applyTo(withDerivedFlag, flowState); final Map<String, String> configuredProperties = appliedConnection.getConfiguredProperties(); final Map<String, ConfigurationProperty> properties = updatedConnection.getConnector() .orElseGet(() -> dataManager.fetch(Connector.class, updatedConnection.getConnectorId())).getProperties(); final Map<String, String> encryptedConfiguredProperties = encryptionComponent.encryptPropertyValues(configuredProperties, properties); return new Connection.Builder().createFrom(appliedConnection).configuredProperties(encryptedConfiguredProperties).build(); } }
Credentials { public Connection apply(final Connection updatedConnection, final CredentialFlowState flowState) { final CredentialProvider credentialProvider = providerFrom(flowState); final Connection withDerivedFlag = new Connection.Builder().createFrom(updatedConnection).isDerived(true).build(); final Connection appliedConnection = credentialProvider.applyTo(withDerivedFlag, flowState); final Map<String, String> configuredProperties = appliedConnection.getConfiguredProperties(); final Map<String, ConfigurationProperty> properties = updatedConnection.getConnector() .orElseGet(() -> dataManager.fetch(Connector.class, updatedConnection.getConnectorId())).getProperties(); final Map<String, String> encryptedConfiguredProperties = encryptionComponent.encryptPropertyValues(configuredProperties, properties); return new Connection.Builder().createFrom(appliedConnection).configuredProperties(encryptedConfiguredProperties).build(); } @Autowired  Credentials(final CredentialProviderLocator credentialProviderLocator, final EncryptionComponent encryptionComponent,
        final DataManager dataManager); }
Credentials { public Connection apply(final Connection updatedConnection, final CredentialFlowState flowState) { final CredentialProvider credentialProvider = providerFrom(flowState); final Connection withDerivedFlag = new Connection.Builder().createFrom(updatedConnection).isDerived(true).build(); final Connection appliedConnection = credentialProvider.applyTo(withDerivedFlag, flowState); final Map<String, String> configuredProperties = appliedConnection.getConfiguredProperties(); final Map<String, ConfigurationProperty> properties = updatedConnection.getConnector() .orElseGet(() -> dataManager.fetch(Connector.class, updatedConnection.getConnectorId())).getProperties(); final Map<String, String> encryptedConfiguredProperties = encryptionComponent.encryptPropertyValues(configuredProperties, properties); return new Connection.Builder().createFrom(appliedConnection).configuredProperties(encryptedConfiguredProperties).build(); } @Autowired  Credentials(final CredentialProviderLocator credentialProviderLocator, final EncryptionComponent encryptionComponent,
        final DataManager dataManager); AcquisitionFlow acquire(final String providerId, final URI baseUrl, final URI returnUrl); AcquisitionMethod acquisitionMethodFor(final String providerId); Connection apply(final Connection updatedConnection, final CredentialFlowState flowState); CredentialFlowState finishAcquisition(final CredentialFlowState flowState, final URI baseUrl); }
Credentials { public Connection apply(final Connection updatedConnection, final CredentialFlowState flowState) { final CredentialProvider credentialProvider = providerFrom(flowState); final Connection withDerivedFlag = new Connection.Builder().createFrom(updatedConnection).isDerived(true).build(); final Connection appliedConnection = credentialProvider.applyTo(withDerivedFlag, flowState); final Map<String, String> configuredProperties = appliedConnection.getConfiguredProperties(); final Map<String, ConfigurationProperty> properties = updatedConnection.getConnector() .orElseGet(() -> dataManager.fetch(Connector.class, updatedConnection.getConnectorId())).getProperties(); final Map<String, String> encryptedConfiguredProperties = encryptionComponent.encryptPropertyValues(configuredProperties, properties); return new Connection.Builder().createFrom(appliedConnection).configuredProperties(encryptedConfiguredProperties).build(); } @Autowired  Credentials(final CredentialProviderLocator credentialProviderLocator, final EncryptionComponent encryptionComponent,
        final DataManager dataManager); AcquisitionFlow acquire(final String providerId, final URI baseUrl, final URI returnUrl); AcquisitionMethod acquisitionMethodFor(final String providerId); Connection apply(final Connection updatedConnection, final CredentialFlowState flowState); CredentialFlowState finishAcquisition(final CredentialFlowState flowState, final URI baseUrl); static final String ACCESS_TOKEN_TAG; static final String ACCESS_TOKEN_URL_TAG; static final String AUTHENTICATION_TYPE_TAG; static final String AUTHENTICATION_URL_TAG; static final String AUTHORIZATION_URL_TAG; static final String AUTHORIZE_USING_PARAMETERS_TAG; static final String CLIENT_ID_TAG; static final String CLIENT_SECRET_TAG; static final String SCOPE_TAG; static final String TOKEN_STRATEGY_TAG; static final String ADDITIONAL_QUERY_PARAMETERS_TAG; }