Esempio n. 1
0
        public void InvokeSingleSignOn(HttpContext context)
        {
            try
            {
                // Extract SAMLRequest information from httpRequest
                string strRequestId = string.Format("id-{0}", Guid.NewGuid());

                SAMLAuthnRequest request = GetSignedSamlAuthnRequest(strRequestId, "2.0", "https://www.google.com/", "");

                // Read SingleSignOn Cookie => return value might be null => checked by SAMLIdentityProvider
                UserContext.Current = SingleSignOnCookie.GetSingleSignOnUserInfo(context);

                // Read additional attributes from Cookie, which were added via extender
                IEnumerable <SAMLAssertionAttribute> additionalAttributes = SingleSignOnCookie.GetAttributes(context);

                // Process SAMLAuthnRequest and Signature and create SAMLAuthnResponse
                SAMLIdentityProvider identityProvider = new SAMLIdentityProvider();
                SAMLAuthnResponse    response         = identityProvider.CreateResponse(request, additionalAttributes == null ? null : additionalAttributes.ToArray());

                // Render self-submitting HTMl-Form to respond to the SAMLAuthnRequest
                RenderSAMLResponse(context, request, response);
            }
            catch (Exception ex)
            {
                AdeNetSingleSignOn.Log.Error(ex);
                context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
        }
Esempio n. 2
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                // Extract SAMLRequest information from httpRequest
                SAMLAuthnRequest request = GetSAMLAuthnRequestFromContext(context);
                AdeNetSingleSignOn.Log.Info("A new SAMLAuthnRequest is being processed.", request);

                // Read SingleSignOn Cookie => return value might be null => checked by SAMLIdentityProvider
                UserContext.Current = SingleSignOnCookie.GetSingleSignOnUserInfo(context);

                // Read additional attributes from Cookie, which were added via extender
                IEnumerable <SAMLAssertionAttribute> additionalAttributes = SingleSignOnCookie.GetAttributes(context);

                // Process SAMLAuthnRequest and Signature and create SAMLAuthnResponse
                SAMLIdentityProvider identityProvider = new SAMLIdentityProvider();
                SAMLAuthnResponse    response         = identityProvider.CreateResponse(request, additionalAttributes == null ? null : additionalAttributes.ToArray());

                // Render self-submitting HTMl-Form to respond to the SAMLAuthnRequest
                RenderSAMLResponse(context, request, response);
            }
            catch (Exception ex)
            {
                AdeNetSingleSignOn.Log.Error(ex);
                context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
        }