public ActionResult Index(OxdModel oxd) { Loadoxdsettings(); var getAuthUrlInputParams = new GetAuthorizationUrlParams(); var getAuthUrlClient = new GetAuthorizationUrlClient(); //prepare input params for Getting Auth URL from a site getAuthUrlInputParams.OxdId = oxd_id; getAuthUrlInputParams.custom_parameters.Add("param1", "value1"); getAuthUrlInputParams.custom_parameters.Add("param2", "value2"); var getAuthUrlResponse = new GetAuthorizationUrlResponse(); //Get Authorization url using OXD Local if (OXDType == "local") { //Get ProtectionAccessToken if (dynamic_registration) { getAuthUrlInputParams.ProtectionAccessToken = GetProtectionAccessToken(oxdHost, oxdPort); } //Get Auth URL getAuthUrlResponse = getAuthUrlClient.GetAuthorizationURL(oxdHost, oxdPort, getAuthUrlInputParams); } //Get Authorization url using OXD Web if (OXDType == "web") { if (dynamic_registration) { getAuthUrlInputParams.ProtectionAccessToken = GetProtectionAccessToken(httpresturl); } getAuthUrlResponse = getAuthUrlClient.GetAuthorizationURL(httpresturl, getAuthUrlInputParams); } //Process Response return(Json(new { authUrl = getAuthUrlResponse.Data.AuthorizationUrl })); }
public void TestAuthorizationUrl_oxd_http() { intializedParameter(); var RegisterSite = new RegisterSiteClient(); RegisterSiteResponse registerSiteResponse = RegisterSite.RegisterSite("https://127.0.0.1:8443", registerSiteParams); Assert.That(registerSiteResponse, Is.Not.Null); Assert.That(registerSiteResponse.Data.OxdId, Is.Not.Null); var authorizationUrlParams = new GetAuthorizationUrlParams(); authorizationUrlParams.OxdId = registerSiteResponse.Data.OxdId; authorizationUrlParams.Scope = new List <string> { "openid", "profile" }; var authorizationUrlclient = new GetAuthorizationUrlClient(); GetAuthorizationUrlResponse authorizationurlresponse = authorizationUrlclient.GetAuthorizationURL("127.0.0.1", 8099, authorizationUrlParams); Assert.That(authorizationurlresponse, Is.Not.Null); Assert.That(authorizationurlresponse.Data.AuthorizationUrl, Is.Not.Null); }
/// <summary> /// Gets Authorization URL via http using the params /// </summary> /// <param name="oxdWebUrl">Oxd to http REST service URL</param> /// <param name="getAuthUrlParams">Input params for Get Authorization URL command via http</param> /// <returns></returns> public GetAuthorizationUrlResponse GetAuthorizationURL(string oxdWebUrl, GetAuthorizationUrlParams getAuthUrlParams) { Logger.Info("Verifying input parameters."); if (string.IsNullOrEmpty(oxdWebUrl)) { throw new ArgumentNullException("Oxd Rest Service URL should not be NULL."); } try { var cmdGetAuthUrl = new Command { CommandType = RestCommandType.get_authorization_url, CommandParams = getAuthUrlParams }; var commandClient = new CommandClient(oxdWebUrl); string commandResponse = commandClient.send(cmdGetAuthUrl); var response = JsonConvert.DeserializeObject <GetAuthorizationUrlResponse>(commandResponse); return(response); } catch (Exception ex) { Logger.Log(NLog.LogLevel.Error, ex, "Exception when getting Authorization url"); return(null); } }
/// <summary> /// Gets Authorization URL of a site using input params /// </summary> /// <param name="host">Oxd Host</param> /// <param name="port">Oxd Port</param> /// <param name="getAuthUrlParams">Input params for Get Authorization URL command</param> /// <returns></returns> public GetAuthorizationUrlResponse GetAuthorizationURL(string host, int port, GetAuthorizationUrlParams getAuthUrlParams) { Logger.Info("Verifying input parameters."); if (string.IsNullOrEmpty(host)) { throw new ArgumentNullException("Oxd Host should not be NULL."); } if (port <= 0) { throw new ArgumentNullException("Oxd Port should be a valid port number."); } if (getAuthUrlParams == null) { throw new ArgumentNullException("The get auth url command params should not be NULL."); } if (string.IsNullOrEmpty(getAuthUrlParams.OxdId)) { throw new MissingFieldException("Oxd ID is required for getting auth url of site."); } try { Logger.Info("Preparing and sending command."); var cmdGetAuthUrl = new Command { CommandType = CommandType.get_authorization_url, CommandParams = getAuthUrlParams }; var commandClient = new CommandClient(host, port); string commandResponse = commandClient.send(cmdGetAuthUrl); var response = JsonConvert.DeserializeObject <GetAuthorizationUrlResponse>(commandResponse); Logger.Info(string.Format("Got response status as {0} and auth url is {1}", response.Status, response.Data.AuthorizationUrl)); return(response); } catch (Exception ex) { Logger.Log(NLog.LogLevel.Error, ex, "Exception when getting auth url of site."); return(null); } }