Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.User != null && this.User.Identity != null)
            {
                identity.Text = this.User.Identity.Name;
            }

            W3IssuerConfigurationElement issuerElement = W3Settings.GetSettings().GetSelectedIssuer();

            byte[] samlReq = Encoding.UTF8.GetBytes(SamlHelper.GetSignedRequestDoc(issuerElement.IssuerID, string.Empty, this.Request.Url.ToString()).OuterXml);
            SAMLRequest.InnerText = Convert.ToBase64String(samlReq);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            loginForm.Action = W3Settings.GetSettings().SignInUri;

            W3IssuerConfigurationElement issuerElement = W3Settings.GetSettings().GetSelectedIssuer();

            string returnUrl = this.Request.QueryString["ReturnUrl"];

            string xml = SamlHelper.GetSignedRequestDoc(issuerElement.IssuerID, string.Empty, returnUrl).OuterXml;

            byte[] samlReq = Encoding.UTF8.GetBytes(xml);
            SAMLRequest.InnerText = Convert.ToBase64String(samlReq);
        }
Exemplo n.º 3
0
        public static X509Certificate2 GetEmbededPrivateCertificate()
        {
            byte[] rawData = null;

            W3IssuerConfigurationElement issuer = W3Settings.GetSettings().GetSelectedIssuer();

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MCS.Library.Cloud.W3.Resources." +
                                                                                             issuer.PrivateCA))
            {
                rawData = stream.ToBytes();
            }

            return(new X509Certificate2(rawData, issuer.PrivateCAPassword, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet));
        }
Exemplo n.º 4
0
        private static void FillPrameters(XmlDocument xmlDoc, XmlNamespaceManager ns, string issuer, string assertionUrl, string source)
        {
            xmlDoc.DocumentElement.SetAttribute("ID", "_" + UuidHelper.NewUuidString());

            if (assertionUrl.IsNullOrEmpty())
            {
                assertionUrl = W3Settings.GetSettings().GetSelectedIssuer().ResponseUri;
            }

            xmlDoc.DocumentElement.SetAttribute("AssertionConsumerServiceURL", assertionUrl);

            if (source.IsNotEmpty())
            {
                xmlDoc.DocumentElement.SetAttribute("source", source);
            }

            XmlElement issuerNode = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("saml:Issuer", ns);

            if (issuerNode != null)
            {
                issuerNode.InnerText = issuer;
            }
        }
Exemplo n.º 5
0
        private static X509Certificate2 GetEmbededPublicCertificate()
        {
            byte[] rawData = null;

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MCS.Library.Cloud.W3.Resources." +
                                                                                             W3Settings.GetSettings().GetSelectedIssuer().PublicCA))
            {
                rawData = stream.ToBytes();
            }

            return(new X509Certificate2(rawData));
        }