diff --git a/Connection/RESTConnector.cs b/Connection/RESTConnector.cs
index e56d777..df7e203 100644
--- a/Connection/RESTConnector.cs
+++ b/Connection/RESTConnector.cs
@@ -29,6 +29,8 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using MiniJSON;
+using IBM.Cloud.SDK.Authentication;
+using Utility = IBM.Cloud.SDK.Utilities.Utility;
#if !NETFX_CORE
using System.Net;
@@ -220,11 +222,11 @@ public Request()
/// The http method for use with UnityWebRequest.
///
public string HttpMethod { get; set; }
- private bool disableSslVerification = false;
+ private bool? disableSslVerification = false;
///
/// Gets and sets the option to disable ssl verification
///
- public bool DisableSslVerification
+ public bool? DisableSslVerification
{
get { return disableSslVerification; }
set { disableSslVerification = value; }
@@ -246,7 +248,7 @@ public bool DisableSslVerification
///
/// Credentials used to authenticate with the server.
///
- public Credentials Authentication { get; set; }
+ public Authenticator Authentication { get; set; }
///
/// Additional headers to attach to all requests.
///
@@ -254,30 +256,19 @@ public bool DisableSslVerification
#endregion
///
- /// This function returns a RESTConnector object for the given service and function.
+ /// This function returns a RESTConnector object for the given service and function.
///
/// The ID of the service.
/// The name of the function.
/// Returns a RESTConnector object or null on error.
///
-
-
- public static RESTConnector GetConnector(Credentials credentials, string function)
+ public static RESTConnector GetConnector(Authenticator authenticator, string function)
{
RESTConnector connector = new RESTConnector
{
- URL = credentials.Url + function,
- Authentication = credentials
+ URL = authenticator.Url + function,
+ Authentication = authenticator
};
-
- if (connector.Authentication.HasIamTokenData())
- {
- connector.Authentication.iamTokenManager.GetToken();
- }
- else if (connector.Authentication.HasIcp4dTokenData())
- {
- connector.Authentication.icp4dTokenManager.GetToken();
- }
return connector;
}
@@ -319,26 +310,6 @@ public bool Send(Request request)
#region Private Functions
private void AddHeaders(Dictionary headers)
{
- if (Authentication != null)
- {
- if (headers == null)
- {
- throw new ArgumentNullException("headers");
- }
-
- if (Authentication.HasCredentials())
- {
- headers.Add(AUTHENTICATION_AUTHORIZATION_HEADER, Authentication.CreateAuthorization());
- }
- else if (Authentication.HasIamTokenData())
- {
- headers.Add(AUTHENTICATION_AUTHORIZATION_HEADER, string.Format("Bearer {0}", Authentication.iamTokenManager.GetAccessToken()));
- }
- else if (Authentication.HasIcp4dTokenData())
- {
- headers.Add(AUTHENTICATION_AUTHORIZATION_HEADER, string.Format("Bearer {0}", Authentication.icp4dTokenManager.GetAccessToken()));
- }
- }
if (Headers != null)
{
@@ -508,7 +479,7 @@ private IEnumerator ProcessRequestQueue()
unityWebRequest.downloadHandler = new DownloadHandlerBuffer();
- if (req.DisableSslVerification)
+ if (req.DisableSslVerification == true)
{
unityWebRequest.certificateHandler = new AcceptAllCertificates();
}
diff --git a/Connection/WSConnector.cs b/Connection/WSConnector.cs
index 8ebc8f2..67b1931 100644
--- a/Connection/WSConnector.cs
+++ b/Connection/WSConnector.cs
@@ -23,6 +23,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Security.Authentication;
+using IBM.Cloud.SDK.Authentication;
using System.Threading;
#if !NETFX_CORE
using UnitySDK.WebSocketSharp;
@@ -172,7 +173,7 @@ public Dictionary Headers
///
/// Credentials used to authenticate with the server.
///
- public Credentials Authentication { get; set; }
+ public Authenticator Authentication { get; set; }
///
/// The current state of this connector.
///
@@ -294,29 +295,23 @@ public static string FixupURL(string URL)
///
/// Create a WSConnector for the given service and function.
///
- /// The credentials for the service.
+ /// The credentials for the service.
/// The name of the function to connect.
/// Additional function arguments.
/// The WSConnector object or null or error.
- public static WSConnector CreateConnector(Credentials credentials, string function, string args)
+ public static WSConnector CreateConnector(Authenticator authenticator, string function, string args)
{
WSConnector connector = new WSConnector();
- if (credentials.HasCredentials())
+ if (authenticator.AuthenticationType == "basic")
{
- connector.Authentication = credentials;
+ connector.Authentication = authenticator;
}
- else if (credentials.HasIamTokenData())
+ else if (authenticator.AuthenticationType == "iam" || authenticator.AuthenticationType == "cp4d")
{
- credentials.iamTokenManager.GetToken();
- connector.Headers.Add(AUTHENTICATION_AUTHORIZATION_HEADER, string.Format("Bearer {0}", credentials.iamTokenManager.GetAccessToken()));
- }
- else if (credentials.HasIcp4dTokenData())
- {
- credentials.icp4dTokenManager.GetToken();
- connector.Headers.Add(AUTHENTICATION_AUTHORIZATION_HEADER, string.Format("Bearer {0}", credentials.icp4dTokenManager.GetAccessToken()));
+ authenticator.Authenticate(connector);
}
- connector.URL = FixupURL(credentials.Url) + function + args;
+ connector.URL = FixupURL(authenticator.Url) + function + args;
return connector;
}