29
29
using Newtonsoft . Json . Linq ;
30
30
using Newtonsoft . Json ;
31
31
using MiniJSON ;
32
+ using IBM . Cloud . SDK . Authentication ;
33
+ using Utility = IBM . Cloud . SDK . Utilities . Utility ;
32
34
33
35
#if ! NETFX_CORE
34
36
using System . Net ;
@@ -220,11 +222,11 @@ public Request()
220
222
/// The http method for use with UnityWebRequest.
221
223
/// </summary>
222
224
public string HttpMethod { get ; set ; }
223
- private bool disableSslVerification = false ;
225
+ private bool ? disableSslVerification = false ;
224
226
/// <summary>
225
227
/// Gets and sets the option to disable ssl verification
226
228
/// </summary>
227
- public bool DisableSslVerification
229
+ public bool ? DisableSslVerification
228
230
{
229
231
get { return disableSslVerification ; }
230
232
set { disableSslVerification = value ; }
@@ -246,38 +248,27 @@ public bool DisableSslVerification
246
248
/// <summary>
247
249
/// Credentials used to authenticate with the server.
248
250
/// </summary>
249
- public Credentials Authentication { get ; set ; }
251
+ public Authenticator Authentication { get ; set ; }
250
252
/// <summary>
251
253
/// Additional headers to attach to all requests.
252
254
/// </summary>
253
255
public Dictionary < string , string > Headers { get ; set ; }
254
256
#endregion
255
257
256
258
/// <summary>
257
- /// This function returns a RESTConnector object for the given service and function.
259
+ /// This function returns a RESTConnector object for the given service and function.
258
260
/// </summary>
259
261
/// <param name="serviceID">The ID of the service.</param>
260
262
/// <param name="function">The name of the function.</param>
261
263
/// <returns>Returns a RESTConnector object or null on error.</returns>
262
264
///
263
-
264
-
265
- public static RESTConnector GetConnector ( Credentials credentials , string function )
265
+ public static RESTConnector GetConnector ( Authenticator authenticator , string function )
266
266
{
267
267
RESTConnector connector = new RESTConnector
268
268
{
269
- URL = credentials . Url + function ,
270
- Authentication = credentials
269
+ URL = authenticator . Url + function ,
270
+ Authentication = authenticator
271
271
} ;
272
-
273
- if ( connector . Authentication . HasIamTokenData ( ) )
274
- {
275
- connector . Authentication . iamTokenManager . GetToken ( ) ;
276
- }
277
- else if ( connector . Authentication . HasIcp4dTokenData ( ) )
278
- {
279
- connector . Authentication . icp4dTokenManager . GetToken ( ) ;
280
- }
281
272
return connector ;
282
273
}
283
274
@@ -319,26 +310,6 @@ public bool Send(Request request)
319
310
#region Private Functions
320
311
private void AddHeaders ( Dictionary < string , string > headers )
321
312
{
322
- if ( Authentication != null )
323
- {
324
- if ( headers == null )
325
- {
326
- throw new ArgumentNullException ( "headers" ) ;
327
- }
328
-
329
- if ( Authentication . HasCredentials ( ) )
330
- {
331
- headers . Add ( AUTHENTICATION_AUTHORIZATION_HEADER , Authentication . CreateAuthorization ( ) ) ;
332
- }
333
- else if ( Authentication . HasIamTokenData ( ) )
334
- {
335
- headers . Add ( AUTHENTICATION_AUTHORIZATION_HEADER , string . Format ( "Bearer {0}" , Authentication . iamTokenManager . GetAccessToken ( ) ) ) ;
336
- }
337
- else if ( Authentication . HasIcp4dTokenData ( ) )
338
- {
339
- headers . Add ( AUTHENTICATION_AUTHORIZATION_HEADER , string . Format ( "Bearer {0}" , Authentication . icp4dTokenManager . GetAccessToken ( ) ) ) ;
340
- }
341
- }
342
313
343
314
if ( Headers != null )
344
315
{
@@ -508,7 +479,7 @@ private IEnumerator ProcessRequestQueue()
508
479
509
480
unityWebRequest . downloadHandler = new DownloadHandlerBuffer ( ) ;
510
481
511
- if ( req . DisableSslVerification )
482
+ if ( req . DisableSslVerification == true )
512
483
{
513
484
unityWebRequest . certificateHandler = new AcceptAllCertificates ( ) ;
514
485
}
0 commit comments