diff --git a/auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java b/auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java index 633b32f85..589e04ce6 100755 --- a/auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java +++ b/auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java @@ -26,6 +26,7 @@ import android.content.Context; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import com.auth0.android.Auth0; @@ -593,7 +594,7 @@ public ParameterizableRequest tokenInfo(@N * @return a request to start */ @NonNull - public DatabaseConnectionRequest createUser(@NonNull String email, @NonNull String password, @NonNull String username, @NonNull String connection) { + public DatabaseConnectionRequest createUser(@NonNull String email, @NonNull String password, @Nullable String username, @NonNull String connection) { HttpUrl url = HttpUrl.parse(auth0.getDomainUrl()).newBuilder() .addPathSegment(DB_CONNECTIONS_PATH) .addPathSegment(SIGN_UP_PATH) @@ -635,7 +636,6 @@ public DatabaseConnectionRequest createUs */ @NonNull public DatabaseConnectionRequest createUser(@NonNull String email, @NonNull String password, @NonNull String connection) { - //noinspection ConstantConditions return createUser(email, password, null, connection); } diff --git a/auth0/src/main/java/com/auth0/android/authentication/request/DelegationRequest.java b/auth0/src/main/java/com/auth0/android/authentication/request/DelegationRequest.java index 3cd093614..5c08755f9 100755 --- a/auth0/src/main/java/com/auth0/android/authentication/request/DelegationRequest.java +++ b/auth0/src/main/java/com/auth0/android/authentication/request/DelegationRequest.java @@ -25,7 +25,6 @@ package com.auth0.android.authentication.request; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import com.auth0.android.Auth0Exception; import com.auth0.android.authentication.AuthenticationException; diff --git a/auth0/src/main/java/com/auth0/android/authentication/request/ProfileRequest.java b/auth0/src/main/java/com/auth0/android/authentication/request/ProfileRequest.java index e2305e119..77982d253 100755 --- a/auth0/src/main/java/com/auth0/android/authentication/request/ProfileRequest.java +++ b/auth0/src/main/java/com/auth0/android/authentication/request/ProfileRequest.java @@ -141,11 +141,13 @@ public void start(@NonNull final BaseCallback() { @Override public void onSuccess(@Nullable final Credentials credentials) { + //noinspection ConstantConditions userInfoRequest .addHeader(HEADER_AUTHORIZATION, "Bearer " + credentials.getAccessToken()) .start(new BaseCallback() { @Override public void onSuccess(@Nullable UserProfile profile) { + //noinspection ConstantConditions callback.onSuccess(new Authentication(profile, credentials)); } diff --git a/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.java b/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.java index 4a9e0d046..7df456540 100644 --- a/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.java +++ b/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.java @@ -275,6 +275,7 @@ private void continueGetCredentials(final BaseCallback extends Callback { * * @param payload Request payload or null */ - void onSuccess(@NonNull T payload); + void onSuccess(@Nullable T payload); } diff --git a/auth0/src/main/java/com/auth0/android/provider/OAuthManager.java b/auth0/src/main/java/com/auth0/android/provider/OAuthManager.java index df893820a..35ec5e46d 100644 --- a/auth0/src/main/java/com/auth0/android/provider/OAuthManager.java +++ b/auth0/src/main/java/com/auth0/android/provider/OAuthManager.java @@ -231,6 +231,7 @@ public void onFailure(@NonNull TokenValidationException error) { @Override public void onSuccess(@Nullable SignatureVerifier signatureVerifier) { + //noinspection ConstantConditions IdTokenVerificationOptions options = new IdTokenVerificationOptions(idTokenVerificationIssuer, apiClient.getClientId(), signatureVerifier); String maxAge = parameters.get(KEY_MAX_AGE); if (!TextUtils.isEmpty(maxAge)) { diff --git a/auth0/src/main/java/com/auth0/android/provider/PKCE.java b/auth0/src/main/java/com/auth0/android/provider/PKCE.java index ac855e0fd..1aa2f04b1 100644 --- a/auth0/src/main/java/com/auth0/android/provider/PKCE.java +++ b/auth0/src/main/java/com/auth0/android/provider/PKCE.java @@ -88,6 +88,7 @@ public void getToken(String authorizationCode, @NonNull final AuthCallback callb .start(new BaseCallback() { @Override public void onSuccess(@Nullable Credentials payload) { + //noinspection ConstantConditions callback.onSuccess(payload); } diff --git a/auth0/src/main/java/com/auth0/android/provider/SignatureVerifier.java b/auth0/src/main/java/com/auth0/android/provider/SignatureVerifier.java index 6d7eb356a..f457da555 100644 --- a/auth0/src/main/java/com/auth0/android/provider/SignatureVerifier.java +++ b/auth0/src/main/java/com/auth0/android/provider/SignatureVerifier.java @@ -59,6 +59,7 @@ static void forAsymmetricAlgorithm(@Nullable final String keyId, @NonNull Authen apiClient.fetchJsonWebKeys().start(new AuthenticationCallback>() { @Override public void onSuccess(@Nullable Map jwks) { + //noinspection ConstantConditions PublicKey publicKey = jwks.get(keyId); try { callback.onSuccess(new AsymmetricSignatureVerifier(publicKey)); diff --git a/auth0/src/main/java/com/auth0/android/provider/VoidCallback.java b/auth0/src/main/java/com/auth0/android/provider/VoidCallback.java index a2c1aec09..575cdf59b 100644 --- a/auth0/src/main/java/com/auth0/android/provider/VoidCallback.java +++ b/auth0/src/main/java/com/auth0/android/provider/VoidCallback.java @@ -24,8 +24,6 @@ package com.auth0.android.provider; -import android.support.annotation.Nullable; - import com.auth0.android.Auth0Exception; import com.auth0.android.callback.BaseCallback; @@ -34,6 +32,4 @@ */ @SuppressWarnings("WeakerAccess") public interface VoidCallback extends BaseCallback { - @Override - void onSuccess(@Nullable Void payload); } \ No newline at end of file diff --git a/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java b/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java index 4cbbc014a..0eec97bd8 100644 --- a/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java +++ b/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java @@ -139,6 +139,7 @@ public void start(@NonNull Context context, @NonNull VoidCallback callback) { if (returnToUrl == null) { returnToUrl = CallbackHelper.getCallbackUri(scheme, context.getApplicationContext().getPackageName(), account.getDomainUrl()); } + //noinspection ConstantConditions LogoutManager logoutManager = new LogoutManager(this.account, callback, returnToUrl); logoutManager.setCustomTabsOptions(ctOptions); diff --git a/auth0/src/main/java/com/auth0/android/request/internal/ManagementErrorBuilder.java b/auth0/src/main/java/com/auth0/android/request/internal/ManagementErrorBuilder.java index ae9561939..339c93931 100644 --- a/auth0/src/main/java/com/auth0/android/request/internal/ManagementErrorBuilder.java +++ b/auth0/src/main/java/com/auth0/android/request/internal/ManagementErrorBuilder.java @@ -1,6 +1,7 @@ package com.auth0.android.request.internal; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.auth0.android.Auth0Exception; import com.auth0.android.management.ManagementException; @@ -30,7 +31,7 @@ public ManagementException from(@NonNull Map values) { @NonNull @Override - public ManagementException from(@NonNull String payload, int statusCode) { + public ManagementException from(@Nullable String payload, int statusCode) { return new ManagementException(payload, statusCode); } } diff --git a/auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.java b/auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.java index f7d03b8dc..997d79fef 100755 --- a/auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.java @@ -843,7 +843,6 @@ public void shouldNotSendNullUsernameOnSignUp() throws Exception { mockAPI.willReturnSuccessfulSignUp(); final MockAuthenticationCallback callback = new MockAuthenticationCallback<>(); - //noinspection ConstantConditions client.createUser(SUPPORT_AUTH0_COM, PASSWORD, null, MY_CONNECTION) .start(callback); @@ -864,7 +863,6 @@ public void shouldNotSendNullUsernameOnSignUp() throws Exception { public void shouldNotSendNullUsernameOnSignUpSync() throws Exception { mockAPI.willReturnSuccessfulSignUp(); - //noinspection ConstantConditions final DatabaseUser user = client.createUser(SUPPORT_AUTH0_COM, PASSWORD, null, MY_CONNECTION) .execute(); diff --git a/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.java b/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.java index fc205bd96..1faf82cc3 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.java @@ -172,13 +172,13 @@ public void shouldThrowOnSetIfCredentialsDoesNotHaveIdTokenOrAccessToken() { manager.saveCredentials(credentials); } - @SuppressWarnings("ConstantConditions") @Test public void shouldThrowOnSetIfCredentialsDoesNotHaveExpiresAt() { exception.expect(CredentialsManagerException.class); exception.expectMessage("Credentials must have a valid date of expiration and a valid access_token or id_token value."); Date date = null; + //noinspection ConstantConditions Credentials credentials = new CredentialsMock("idToken", "accessToken", "type", "refreshToken", date, "scope"); manager.saveCredentials(credentials); } diff --git a/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.java b/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.java index 389b71e9f..69b82a3d5 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.java @@ -277,13 +277,13 @@ public void shouldThrowOnSaveIfCredentialsDoesNotHaveIdTokenOrAccessToken() { manager.saveCredentials(credentials); } - @SuppressWarnings("ConstantConditions") @Test public void shouldThrowOnSaveIfCredentialsDoesNotHaveExpiresAt() { exception.expect(CredentialsManagerException.class); exception.expectMessage("Credentials must have a valid date of expiration and a valid access_token or id_token value."); Date date = null; + //noinspection ConstantConditions Credentials credentials = new CredentialsMock("idToken", "accessToken", "type", "refreshToken", date, "scope"); prepareJwtDecoderMock(new Date()); manager.saveCredentials(credentials); diff --git a/auth0/src/test/java/com/auth0/android/authentication/storage/SharedPreferencesStorageTest.java b/auth0/src/test/java/com/auth0/android/authentication/storage/SharedPreferencesStorageTest.java index 9043137ff..0d7d7a183 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/storage/SharedPreferencesStorageTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/storage/SharedPreferencesStorageTest.java @@ -67,11 +67,11 @@ public void shouldCreateWithCustomPreferencesFileName() { verify(context).getSharedPreferences("my-preferences-file", Context.MODE_PRIVATE); } - @SuppressWarnings("ConstantConditions") @Test public void shouldThrowOnCreateIfCustomPreferencesFileNameIsNull() { exception.expect(IllegalArgumentException.class); exception.expectMessage("The SharedPreferences name is invalid"); + //noinspection ConstantConditions new SharedPreferencesStorage(context, null); } @@ -184,11 +184,11 @@ public void shouldRetrieveBooleanValueFromPreferences() { //Remove - @SuppressWarnings("ConstantConditions") @Test public void shouldRemovePreferencesKeyOnNullStringValue() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); String value = null; + //noinspection ConstantConditions storage.store("name", value); verify(sharedPreferencesEditor).remove("name"); verify(sharedPreferencesEditor).apply();