class 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 public  Credentials(final CredentialProviderLocator credentialProviderLocator, final EncryptionComponent encryptionComponent,
        final DataManager dataManager);

}