@Test public void shouldAcquireOAuth1aCredentials() { final OAuth1ConnectionFactory<?> oauth1 = mock(OAuth1ConnectionFactory.class); @SuppressWarnings("unchecked") final Applicator<OAuthToken> applicator = mock(Applicator.class); when(locator.providerWithId("providerId")) .thenReturn(new OAuth1CredentialProvider<>("providerId", oauth1, applicator)); final OAuth1Operations operations = mock(OAuth1Operations.class); when(oauth1.getOAuthOperations()).thenReturn(operations); when(operations.getVersion()).thenReturn(OAuth1Version.CORE_10_REVISION_A); final OAuthToken token = new OAuthToken("value", "secret"); when(operations.fetchRequestToken("https: final ArgumentCaptor<OAuth1Parameters> parameters = ArgumentCaptor.forClass(OAuth1Parameters.class); when(operations.buildAuthorizeUrl(eq("value"), parameters.capture())) .thenReturn("https: final AcquisitionFlow acquisition = credentials.acquire("providerId", URI.create("https: URI.create("https: final CredentialFlowState expectedFlowState = new OAuth1CredentialFlowState.Builder().providerId("providerId") .redirectUrl("https: .token(token).build(); final AcquisitionFlow expected = new AcquisitionFlow.Builder().type(Type.OAUTH1) .redirectUrl("https: assertThat(acquisition).isEqualToIgnoringGivenFields(expected, "state"); final Optional<CredentialFlowState> maybeState = acquisition.state(); assertThat(maybeState).isPresent(); final CredentialFlowState state = maybeState.get(); assertThat(state).isEqualToIgnoringGivenFields(expectedFlowState, "key"); assertThat(state.getKey()).isNotNull(); final OAuth1Parameters oAuth1Parameters = parameters.getValue(); assertThat(oAuth1Parameters.getCallbackUrl()).isNull(); }
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; }