diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-10-04 14:53:59 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-10-04 14:53:59 +0000 |
commit | 05ff90fafb6413aeaf9c1a099f900afd3af0788a (patch) | |
tree | 703a67d6f604004d5914fbbd7214b5dba19bfead | |
parent | 636acbbbfdf67dad08aa267edfbd6d31a1a8b309 (diff) | |
parent | 8c3107a6b337e9f29633f7b6ae38613f8319488e (diff) | |
download | gsma_services-05ff90fafb6413aeaf9c1a099f900afd3af0788a.tar.gz |
Snap for 10900817 from 8c3107a6b337e9f29633f7b6ae38613f8319488e to sdk-releaseplatform-tools-34.0.5
Change-Id: Ia7cf8bdf926c0bd318655c1fcd7b5e44641834ff
5 files changed, 131 insertions, 109 deletions
@@ -1,3 +1,5 @@ amruthr@google.com jackyu@google.com rgreenwalt@google.com +sasindran@google.com +sarahchin@google.com diff --git a/ts43authentication/Android.bp b/ts43authentication/Android.bp index f9178a4..1a13d63 100644 --- a/ts43authentication/Android.bp +++ b/ts43authentication/Android.bp @@ -11,6 +11,7 @@ java_library { "src/**/*.java", ], static_libs: [ + "androidx.annotation_annotation", "service-entitlement", ], } diff --git a/ts43authentication/AndroidManifest.xml b/ts43authentication/AndroidManifest.xml new file mode 100644 index 0000000..dca0379 --- /dev/null +++ b/ts43authentication/AndroidManifest.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + package="com.android.libraries.ts43authentication"> + <uses-sdk android:minSdkVersion="29"/> +</manifest> diff --git a/ts43authentication/src/com/android/libraries/ts43authentication/AuthenticationException.java b/ts43authentication/src/com/android/libraries/ts43authentication/AuthenticationException.java index bed5877..707a7bf 100644 --- a/ts43authentication/src/com/android/libraries/ts43authentication/AuthenticationException.java +++ b/ts43authentication/src/com/android/libraries/ts43authentication/AuthenticationException.java @@ -16,12 +16,11 @@ package com.android.libraries.ts43authentication; -import android.annotation.IntDef; -import android.annotation.NonNull; -import android.annotation.Nullable; import android.os.OutcomeReceiver; import android.os.PersistableBundle; +import androidx.annotation.IntDef; + import com.android.libraries.entitlement.ServiceEntitlementException; import java.lang.annotation.Retention; @@ -90,8 +89,12 @@ public class AuthenticationException extends Exception { */ public static final int ERROR_INVALID_HTTP_RESPONSE = 8; + /** + * Authentication errors that can be returned by the TS.43 authentication library or + * service entitlement library. + */ @Retention(RetentionPolicy.SOURCE) - @IntDef(prefix = {"ERROR_"}, value = { + @IntDef({ ERROR_UNSPECIFIED, ERROR_INVALID_APP_NAME, ERROR_MUST_USE_OIDC, @@ -117,10 +120,10 @@ public class AuthenticationException extends Exception { @AuthenticationError private final int mError; private final int mHttpStatusCode; - @NonNull private final String mRetryAfter; + private final String mRetryAfter; private AuthenticationException(@AuthenticationError int error, int httpStatusCode, - @NonNull String retryAfter, @NonNull String message) { + String retryAfter, String message) { super(message); mError = error; mHttpStatusCode = httpStatusCode; @@ -129,18 +132,20 @@ public class AuthenticationException extends Exception { /** * Create an AuthenticationException for the given {@link AuthenticationError}. + * * @param error The authentication error. * @param message The detail message with more information about the exception. */ - public AuthenticationException(@AuthenticationError int error, @NonNull String message) { + public AuthenticationException(int error, String message) { this(error, HTTP_STATUS_CODE_UNSPECIFIED, RETRY_AFTER_UNSPECIFIED, message); } /** * Create an AuthenticationException from the given {@link ServiceEntitlementException}. + * * @param exception The service entitlement exception from the TS.43 library. */ - public AuthenticationException(@NonNull ServiceEntitlementException exception) { + public AuthenticationException(ServiceEntitlementException exception) { this(convertToAuthenticationError(exception.getErrorCode()), convertToHttpStatusCode(exception.getHttpStatus()), convertToRetryAfter(exception.getRetryAfter()), exception.getMessage()); @@ -168,7 +173,7 @@ public class AuthenticationException extends Exception { * {@code HTTP-date} or the number of seconds to delay, as defined in * <a href="https://tools.ietf.org/html/rfc7231#section-7.1.3">RFC 7231</a> */ - @NonNull public String getRetryAfter() { + public String getRetryAfter() { return mRetryAfter; } @@ -201,7 +206,7 @@ public class AuthenticationException extends Exception { return httpStatusCode; } - private static String convertToRetryAfter(@Nullable String retryAfter) { + private static String convertToRetryAfter(String retryAfter) { if (retryAfter == null || retryAfter.isEmpty() || retryAfter.equals(ServiceEntitlementException.RETRY_AFTER_UNSPECIFIED)) { return RETRY_AFTER_UNSPECIFIED; diff --git a/ts43authentication/src/com/android/libraries/ts43authentication/Ts43AuthenticationLibrary.java b/ts43authentication/src/com/android/libraries/ts43authentication/Ts43AuthenticationLibrary.java index 50220c9..5a443b5 100644 --- a/ts43authentication/src/com/android/libraries/ts43authentication/Ts43AuthenticationLibrary.java +++ b/ts43authentication/src/com/android/libraries/ts43authentication/Ts43AuthenticationLibrary.java @@ -16,10 +16,6 @@ package com.android.libraries.ts43authentication; -import android.annotation.CallbackExecutor; -import android.annotation.NonNull; -import android.annotation.Nullable; -import android.annotation.StringDef; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -34,6 +30,9 @@ import android.os.PersistableBundle; import android.telephony.SubscriptionInfo; import android.util.Log; +import androidx.annotation.Nullable; +import androidx.annotation.StringDef; + import com.android.libraries.entitlement.ServiceEntitlementException; import com.android.libraries.entitlement.Ts43Authentication; @@ -45,6 +44,7 @@ import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.ArrayList; import java.util.HexFormat; +import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.locks.ReentrantLock; @@ -54,7 +54,7 @@ import java.util.concurrent.locks.ReentrantLock; * {@link AuthenticationException} on failure. */ public class Ts43AuthenticationLibrary extends Handler { - private static final String TAG = "Ts43AuthenticationLibrary"; + private static final String TAG = "Ts43AuthLibrary"; /** * Configuration key for the list of {@code SHA256} signing certificates and packages that are @@ -82,8 +82,11 @@ public class Ts43AuthenticationLibrary extends Handler { */ public static final String KEY_APPEND_SHA_TO_APP_NAME_BOOL = "append_sha_to_app_name"; + /** + * Configuration keys for the {@link PersistableBundle} passed to authentication requests. + */ @Retention(RetentionPolicy.SOURCE) - @StringDef(prefix = {"KEY_"}, value = { + @StringDef({ KEY_ALLOWED_CERTIFICATES_STRING_ARRAY, KEY_APPEND_SHA_TO_APP_NAME_BOOL, }) @@ -93,37 +96,36 @@ public class Ts43AuthenticationLibrary extends Handler { private static final int EVENT_REQUEST_OIDC_AUTHENTICATION_SERVER = 1; private static final int EVENT_REQUEST_OIDC_AUTHENTICATION = 2; - @NonNull private final ReentrantLock mLock = new ReentrantLock(); - @NonNull private final Context mContext; - @NonNull private final PackageManager mPackageManager; + private final ReentrantLock mLock = new ReentrantLock(); + private final Context mContext; + private final PackageManager mPackageManager; /** * Create an instance of the TS.43 Authentication Library. + * * @param context The application context. * @param looper The looper to run authentication requests on. */ - public Ts43AuthenticationLibrary(@NonNull Context context, @NonNull Looper looper) { + public Ts43AuthenticationLibrary(Context context, Looper looper) { super(looper); mContext = context; mPackageManager = mContext.getPackageManager(); } private static class EapAkaAuthenticationRequest { - @NonNull private final String mAppName; + private final String mAppName; @Nullable private final String mAppVersion; private final int mSlotIndex; - @NonNull private final URL mEntitlementServerAddress; + private final URL mEntitlementServerAddress; @Nullable private final String mEntitlementVersion; - @NonNull private final String mAppId; - @NonNull private final Executor mExecutor; - @NonNull private final OutcomeReceiver< + private final String mAppId; + private final Executor mExecutor; + private final OutcomeReceiver< Ts43Authentication.Ts43AuthToken, AuthenticationException> mCallback; - private EapAkaAuthenticationRequest(@NonNull String appName, @Nullable String appVersion, - int slotIndex, @NonNull URL entitlementServerAddress, - @Nullable String entitlementVersion, @NonNull String appId, - @NonNull @CallbackExecutor Executor executor, - @NonNull OutcomeReceiver< + private EapAkaAuthenticationRequest(String appName, @Nullable String appVersion, + int slotIndex, URL entitlementServerAddress, @Nullable String entitlementVersion, + String appId, Executor executor, OutcomeReceiver< Ts43Authentication.Ts43AuthToken, AuthenticationException> callback) { mAppName = appName; mAppVersion = appVersion; @@ -137,20 +139,19 @@ public class Ts43AuthenticationLibrary extends Handler { } private static class OidcAuthenticationServerRequest { - @NonNull private final String mAppName; + private final String mAppName; @Nullable private final String mAppVersion; private final int mSlotIndex; - @NonNull private final URL mEntitlementServerAddress; + private final URL mEntitlementServerAddress; @Nullable private final String mEntitlementVersion; - @NonNull private final String mAppId; - @NonNull private final Executor mExecutor; - @NonNull private final OutcomeReceiver<URL, AuthenticationException> mCallback; - - private OidcAuthenticationServerRequest(@NonNull String appName, - @Nullable String appVersion, int slotIndex, @NonNull URL entitlementServerAddress, - @Nullable String entitlementVersion, @NonNull String appId, - @NonNull @CallbackExecutor Executor executor, - @NonNull OutcomeReceiver<URL, AuthenticationException> callback) { + private final String mAppId; + private final Executor mExecutor; + private final OutcomeReceiver<URL, AuthenticationException> mCallback; + + private OidcAuthenticationServerRequest(String appName, @Nullable String appVersion, + int slotIndex, URL entitlementServerAddress, @Nullable String entitlementVersion, + String appId, Executor executor, + OutcomeReceiver<URL, AuthenticationException> callback) { mAppName = appName; mAppVersion = appVersion; mSlotIndex = slotIndex; @@ -163,17 +164,15 @@ public class Ts43AuthenticationLibrary extends Handler { } private static class OidcAuthenticationRequest { - @NonNull private final URL mEntitlementServerAddress; + private final URL mEntitlementServerAddress; @Nullable private final String mEntitlementVersion; - @NonNull private final URL mAesUrl; - @NonNull private final Executor mExecutor; - @NonNull private final OutcomeReceiver< + private final URL mAesUrl; + private final Executor mExecutor; + private final OutcomeReceiver< Ts43Authentication.Ts43AuthToken, AuthenticationException> mCallback; - private OidcAuthenticationRequest(@NonNull URL entitlementServerAddress, - @Nullable String entitlementVersion, @NonNull URL aesUrl, - @NonNull @CallbackExecutor Executor executor, - @NonNull OutcomeReceiver< + private OidcAuthenticationRequest(URL entitlementServerAddress, + @Nullable String entitlementVersion, URL aesUrl, Executor executor, OutcomeReceiver< Ts43Authentication.Ts43AuthToken, AuthenticationException> callback) { mEntitlementServerAddress = entitlementServerAddress; mEntitlementVersion = entitlementVersion; @@ -188,7 +187,7 @@ public class Ts43AuthenticationLibrary extends Handler { * TS.43 Service Entitlement Configuration section 2.8.1. * * @param configs The configurations that should be applied to this authentication request. - * The keys of the bundle must be one of the {@link ConfigurationKey}s. + * The keys of the bundle must be in {@link ConfigurationKey}. * @param packageName The package name for the calling application, used to validate the * identity of the calling application. This will be sent as-is as the {@code app_name} * in the HTTP GET request to the entitlement server unless @@ -210,11 +209,9 @@ public class Ts43AuthenticationLibrary extends Handler { * If the authentication fails, {@link OutcomeReceiver#onError(Throwable)} will return an * {@link AuthenticationException} with the failure details. */ - public void requestEapAkaAuthentication(@NonNull PersistableBundle configs, - @NonNull String packageName, @Nullable String appVersion, int slotIndex, - @NonNull URL entitlementServerAddress, @Nullable String entitlementVersion, - @NonNull String appId, @NonNull @CallbackExecutor Executor executor, - @NonNull OutcomeReceiver< + public void requestEapAkaAuthentication(PersistableBundle configs, String packageName, + @Nullable String appVersion, int slotIndex, URL entitlementServerAddress, + @Nullable String entitlementVersion, String appId, Executor executor, OutcomeReceiver< Ts43Authentication.Ts43AuthToken, AuthenticationException> callback) { String[] allowedPackageInfo = configs.getStringArray(KEY_ALLOWED_CERTIFICATES_STRING_ARRAY); String certificate = getMatchingCertificate(allowedPackageInfo, packageName); @@ -224,9 +221,9 @@ public class Ts43AuthenticationLibrary extends Handler { entitlementServerAddress, entitlementVersion, appId, executor, callback)) .sendToTarget(); } else { - executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( - new AuthenticationException(AuthenticationException.ERROR_INVALID_APP_NAME, - "Failed to verify the identity of the calling application")))); + executor.execute(() -> callback.onError(new AuthenticationException( + AuthenticationException.ERROR_INVALID_APP_NAME, + "Failed to verify the identity of the calling application"))); } } @@ -240,7 +237,7 @@ public class Ts43AuthenticationLibrary extends Handler { * authentication token. * * @param configs The configurations that should be applied to this authentication request. - * The keys of the bundle must be one of the {@link ConfigurationKey}s. + * The keys of the bundle must be in {@link ConfigurationKey}. * @param packageName The package name for the calling application, used to validate the * identity of the calling application. This will be sent as-is as the {@code app_name} * in the HTTP GET request to the entitlement server unless @@ -264,11 +261,11 @@ public class Ts43AuthenticationLibrary extends Handler { * If the authentication fails, {@link OutcomeReceiver#onError(Throwable)} will return an * {@link AuthenticationException} with the failure details. */ - public void requestOidcAuthenticationServer(@NonNull PersistableBundle configs, - @NonNull String packageName, @Nullable String appVersion, int slotIndex, - @NonNull URL entitlementServerAddress, @Nullable String entitlementVersion, - @NonNull String appId, @NonNull @CallbackExecutor Executor executor, - @NonNull OutcomeReceiver<URL, AuthenticationException> callback) { + public void requestOidcAuthenticationServer(PersistableBundle configs, + String packageName, @Nullable String appVersion, int slotIndex, + URL entitlementServerAddress, @Nullable String entitlementVersion, + String appId, Executor executor, + OutcomeReceiver<URL, AuthenticationException> callback) { String[] allowedPackageInfo = configs.getStringArray(KEY_ALLOWED_CERTIFICATES_STRING_ARRAY); String certificate = getMatchingCertificate(allowedPackageInfo, packageName); if (isCallingPackageAllowed(allowedPackageInfo, packageName, certificate)) { @@ -278,9 +275,9 @@ public class Ts43AuthenticationLibrary extends Handler { entitlementServerAddress, entitlementVersion, appId, executor, callback)).sendToTarget(); } else { - executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( - new AuthenticationException(AuthenticationException.ERROR_INVALID_APP_NAME, - "Failed to verify the identity of the calling application")))); + executor.execute(() -> callback.onError(new AuthenticationException( + AuthenticationException.ERROR_INVALID_APP_NAME, + "Failed to verify the identity of the calling application"))); } } @@ -289,7 +286,7 @@ public class Ts43AuthenticationLibrary extends Handler { * TS.43 Service Entitlement Configuration section 2.8.2. * * @param configs The configurations that should be applied to this authentication request. - * The keys of the bundle must be one of the {@link ConfigurationKey}s. + * The keys of the bundle must be in {@link ConfigurationKey}. * @param packageName The package name for the calling application, used to validate the * identity of the calling application. * @param entitlementServerAddress The entitlement server address. @@ -304,11 +301,10 @@ public class Ts43AuthenticationLibrary extends Handler { * If the authentication fails, {@link OutcomeReceiver#onError(Throwable)} will return an * {@link AuthenticationException} with the failure details. */ - public void requestOidcAuthentication(@NonNull PersistableBundle configs, - @NonNull String packageName, @NonNull URL entitlementServerAddress, - @Nullable String entitlementVersion, @NonNull URL aesUrl, - @NonNull @CallbackExecutor Executor executor, - @NonNull OutcomeReceiver< + public void requestOidcAuthentication(PersistableBundle configs, + String packageName, URL entitlementServerAddress, + @Nullable String entitlementVersion, URL aesUrl, Executor executor, + OutcomeReceiver< Ts43Authentication.Ts43AuthToken, AuthenticationException> callback) { String[] allowedPackageInfo = configs.getStringArray(KEY_ALLOWED_CERTIFICATES_STRING_ARRAY); String certificate = getMatchingCertificate(allowedPackageInfo, packageName); @@ -317,14 +313,14 @@ public class Ts43AuthenticationLibrary extends Handler { entitlementServerAddress, entitlementVersion, aesUrl, executor, callback)) .sendToTarget(); } else { - executor.execute(() -> Binder.withCleanCallingIdentity(() -> callback.onError( - new AuthenticationException(AuthenticationException.ERROR_INVALID_APP_NAME, - "Failed to verify the identity of the calling application")))); + executor.execute(() -> callback.onError(new AuthenticationException( + AuthenticationException.ERROR_INVALID_APP_NAME, + "Failed to verify the identity of the calling application"))); } } @Nullable private String getMatchingCertificate(@Nullable String[] allowedPackageInfo, - @NonNull String packageName) { + String packageName) { if (allowedPackageInfo == null || allowedPackageInfo.length == 0) { // No need to find a matching certificates if the allowlist is empty. Log.d(TAG, "No need to find a matching certificate because the allowlist is empty"); @@ -334,9 +330,9 @@ public class Ts43AuthenticationLibrary extends Handler { // At this point an allowlist exists. A matching certificate must be found in order for // the authentication request to be validated. If this method returns {@code null} because // a matching certificate is unable to be found, the authentication request will be denied. - ArrayList<String> allowedCertificates = + List<String> allowedCertificates = getAllowedCertificatesForPackage(allowedPackageInfo, packageName); - if (allowedCertificates.size() == 0) { + if (allowedCertificates.isEmpty()) { // If there are no allowed certificates for the given package, return null. Log.e(TAG, "No allowed certificates found for package: " + packageName); return null; @@ -372,12 +368,12 @@ public class Ts43AuthenticationLibrary extends Handler { return null; } - @NonNull private ArrayList<String> getAllowedCertificatesForPackage( - @NonNull String[] allowedPackageInfo, @NonNull String packageName) { - ArrayList<String> allowedCertificates = new ArrayList<>(); + private List<String> getAllowedCertificatesForPackage(String[] allowedPackageInfo, + String packageName) { + List<String> allowedCertificates = new ArrayList<>(); for (String packageInfo : allowedPackageInfo) { // packageInfo format: 1) "SHA256" or 2) "SHA256:package1,package2,package3..." - String[] splitPackageInfo = packageInfo.split(":"); + String[] splitPackageInfo = packageInfo.split(":", -1); if (splitPackageInfo.length == 1) { // Case 1: Certificate only allowedCertificates.add(packageInfo); @@ -385,7 +381,7 @@ public class Ts43AuthenticationLibrary extends Handler { // Case 2: Certificate and allowed packages String certificate = splitPackageInfo[0]; String packages = splitPackageInfo[1]; - for (String allowedPackage : packages.split(",")) { + for (String allowedPackage : packages.split(",", -1)) { // Add the certificate only if the package name is specified in the allowlist. if (allowedPackage.equals(packageName)) { allowedCertificates.add(certificate); @@ -397,11 +393,11 @@ public class Ts43AuthenticationLibrary extends Handler { return allowedCertificates; } - @Nullable private Signature getMainPackageSignature(@NonNull String packageName) { + @Nullable private Signature getMainPackageSignature(String packageName) { PackageInfo packageInfo; try { - packageInfo = mPackageManager.getPackageInfo( - packageName, PackageManager.GET_SIGNING_CERTIFICATES); + packageInfo = mPackageManager.getPackageInfo(packageName, + PackageManager.PackageInfoFlags.of(PackageManager.GET_SIGNING_CERTIFICATES)); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Unable to find package name: " + packageName); return null; @@ -422,7 +418,7 @@ public class Ts43AuthenticationLibrary extends Handler { } } } - if (signatures == null && signatures[index] != null) { + if (signatures == null || signatures[index] == null) { Log.e(TAG, "Unable to find package signatures for package: " + packageName); return null; } else { @@ -433,7 +429,7 @@ public class Ts43AuthenticationLibrary extends Handler { } private boolean isCallingPackageAllowed(@Nullable String[] allowedPackageInfo, - @NonNull String packageName, @Nullable String certificate) { + String packageName, @Nullable String certificate) { // Check that the package name matches that of the calling package. if (!isPackageNameValidForCaller(packageName)) { return false; @@ -448,7 +444,7 @@ public class Ts43AuthenticationLibrary extends Handler { } } - private boolean isPackageNameValidForCaller(@NonNull String packageName) { + private boolean isPackageNameValidForCaller(String packageName) { String[] packages = mPackageManager.getPackagesForUid(Binder.getCallingUid()); for (String uidPackage : packages) { if (packageName.equals(uidPackage)) { @@ -459,8 +455,8 @@ public class Ts43AuthenticationLibrary extends Handler { return false; } - @NonNull private String getAppName(@NonNull PersistableBundle configs, - @NonNull String packageName, @Nullable String certificate) { + private String getAppName(PersistableBundle configs, String packageName, + @Nullable String certificate) { if (configs.getBoolean(KEY_APPEND_SHA_TO_APP_NAME_BOOL) && certificate != null) { return certificate + "|" + packageName; } @@ -468,7 +464,7 @@ public class Ts43AuthenticationLibrary extends Handler { } @Override - public void handleMessage(@NonNull Message msg) { + public void handleMessage(Message msg) { switch (msg.what) { case EVENT_REQUEST_EAP_AKA_AUTHENTICATION: onRequestEapAkaAuthentication((EapAkaAuthenticationRequest) msg.obj); @@ -484,25 +480,23 @@ public class Ts43AuthenticationLibrary extends Handler { } } - private void onRequestEapAkaAuthentication(@NonNull EapAkaAuthenticationRequest request) { + private void onRequestEapAkaAuthentication(EapAkaAuthenticationRequest request) { mLock.lock(); try { Ts43Authentication authLibrary = new Ts43Authentication(mContext, request.mEntitlementServerAddress, request.mEntitlementVersion); Ts43Authentication.Ts43AuthToken authToken = authLibrary.getAuthToken( request.mSlotIndex, request.mAppId, request.mAppName, request.mAppVersion); - request.mExecutor.execute(() -> Binder.withCleanCallingIdentity( - () -> request.mCallback.onResult(authToken))); + request.mExecutor.execute(() -> request.mCallback.onResult(authToken)); } catch (ServiceEntitlementException exception) { - request.mExecutor.execute(() -> Binder.withCleanCallingIdentity( - () -> request.mCallback.onError(new AuthenticationException(exception)))); + request.mExecutor.execute(() -> + request.mCallback.onError(new AuthenticationException(exception))); } finally { mLock.unlock(); } } - private void onRequestOidcAuthenticationServer( - @NonNull OidcAuthenticationServerRequest request) { + private void onRequestOidcAuthenticationServer(OidcAuthenticationServerRequest request) { mLock.lock(); try { Ts43Authentication authLibrary = new Ts43Authentication(mContext, @@ -511,28 +505,26 @@ public class Ts43AuthenticationLibrary extends Handler { mContext, request.mSlotIndex, request.mEntitlementServerAddress, request.mEntitlementVersion, request.mAppId, request.mAppName, request.mAppVersion); - request.mExecutor.execute(() -> Binder.withCleanCallingIdentity( - () -> request.mCallback.onResult(url))); + request.mExecutor.execute(() -> request.mCallback.onResult(url)); } catch (ServiceEntitlementException exception) { - request.mExecutor.execute(() -> Binder.withCleanCallingIdentity( - () -> request.mCallback.onError(new AuthenticationException(exception)))); + request.mExecutor.execute(() -> + request.mCallback.onError(new AuthenticationException(exception))); } finally { mLock.unlock(); } } - private void onRequestOidcAuthentication(@NonNull OidcAuthenticationRequest request) { + private void onRequestOidcAuthentication(OidcAuthenticationRequest request) { mLock.lock(); try { Ts43Authentication authLibrary = new Ts43Authentication(mContext, request.mEntitlementServerAddress, request.mEntitlementVersion); Ts43Authentication.Ts43AuthToken authToken = authLibrary.getAuthToken( request.mAesUrl); - request.mExecutor.execute(() -> Binder.withCleanCallingIdentity( - () -> request.mCallback.onResult(authToken))); + request.mExecutor.execute(() -> request.mCallback.onResult(authToken)); } catch (ServiceEntitlementException exception) { - request.mExecutor.execute(() -> Binder.withCleanCallingIdentity( - () -> request.mCallback.onError(new AuthenticationException(exception)))); + request.mExecutor.execute(() -> + request.mCallback.onError(new AuthenticationException(exception))); } finally { mLock.unlock(); } |