AuthBridge.Protocols.OpenID.RelativeOpenIdHandler.ProcessSignInResponse C# (CSharp) Method

ProcessSignInResponse() public method

public ProcessSignInResponse ( string realm, string originalUrl, System.Web.HttpContextBase httpContext ) : ClaimsIdentity
realm string
originalUrl string
httpContext System.Web.HttpContextBase
return System.Security.Claims.ClaimsIdentity
        public override ClaimsIdentity ProcessSignInResponse(string realm, string originalUrl, HttpContextBase httpContext)
        {
            var site = new Uri(httpContext.Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped));
            var issuerUrl = new Uri(site,
                new Uri(Issuer.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped)).MakeRelativeUri(Issuer.Url));

            var identifierUrl = new Uri(site,
                new Uri(MultiProtocolIssuer.Identifier.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped)).MakeRelativeUri(MultiProtocolIssuer.Identifier));

            var client = new Clients.RelativeOpenIdClient(issuerUrl, identifierUrl);
            Logger.Debug("ProcessSignInResponse");
            Logger.DebugFormat("Issuer.Url {0}, originalUrl {1}, identifierUrl {2}", issuerUrl, originalUrl,
                identifierUrl);

            AuthenticationResult result;
            try
            {
                result = client.VerifyAuthentication(httpContext);
                Logger.Debug(string.Format("ProviderUserId {0}", result.ProviderUserId));
            }
            catch (WebException wex)
            {
                throw new InvalidOperationException(new StreamReader(wex.Response.GetResponseStream()).ReadToEnd(), wex);
            }

            var claims = new List<Claim>
            {
                new Claim(System.IdentityModel.Claims.ClaimTypes.NameIdentifier, result.ProviderUserId)
            };
            claims.AddRange(result.ExtraData.Select(claim => new Claim(claim.Key, claim.Value)));

            var identity = new ClaimsIdentity(claims, issuerUrl.ToString());
            return identity;
        }