Пример #1
0
        public ActionResult GetClaimsGatheringUrl()
        {
            var getClaimsGatheringUrlParams = new UmaRpGetClaimsGatheringUrlParams();
            var getClaimsGatheringUrlClient = new UmaRpGetClaimsGatheringUrlClient();

            string ticket = "";

            if (Session["uma_ticket"] != null)
            {
                ticket = Session["uma_ticket"].ToString();
            }

            //prepare input params for Check Access
            getClaimsGatheringUrlParams.OxdId             = oxd_id;
            getClaimsGatheringUrlParams.Ticket            = ticket;
            getClaimsGatheringUrlParams.ClaimsRedirectURI = "https://client.example.com";


            var getClaimsGatheringUrlResponse = new UmaRpGetClaimsGatheringUrlResponse();

            //For OXD Local
            if (OXDType == "local")
            {
                //Get protection access token
                getClaimsGatheringUrlParams.ProtectionAccessToken = GetProtectionAccessToken(oxdHost, oxdPort);
                //Authorize RPT
                getClaimsGatheringUrlResponse = getClaimsGatheringUrlClient.GetClaimsGatheringUrl(oxdHost, oxdPort, getClaimsGatheringUrlParams);
            }

            //For OXD Web
            if (OXDType == "web")
            {
                //Get protection access token
                getClaimsGatheringUrlParams.ProtectionAccessToken = GetProtectionAccessToken(httpresturl);
                //Authorize RPT
                getClaimsGatheringUrlResponse = getClaimsGatheringUrlClient.GetClaimsGatheringUrl(httpresturl, getClaimsGatheringUrlParams);
            }

            //process response
            return(Json(new { Response = JsonConvert.SerializeObject(getClaimsGatheringUrlResponse.Data) }));
        }
        /// <summary>
        /// oxd-web Get Claims Gathering Url
        /// </summary>
        /// <param name="oxdweburl">Oxd Web url</param>
        /// <param name="umaRpGetClaimsGatheringUrlParams">Input params for UMA Claims Gathering URL command</param>
        /// <returns></returns>
        public UmaRpGetClaimsGatheringUrlResponse GetClaimsGatheringUrl(string oxdweburl, UmaRpGetClaimsGatheringUrlParams umaRpGetClaimsGatheringUrlParams)
        {
            Logger.Info("Verifying input parameters.");


            if (umaRpGetClaimsGatheringUrlParams == null)
            {
                throw new ArgumentNullException("The UMA RS Get Claims Gathering Url params should not be NULL.");
            }

            if (string.IsNullOrEmpty(umaRpGetClaimsGatheringUrlParams.OxdId))
            {
                throw new MissingFieldException("Oxd ID is required for  Get Claims Gathering Url ");
            }



            try
            {
                Logger.Info("Preparing and sending command.");
                var cmdUmaRpGetClaimsGatheringUrl = new Command {
                    CommandType = CommandType.uma_rp_get_claims_gathering_url, CommandParams = umaRpGetClaimsGatheringUrlParams
                };
                var    commandClient   = new CommandClient(oxdweburl);
                string commandResponse = commandClient.send(cmdUmaRpGetClaimsGatheringUrl);

                var response = JsonConvert.DeserializeObject <UmaRpGetClaimsGatheringUrlResponse>(commandResponse);

                if (response.Status.ToLower().Equals("error"))
                {
                    Logger.Info(string.Format("Got response status as {0}. The error is {1} with description {2}",
                                              response.Status, response.Data.Error, response.Data.ErrorDescription));
                }
                else
                {
                    Logger.Info(string.Format("Got response status as {0} ", response.Status));
                }

                return(response);
            }
            catch (Exception ex)
            {
                Logger.Log(NLog.LogLevel.Error, ex, "Exception when Getting UMA Claims Gathering URL.");
                return(null);
            }
        }