1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.libraries.entitlement.odsa; 18 19 import androidx.annotation.NonNull; 20 import androidx.annotation.Nullable; 21 22 import com.android.libraries.entitlement.EsimOdsaOperation.OdsaOperationResult; 23 24 import com.google.errorprone.annotations.CanIgnoreReturnValue; 25 26 import java.net.URL; 27 28 /** ODSA general response described in GSMA Service Entitlement Configuration section 6.5.1. */ 29 public abstract class OdsaResponse { 30 /** Operation result. */ 31 @OdsaOperationResult operationResult()32 public abstract int operationResult(); 33 34 /** 35 * The provided URL shall present a web view to user on the reason(s) why the authentication 36 * failed. 37 */ 38 @Nullable generalErrorUrl()39 public abstract URL generalErrorUrl(); 40 41 /** 42 * User data sent to the Service Provider when requesting the {@link #generalErrorUrl()} web 43 * view. It should contain user-specific attributes to improve user experience. 44 */ 45 @Nullable generalErrorUserData()46 public abstract String generalErrorUserData(); 47 48 /** 49 * User-specific content string to be shown to the user. 50 */ 51 @Nullable generalErrorText()52 public abstract String generalErrorText(); 53 54 /** Builder */ 55 public abstract static class Builder { 56 /** 57 * Set the operation result. 58 * 59 * @param operationResult The operation result. 60 * @return The builder. 61 */ 62 @NonNull 63 @CanIgnoreReturnValue setOperationResult(@dsaOperationResult int operationResult)64 public abstract Builder setOperationResult(@OdsaOperationResult int operationResult); 65 66 /** 67 * Set the URL to the web view to user on the reason(s) why the authentication failed. 68 * 69 * @param url The provided URL shall present a web view to user on the reason(s) why the 70 * authentication failed. 71 * @return The builder. 72 */ 73 @NonNull 74 @CanIgnoreReturnValue setGeneralErrorUrl(@onNull URL url)75 public abstract Builder setGeneralErrorUrl(@NonNull URL url); 76 77 /** 78 * Set the user data of {@link #generalErrorUrl()}. 79 * 80 * @param userData User data sent to the Service Provider when requesting the {@link 81 * #generalErrorUrl()} web view. It should contain user-specific attributes 82 * to improve user experience. 83 * @return The builder. 84 */ 85 @NonNull 86 @CanIgnoreReturnValue setGeneralErrorUserData(@onNull String userData)87 public abstract Builder setGeneralErrorUserData(@NonNull String userData); 88 89 /** 90 * Set the user text of {@link #generalErrorText()}. 91 * 92 * @param text User-specific content string to be shown to the user. 93 * @return The builder. 94 */ 95 @NonNull 96 @CanIgnoreReturnValue setGeneralErrorText(@onNull String text)97 public abstract Builder setGeneralErrorText(@NonNull String text); 98 } 99 } 100