Search in sources :

Example 1 with ConfigurationRequest

use of com.okta.oidc.net.request.ConfigurationRequest in project okta-oidc-android by okta.

the class SyncWebAuthClientTest method configurationRequestFailure.

@Test
public void configurationRequestFailure() throws AuthorizationException, InterruptedException {
    mExpectedEx.expect(AuthorizationException.class);
    mEndPoint.enqueueConfigurationFailure();
    ConfigurationRequest request = mSyncWebAuth.configurationRequest();
    ProviderConfiguration configuration = request.executeRequest(mHttpClient);
    RecordedRequest recordedRequest = mEndPoint.takeRequest();
    assertThat(recordedRequest.getPath(), equalTo("//.well-known/openid-configuration?client_id=CLIENT_ID"));
    assertNull(configuration);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ConfigurationRequest(com.okta.oidc.net.request.ConfigurationRequest) ProviderConfiguration(com.okta.oidc.net.request.ProviderConfiguration) Test(org.junit.Test)

Example 2 with ConfigurationRequest

use of com.okta.oidc.net.request.ConfigurationRequest in project okta-oidc-android by okta.

the class SyncWebAuthClientTest method configurationRequest.

@Test
public void configurationRequest() throws AuthorizationException, InterruptedException {
    mEndPoint.enqueueConfigurationSuccess();
    ConfigurationRequest request = mSyncWebAuth.configurationRequest();
    ProviderConfiguration configuration = request.executeRequest(mHttpClient);
    RecordedRequest recordedRequest = mEndPoint.takeRequest();
    assertThat(recordedRequest.getPath(), equalTo("//.well-known/openid-configuration?client_id=CLIENT_ID"));
    assertNotNull(configuration);
    assertEquals(mGson.fromJson(PROVIDER_CONFIG, ProviderConfiguration.class).persist(), configuration.persist());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ConfigurationRequest(com.okta.oidc.net.request.ConfigurationRequest) ProviderConfiguration(com.okta.oidc.net.request.ProviderConfiguration) Test(org.junit.Test)

Example 3 with ConfigurationRequest

use of com.okta.oidc.net.request.ConfigurationRequest in project okta-oidc-android by okta.

the class AuthAPI method obtainNewConfiguration.

protected ProviderConfiguration obtainNewConfiguration() throws AuthorizationException {
    try {
        ProviderConfiguration config = mOktaState.getProviderConfiguration();
        Uri discoveryUri = mOidcConfig.getDiscoveryUri();
        if (discoveryUri != null) {
            if (config == null || !discoveryUri.toString().contains(config.issuer)) {
                mOktaState.setCurrentState(State.OBTAIN_CONFIGURATION);
                ConfigurationRequest request = configurationRequest();
                mCurrentRequest.set(new WeakReference<>(request));
                config = request.executeRequest(mHttpClient);
                mOktaState.save(config);
            }
        } else {
            config = new ProviderConfiguration(mOidcConfig.getCustomConfiguration());
            mOktaState.save(config);
        }
        return config;
    } catch (OktaRepository.EncryptionException e) {
        throw AuthorizationException.EncryptionErrors.byEncryptionException(e);
    }
}
Also used : ConfigurationRequest(com.okta.oidc.net.request.ConfigurationRequest) OktaRepository(com.okta.oidc.storage.OktaRepository) Uri(android.net.Uri) ProviderConfiguration(com.okta.oidc.net.request.ProviderConfiguration)

Aggregations

ConfigurationRequest (com.okta.oidc.net.request.ConfigurationRequest)3 ProviderConfiguration (com.okta.oidc.net.request.ProviderConfiguration)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 Test (org.junit.Test)2 Uri (android.net.Uri)1 OktaRepository (com.okta.oidc.storage.OktaRepository)1