protected override WebRequest GetWebRequest(Uri uri)
        {
            var wr = base.GetWebRequest(uri);

            wr.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");

            if (authentication is SAML)
            {
                wr.Headers.Add("Cookie", string.Format("FedAuth={0}", SAML.GetToken(siteUrl)));
            }

            return(wr);
        }
예제 #2
0
        static void Main(string[] args)
        {
            try
            {
                ParseArguments(args);

                SAMLController.Initialize();

                XmlElement xmlElement = GetSAMLMessage();
                SAMLIdentifiers.MessageType messageType = SAML.GetSAMLMessageType(xmlElement);
                Console.WriteLine("The SAML message type is: {0}", messageType);

                switch (messageType)
                {
                case SAMLIdentifiers.MessageType.AuthnRequest:
                    ReceiveAuthnRequest(xmlElement);
                    break;

                case SAMLIdentifiers.MessageType.SAMLResponse:
                    ReceiveSAMLResponse(xmlElement);
                    break;

                case SAMLIdentifiers.MessageType.LogoutRequest:
                    ReceiveLogoutMessage(xmlElement, messageType);
                    break;

                case SAMLIdentifiers.MessageType.LogoutResponse:
                    ReceiveLogoutMessage(xmlElement, messageType);
                    break;
                }
            }

            catch (Exception exception)
            {
                Console.Error.WriteLine(exception.ToString());

                if (exception is ArgumentException)
                {
                    ShowUsage();
                }
            }
        }