다음을 통해 공유


SignInResponseMessage 클래스

Represents a Federation SignIn Response Message.

네임스페이스: Microsoft.IdentityModel.Protocols.WSFederation
어셈블리: Microsoft.IdentityModel(microsoft.identitymodel.dll에 있음)

사용법

    Dim instance As SignInResponseMessage

구문

‘선언
Public Class SignInResponseMessage
    Inherits WSFederationMessage
public class SignInResponseMessage : WSFederationMessage
public ref class SignInResponseMessage : public WSFederationMessage
public class SignInResponseMessage extends WSFederationMessage
public class SignInResponseMessage extends WSFederationMessage

Code snippet of a sample web page that accepts HTTP request and creates SignInRequest message and SignInResponse message.

namespace SimplePassiveSTS
{
    public partial class _Default : System.Web.UI.Page
    {
        /// <summary>
        /// Returns whether the user is authenticated or not. 
        /// </summary>
        bool IsAuthenticatedUser
        {
            get
            {
return ( ( Page.User != null ) && ( Page.User.Identity != null ) && ( Page.User.Identity.IsAuthenticated ) );
            }
        }

       /// <summary>
 /// Helper function that processes the incoming request message
 /// and creates a response message
       /// </summary>
private SignInResponseMessage ProcessSignInRequest(SignInRequestMessage requestMessage )
      {
            if ( requestMessage == null )
            {
                throw new ArgumentNullException( "requestMessage" );
            }

// Ensure that the requestMessage has the required ‘wtrealm’ 
// parameter
            if ( String.IsNullOrEmpty( requestMessage.Realm ) )
            {
                throw new InvalidOperationException(
"Incoming Passive Request message didn't contain the wtrealm parameter." );
            }

// Create a SecurityTokenServiceConfiguration instance

SecurityTokenServiceConfiguration stsconfig = new SecurityTokenServiceConfiguration( "SimplePassiveSTS" );

            // Create the STS.
            SecurityTokenService sts = new MySecurityTokenService(stsconfig); 

            // Create the WS-Federation serializer to process the request and
// create the response.
// This creates the default WSFederationSerializer that handles 
// the WS-Trust Feb 2005 specification.
WSFederationSerializer federationSerializer = new WSFederationSerializer();

            // Create RST from the request
RequestSecurityToken request = federationSerializer.CreateRequest (                                               requestMessage, new WSTrustSerializationContext() );

            // Get RSTR from the STS.
RequestSecurityTokenResponse response = sts.Issue(ClaimsPrincipal.Current, request );

            // Create WS-Federation Response message from the RSTR
            return new SignInResponseMessage( new Uri( response.ReplyTo ),
                federationSerializer.GetResponseAsString(response, new WSTrustSerializationContext() ) );

        }

        /// <summary>
 /// We perform WS-Federation passive protocol logic in this method ///and call out to the appropriate request handlers. 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_PreRender( object sender, EventArgs e )
        {
            if ( IsAuthenticatedUser )
            {
                // Use WSFederationMessage.CreateFromUri to parse the request and create a WSFederationMessage. 
                WSFederationMessage federationMessage = WSFederationMessage.CreateFromUri( Request.Url );

                if ( federationMessage.Action == WSFederationConstants.Actions.SignIn )
                {
                    // Process the sign in request. 
SignInResponseMessage responseMessage = ProcessSignInRequest(
                        federationMessage as SignInRequestMessage );

// Always Echo back the Context (wctx) which came on the // request.
                    responseMessage.Context = federationMessage.Context;

                    // Write the response message.     
                    responseMessage.Write( Page.Response.Output );
                    Response.Flush();
                    Response.End();
                }
                else if ( federationMessage.Action == WSFederationConstants.Actions.SignOut ||
                          federationMessage.Action == WSFederationConstants.Actions.SignOutCleanup )
                {
                   // Perform the clean-up operation here
                }
                else
                {
                    throw new InvalidOperationException( String.Format(
                                  CultureInfo.InvariantCulture, "Unsupported Action: {0}", federationMessage.Action ) );
                }
            }

        }

    }

}

설명

This message is created when the received message wa parameter is wsignin1.0 with a wresult/wresultptr parameter.

In Beta release, when converting a RequestSecurityTokenResponse object to a SignInResponseMessage object, the context attribute on RequestSecurityTokenResponse is not transferred over, and needs to be manually set.

상속 계층 구조

System.Object
   Microsoft.IdentityModel.Protocols.WSFederation.WSFederationMessage
    Microsoft.IdentityModel.Protocols.WSFederation.SignInResponseMessage

스레드 안전성

이 유형의 공용 정적(Visual Basic에서는 Shared) 멤버는 모두 스레드로부터 안전합니다.인스턴스 멤버는 스레드로부터 안전하지 않을 수 있습니다.

플랫폼

개발 플랫폼

Windows Server 2003, Windows Vista

Target Platforms

Windows Server 2008, Windows Vista, Not tested on Windows XP

Change History

참고 항목

참조

SignInResponseMessage 멤버
Microsoft.IdentityModel.Protocols.WSFederation 네임스페이스