@Test public void shouldAcquireOAuth2Credentials() { final OAuth2ConnectionFactory<?> oauth2 = mock(OAuth2ConnectionFactory.class); @SuppressWarnings("unchecked") final Applicator<AccessGrant> applicator = mock(Applicator.class); when(locator.providerWithId("providerId")) .thenReturn(new OAuth2CredentialProvider<>("providerId", oauth2, applicator, Collections.emptyMap())); when(oauth2.getScope()).thenReturn("scope"); when(oauth2.generateState()).thenReturn("state-token"); final OAuth2Operations operations = mock(OAuth2Operations.class); when(oauth2.getOAuthOperations()).thenReturn(operations); final ArgumentCaptor<OAuth2Parameters> parameters = ArgumentCaptor.forClass(OAuth2Parameters.class); when(operations.buildAuthorizeUrl(parameters.capture())).thenReturn("https: final AcquisitionFlow acquisition = credentials.acquire("providerId", URI.create("https: URI.create("/ui#state")); final CredentialFlowState expectedFlowState = new OAuth2CredentialFlowState.Builder().key("state-token") .providerId("providerId").redirectUrl("https: .returnUrl(URI.create("/ui#state")).build(); final AcquisitionFlow expected = new AcquisitionFlow.Builder().type(Type.OAUTH2) .redirectUrl("https: assertThat(acquisition).isEqualTo(expected); final OAuth2Parameters capturedParameters = parameters.getValue(); assertThat(capturedParameters.getRedirectUri()).isEqualTo("https: assertThat(capturedParameters.getScope()).isEqualTo("scope"); assertThat(capturedParameters.getState()).isEqualTo("state-token"); }
public AcquisitionFlow acquire(final String providerId, final URI baseUrl, final URI returnUrl) { final CredentialProvider credentialProvider = providerFor(providerId); final CredentialFlowState flowState = credentialProvider.prepare(providerId, baseUrl, returnUrl); return new AcquisitionFlow.Builder().type(flowState.type()).redirectUrl(flowState.getRedirectUrl()).state(flowState).build(); }
Credentials { public AcquisitionFlow acquire(final String providerId, final URI baseUrl, final URI returnUrl) { final CredentialProvider credentialProvider = providerFor(providerId); final CredentialFlowState flowState = credentialProvider.prepare(providerId, baseUrl, returnUrl); return new AcquisitionFlow.Builder().type(flowState.type()).redirectUrl(flowState.getRedirectUrl()).state(flowState).build(); } }
Credentials { public AcquisitionFlow acquire(final String providerId, final URI baseUrl, final URI returnUrl) { final CredentialProvider credentialProvider = providerFor(providerId); final CredentialFlowState flowState = credentialProvider.prepare(providerId, baseUrl, returnUrl); return new AcquisitionFlow.Builder().type(flowState.type()).redirectUrl(flowState.getRedirectUrl()).state(flowState).build(); } @Autowired  Credentials(final CredentialProviderLocator credentialProviderLocator, final EncryptionComponent encryptionComponent,
        final DataManager dataManager); }
Credentials { public AcquisitionFlow acquire(final String providerId, final URI baseUrl, final URI returnUrl) { final CredentialProvider credentialProvider = providerFor(providerId); final CredentialFlowState flowState = credentialProvider.prepare(providerId, baseUrl, returnUrl); return new AcquisitionFlow.Builder().type(flowState.type()).redirectUrl(flowState.getRedirectUrl()).state(flowState).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 AcquisitionFlow acquire(final String providerId, final URI baseUrl, final URI returnUrl) { final CredentialProvider credentialProvider = providerFor(providerId); final CredentialFlowState flowState = credentialProvider.prepare(providerId, baseUrl, returnUrl); return new AcquisitionFlow.Builder().type(flowState.type()).redirectUrl(flowState.getRedirectUrl()).state(flowState).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; }