Example #1
0
        public void GetComplianceUrlTest()
        {
            string destination = "test.htm";
            string username    = "******";
            string description = "this & is a test description";

            int    timestamp   = HL7AuthHelper.GetTimestamp();
            string requestHash = string.Format("{0}|{1}|{2}|{3}",
                                               username,
                                               destination,
                                               timestamp,
                                               Trifolia.Config.AppSettings.HL7ApiKey);
            string expected = string.Format(
                "{0}?userid={1}&returnURL={2}&signingURL={2}&signingDescription={3}&requestHash={4}&timestampUTCEpoch={5}&apiKey={6}",
                "http://hl7.amg-hq.net/temp/mike/webservices/compliance_redirect.cfm",
                username,
                destination,
                "this+%26+is+a+test+description",
                HL7AuthHelper.GetEncrypted(requestHash, Trifolia.Config.AppSettings.HL7SharedKey),
                timestamp,
                Trifolia.Config.AppSettings.HL7ApiKey);

            string actual = HL7AuthHelper.GetComplianceUrl(destination, username, description, timestamp);

            Assert.AreEqual(expected, actual);
        }
Example #2
0
        /// <summary>
        /// Checks if the authenticated user is from the HL7 organization.
        /// If yes, a redirect ActionResult is returned that forwards the user to the HL7 disclaimer page.
        /// The action result includes a redirectUrl parameter that tells HL7 to redirect the user back to trifolia.
        /// The redirectUrl parameter of the returned ActionResult includes the retAction passed to this method
        /// and an implementationGuideId param for the ig.
        /// </summary>
        private ActionResult BeforeExport(ImplementationGuide ig, string retAction)
        {
            bool dy = false;

            bool.TryParse(Request.Params["dy"], out dy);

            // If the user is HL7 authenticated, they must sign a disclaimer before generating the IG
            if (CheckPoint.Instance.OrganizationName == "HL7" && !dy)
            {
                Dictionary <string, string> authData = CheckPoint.Instance.GetAuthenticatedData();

                string userId = authData["UserId"];

                string url = HL7AuthHelper.GetComplianceUrl(
                    Url.Action(retAction, "Export", new { implementationGuideId = ig.Id, dy = true }, Request.Url.Scheme),
                    userId,
                    ig.Name);

                return(Redirect(url));
            }

            return(null);
        }