• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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;
18 
19 import android.os.Build;
20 import android.os.Build.VERSION;
21 
22 import com.google.auto.value.AutoValue;
23 
24 /**
25  * Service entitlement HTTP request parameters, as defiend in GSMA spec TS.43 section 2.2.
26  */
27 @AutoValue
28 public abstract class ServiceEntitlementRequest {
29     /** Disables notification token. */
30     public static final int NOTICATION_ACTION_DISABLE = 0;
31     /** Enables FCM notification token. */
32     public static final int NOTICATION_ACTION_ENABLE_FCM = 2;
33     /** Accepts the content type in XML format. */
34     public static final String ACCEPT_CONTENT_TYPE_XML = "text/vnd.wap.connectivity-xml";
35     /** Accepts the content type in JSON format. */
36     public static final String ACCEPT_CONTENT_TYPE_JSON =
37             "application/vnd.gsma.eap-relay.v1.0+json";
38     /** Accepts the content type in JSON or XML format. */
39     public static final String ACCEPT_CONTENT_TYPE_JSON_AND_XML =
40             "application/vnd.gsma.eap-relay.v1.0+json, text/vnd.wap.connectivity-xml";
41     /** Default value of configuration version. */
42     public static final int DEFAULT_CONFIGURATION_VERSION = 0;
43     /** Default value of entitlement version. */
44     public static final String DEFAULT_ENTITLEMENT_VERSION = "2.0";
45 
46 
47     /**
48      * Returns the version of configuration currently stored on the client. Used by HTTP parameter
49      * "vers".
50      */
configurationVersion()51     public abstract int configurationVersion();
52 
53     /**
54      * Returns the version of the entitlement specification. Used by HTTP parameter
55      * "entitlement_version".
56      */
entitlementVersion()57     public abstract String entitlementVersion();
58 
59     /**
60      * Returns the authentication token. Used by HTTP parameter "token".
61      */
authenticationToken()62     public abstract String authenticationToken();
63 
64     /**
65      * Returns the temporary token. Used by HTTP parameter "temporary_token".
66      */
temporaryToken()67     public abstract String temporaryToken();
68 
69     /**
70      * Returns the unique identifier of the device like IMEI. Used by HTTP parameter "terminal_id".
71      */
terminalId()72     public abstract String terminalId();
73 
74     /**
75      * Returns the OEM of the device. Used by HTTP parameter "terminal_vendor".
76      */
terminalVendor()77     public abstract String terminalVendor();
78 
79     /**
80      * Returns the model of the device. Used by HTTP parameter "terminal_model".
81      */
terminalModel()82     public abstract String terminalModel();
83 
84     /**
85      * Returns the software version of the device. Used by HTTP parameter "terminal_sw_version".
86      */
terminalSoftwareVersion()87     public abstract String terminalSoftwareVersion();
88 
89     /**
90      * Returns the name of the device application making the request. Used by HTTP parameter
91      * "app_name".
92      */
appName()93     public abstract String appName();
94 
95     /**
96      * Returns the version of the device application making the request. Used by HTTP parameter
97      * "app_version".
98      */
appVersion()99     public abstract String appVersion();
100 
101     /**
102      * Returns the FCM registration token used to register for entitlement configuration request
103      * from network. Used by HTTP parameter "notif_token".
104      */
notificationToken()105     public abstract String notificationToken();
106 
107     /**
108      * Returns the action associated with the FCM registration token. Used by HTTP parameter
109      * "notif_action".
110      *
111      * @see #NOTICATION_ACTION_ENABLE_FCM
112      * @see #NOTICATION_ACTION_DISABLE
113      */
notificationAction()114     public abstract int notificationAction();
115 
116     /**
117      * Returns the accepted content type of http response.
118      *
119      * @see #ACCEPT_CONTENT_TYPE_XML
120      * @see #ACCEPT_CONTENT_TYPE_JSON
121      * @see #ACCEPT_CONTENT_TYPE_JSON_AND_XML
122      */
acceptContentType()123     public abstract String acceptContentType();
124 
125     /**
126      * Returns the boost type for premium network. Used for premium network slice entitlement.
127      */
boostType()128     public abstract String boostType();
129 
130     /**
131      * Returns a new {@link Builder} object.
132      */
builder()133     public static Builder builder() {
134         return new AutoValue_ServiceEntitlementRequest.Builder()
135                 .setConfigurationVersion(DEFAULT_CONFIGURATION_VERSION)
136                 .setEntitlementVersion(DEFAULT_ENTITLEMENT_VERSION)
137                 .setAuthenticationToken("")
138                 .setTemporaryToken("")
139                 .setTerminalId("")
140                 .setTerminalVendor(Build.MANUFACTURER)
141                 .setTerminalModel(Build.MODEL)
142                 .setTerminalSoftwareVersion(VERSION.BASE_OS)
143                 .setAppName("")
144                 .setAppVersion("")
145                 .setNotificationToken("")
146                 .setNotificationAction(NOTICATION_ACTION_ENABLE_FCM)
147                 .setAcceptContentType(ACCEPT_CONTENT_TYPE_JSON_AND_XML)
148                 .setBoostType("");
149     }
150 
151     /**
152      * Builder.
153      */
154     @AutoValue.Builder
155     public abstract static class Builder {
156         /**
157          * Sets the version of configuration currently stored on the client. Used by HTTP parameter
158          * "vers".
159          *
160          * <p>If not set, default to {@link #DEFAULT_CONFIGURATION_VERSION} indicating no existing
161          * configuration.
162          */
setConfigurationVersion(int value)163         public abstract Builder setConfigurationVersion(int value);
164 
165         /**
166          * Sets the current version of the entitlement specification. Used by HTTP parameter
167          * "entitlement_version".
168          *
169          * <p>If not set, default to {@link #DEFAULT_ENTITLEMENT_VERSION} base on TS.43-v5.0.
170          */
setEntitlementVersion(String value)171         public abstract Builder setEntitlementVersion(String value);
172 
173         /**
174          * Sets the authentication token. Used by HTTP parameter "token".
175          *
176          * <p>If not set, will trigger embedded EAP-AKA authentication as decribed in TS.43 section
177          * 2.6.1.
178          */
setAuthenticationToken(String value)179         public abstract Builder setAuthenticationToken(String value);
180 
181         /**
182          * Sets the temporary token. Used by HTTP parameter "temporary_token".
183          *
184          * <p>Optional.
185          */
setTemporaryToken(String value)186         public abstract Builder setTemporaryToken(String value);
187 
188         /**
189          * Sets the unique identifier of the device like IMEI. Used by HTTP parameter
190          * "terminal_id".
191          *
192          * <p>If not set, will use the device IMEI.
193          */
setTerminalId(String value)194         public abstract Builder setTerminalId(String value);
195 
196         /**
197          * Sets the OEM of the device. Used by HTTP parameter "terminal_vendor".
198          *
199          * <p>If not set, will use {@link android.os.Build#MANUFACTURER}.
200          */
setTerminalVendor(String value)201         public abstract Builder setTerminalVendor(String value);
202 
203         /**
204          * Sets the model of the device. Used by HTTP parameter "terminal_model".
205          *
206          * <p>If not set, will use {@link android.os.Build#MODEL}.
207          */
setTerminalModel(String value)208         public abstract Builder setTerminalModel(String value);
209 
210         /**
211          * Sets the software version of the device. Used by HTTP parameter "terminal_sw_version".
212          *
213          * <p>If not set, will use {@link android.os.Build.VERSION#BASE_OS}.
214          */
setTerminalSoftwareVersion(String value)215         public abstract Builder setTerminalSoftwareVersion(String value);
216 
217         /**
218          * Sets the name of the device application making the request. Used by HTTP parameter
219          * "app_name".
220          *
221          * <p>Optional.
222          */
setAppName(String value)223         public abstract Builder setAppName(String value);
224 
225         /**
226          * Sets the version of the device application making the request. Used by HTTP parameter
227          * "app_version".
228          *
229          * <p>Optional.
230          */
setAppVersion(String value)231         public abstract Builder setAppVersion(String value);
232 
233         /**
234          * Sets the FCM registration token used to register for entitlement configuration request
235          * from network. Used by HTTP parameter "notif_token".
236          *
237          * <p>Optional.
238          */
setNotificationToken(String value)239         public abstract Builder setNotificationToken(String value);
240 
241         /**
242          * Sets the action associated with the FCM registration token. Used by HTTP parameter
243          * "notif_action".
244          *
245          * <p>Required if a token is set with {@link #setNotificationToken}, and default to {@link
246          * #NOTICATION_ACTION_ENABLE_FCM}; otherwise ignored.
247          *
248          * @see #NOTICATION_ACTION_ENABLE_FCM
249          * @see #NOTICATION_ACTION_DISABLE
250          */
setNotificationAction(int value)251         public abstract Builder setNotificationAction(int value);
252 
253         /**
254          * Sets the configuration document format the caller accepts, e.g. XML or JSON. Used by HTTP
255          * request header "Accept".
256          *
257          * <p>If not set, will use {@link #ACCEPT_CONTENT_TYPE_JSON_AND_XML}.
258          *
259          * @see #ACCEPT_CONTENT_TYPE_XML
260          * @see #ACCEPT_CONTENT_TYPE_JSON
261          * @see #ACCEPT_CONTENT_TYPE_JSON_AND_XML
262          */
setAcceptContentType(String contentType)263         public abstract Builder setAcceptContentType(String contentType);
264 
265         /**
266          * Sets the boost type for premium network. Used by HTTP parameter
267          * "boost_type" in case of premium network slice entitlement.
268          *
269          * <p>Optional.
270          */
setBoostType(String value)271         public abstract Builder setBoostType(String value);
272 
build()273         public abstract ServiceEntitlementRequest build();
274     }
275 }
276