Search in sources :

Example 11 with ProviderConfiguration

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

the class SyncSessionClientImpl method migrateTo.

@Override
public void migrateTo(EncryptionManager manager) throws AuthorizationException {
    try {
        final ProviderConfiguration providerConfiguration = mOktaState.getProviderConfiguration();
        final TokenResponse tokenResponse = mOktaState.getTokenResponse();
        final WebRequest authorizedRequest = mOktaState.getAuthorizeRequest();
        clear();
        mOktaState.setEncryptionManager(manager);
        mOktaState.save(providerConfiguration);
        mOktaState.save(tokenResponse);
        mOktaState.save(authorizedRequest);
    } catch (OktaRepository.EncryptionException e) {
        throw AuthorizationException.EncryptionErrors.byEncryptionException(e);
    }
}
Also used : TokenResponse(com.okta.oidc.net.response.TokenResponse) WebRequest(com.okta.oidc.net.request.web.WebRequest) OktaRepository(com.okta.oidc.storage.OktaRepository) ProviderConfiguration(com.okta.oidc.net.request.ProviderConfiguration)

Example 12 with ProviderConfiguration

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

the class SyncWebAuthClientImpl method signIn.

@Override
@WorkerThread
public Result signIn(@NonNull final Activity activity, @Nullable AuthenticationPayload payload) {
    mCancel.set(false);
    try {
        if (!isRedirectUrisRegistered(mOidcConfig.getRedirectUri(), activity)) {
            String errorDescription = "No uri registered to handle redirect " + "or multiple applications registered";
            Log.e(TAG, errorDescription);
            throw new AuthorizationException(TYPE_OAUTH_REGISTRATION_ERROR, INVALID_REDIRECT_URI.code, INVALID_REDIRECT_URI.error, errorDescription, null, null);
        }
        ProviderConfiguration configuration = obtainNewConfiguration();
        checkIfCanceled();
        WebRequest request = new AuthorizeRequest.Builder().config(mOidcConfig).providerConfiguration(configuration).authenticationPayload(payload).create();
        mOktaState.save(request);
        mOktaState.setCurrentState(State.SIGN_IN_REQUEST);
        StateResult authResult = startSignIn(activity, request);
        return processSignInResult(authResult);
    } catch (AuthorizationException e) {
        return Result.error(e);
    } catch (IOException | InterruptedException e) {
        return Result.cancel();
    } catch (OktaRepository.EncryptionException e) {
        return Result.error(EncryptionErrors.byEncryptionException(e));
    } finally {
        resetCurrentState();
    }
}
Also used : WebRequest(com.okta.oidc.net.request.web.WebRequest) AuthorizationException(com.okta.oidc.util.AuthorizationException) StateResult(com.okta.oidc.AuthenticationResultHandler.StateResult) OktaRepository(com.okta.oidc.storage.OktaRepository) IOException(java.io.IOException) ProviderConfiguration(com.okta.oidc.net.request.ProviderConfiguration) WorkerThread(androidx.annotation.WorkerThread)

Example 13 with ProviderConfiguration

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

the class OktaStateTest method getProviderConfiguration.

@Test
public void getProviderConfiguration() throws OktaRepository.EncryptionException {
    ProviderConfiguration providerConfiguration = TestValues.getProviderConfiguration(CUSTOM_URL);
    mOktaState.save(providerConfiguration);
    ProviderConfiguration expected = mOktaState.getProviderConfiguration();
    assertNotNull(expected);
    assertEquals(providerConfiguration.persist(), expected.persist());
}
Also used : ProviderConfiguration(com.okta.oidc.net.request.ProviderConfiguration) Test(org.junit.Test)

Example 14 with ProviderConfiguration

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

the class OktaStateTest method validateDelete.

@Test
public void validateDelete() throws OktaRepository.EncryptionException {
    TokenResponse tokenResponse = TestValues.getTokenResponse();
    ProviderConfiguration providerConfiguration = TestValues.getProviderConfiguration(CUSTOM_URL);
    mOktaState.save(tokenResponse);
    mOktaState.save(providerConfiguration);
    mOktaState.delete(tokenResponse);
    assertNull(mOktaState.getTokenResponse());
    assertNotNull(mOktaState.getProviderConfiguration());
}
Also used : TokenResponse(com.okta.oidc.net.response.TokenResponse) ProviderConfiguration(com.okta.oidc.net.request.ProviderConfiguration) Test(org.junit.Test)

Example 15 with ProviderConfiguration

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

the class TestValues method getOAuth2ProviderConfiguration.

public static ProviderConfiguration getOAuth2ProviderConfiguration(String url) {
    ProviderConfiguration configuration = getProviderConfiguration(url);
    configuration.userinfo_endpoint = null;
    return configuration;
}
Also used : ProviderConfiguration(com.okta.oidc.net.request.ProviderConfiguration)

Aggregations

ProviderConfiguration (com.okta.oidc.net.request.ProviderConfiguration)15 TokenResponse (com.okta.oidc.net.response.TokenResponse)7 OktaRepository (com.okta.oidc.storage.OktaRepository)6 Test (org.junit.Test)4 ConfigurationRequest (com.okta.oidc.net.request.ConfigurationRequest)3 WebRequest (com.okta.oidc.net.request.web.WebRequest)3 AuthorizationException (com.okta.oidc.util.AuthorizationException)3 Uri (android.net.Uri)2 WorkerThread (androidx.annotation.WorkerThread)2 AuthorizedRequest (com.okta.oidc.net.request.AuthorizedRequest)2 TokenRequest (com.okta.oidc.net.request.TokenRequest)2 AuthorizeResponse (com.okta.oidc.net.response.web.AuthorizeResponse)2 IOException (java.io.IOException)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 NonNull (androidx.annotation.NonNull)1 RestrictTo (androidx.annotation.RestrictTo)1 Gson (com.google.gson.Gson)1 StateResult (com.okta.oidc.AuthenticationResultHandler.StateResult)1 OIDCConfig (com.okta.oidc.OIDCConfig)1 NativeAuthorizeRequest (com.okta.oidc.net.request.NativeAuthorizeRequest)1