use of com.okta.oidc.net.request.ProviderConfiguration 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);
}
use of com.okta.oidc.net.request.ProviderConfiguration 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());
}
use of com.okta.oidc.net.request.ProviderConfiguration in project okta-oidc-android by okta.
the class HttpClientImplTest method setUp.
@Before
public void setUp() throws Exception {
mEndPoint = new MockEndPoint();
String url = mEndPoint.getUrl();
OIDCConfig config = TestValues.getConfigWithUrl(url);
ProviderConfiguration providerConfiguration = TestValues.getProviderConfiguration(url);
TokenResponse tokenResponse = new Gson().fromJson(JsonStrings.TOKEN_RESPONSE, TokenResponse.class);
mHttpClient = new HttpClientImpl();
mRequest = HttpRequestBuilder.newAuthorizedRequest().uri(Uri.parse(mEndPoint.getUrl())).httpRequestMethod(ConnectionParameters.RequestMethod.POST).config(config).providerConfiguration(providerConfiguration).tokenResponse(tokenResponse).createRequest();
}
use of com.okta.oidc.net.request.ProviderConfiguration in project okta-oidc-android by okta.
the class TestValues method getProviderConfiguration.
public static ProviderConfiguration getProviderConfiguration(String url) {
ProviderConfiguration configuration = new ProviderConfiguration();
configuration.issuer = url;
configuration.revocation_endpoint = url + REVOCATION_ENDPOINT;
configuration.authorization_endpoint = url + AUTHORIZATION_ENDPOINT;
configuration.token_endpoint = url + TOKEN_ENDPOINT;
configuration.introspection_endpoint = url + INTROSPECT_ENDPOINT;
configuration.jwks_uri = url + JWKS_ENDPOINT;
configuration.registration_endpoint = url + REGISTRATION_ENDPOINT;
configuration.end_session_endpoint = url + END_SESSION_ENDPOINT;
configuration.userinfo_endpoint = url + USERINFO_ENDPOINT;
return configuration;
}
use of com.okta.oidc.net.request.ProviderConfiguration in project okta-oidc-android by okta.
the class SyncWebAuthClientImpl method processSignInResult.
@NonNull
private Result processSignInResult(StateResult result) {
if (result == null) {
return Result.error(new AuthorizationException("Result is empty", new NullPointerException()));
}
switch(result.getStatus()) {
case CANCELED:
return Result.cancel();
case ERROR:
return Result.error(result.getException());
case AUTHORIZED:
mOktaState.setCurrentState(State.TOKEN_EXCHANGE);
TokenResponse response;
try {
WebRequest authorizedRequest = mOktaState.getAuthorizeRequest();
ProviderConfiguration providerConfiguration = mOktaState.getProviderConfiguration();
AuthorizeResponse authResponse = (AuthorizeResponse) result.getAuthorizationResponse();
if (isVerificationFlow((authResponse))) {
return processEmailVerification(authResponse);
}
validateResult(result.getAuthorizationResponse(), authorizedRequest);
TokenRequest request = tokenExchange((AuthorizeResponse) result.getAuthorizationResponse(), providerConfiguration, (AuthorizeRequest) authorizedRequest);
mCurrentRequest.set(new WeakReference<>(request));
response = request.executeRequest(mHttpClient);
mOktaState.save(response);
} catch (OktaRepository.EncryptionException e) {
return Result.error(EncryptionErrors.byEncryptionException(e));
} catch (AuthorizationException e) {
return Result.error(e);
}
return Result.success();
default:
return Result.error(new AuthorizationException("StateResult with invalid status: " + result.getStatus().name(), new IllegalStateException()));
}
}
Aggregations