예제 #1
0
        private bool HandleResponseMessage()
        {
            try
            {
                var responseMessage = FederationAuthenticationModule.GetSignInResponseMessage(new HttpRequestWrapper(this.Context.Request));
                if (responseMessage != null)
                {
                    string xmlTokenFromMessage = this.FederationAuthenticationModule.GetXmlTokenFromMessage(responseMessage, null);

                    FederationConfiguration serviceConfiguration = this.FederationAuthenticationModule.FederationConfiguration;
                    //ServiceConfiguration serviceConfiguration       = CUFSSecurityTokenServiceConfiguration.Current;
                    FederationPassiveTokenReceiver tokenReceiver = new FederationPassiveTokenReceiver(serviceConfiguration);
                    SecurityToken securityToken = tokenReceiver.ReadToken(xmlTokenFromMessage);

                    SecurityTokenReceivedEventArgs securityTokenReceivedEventArgs = new SecurityTokenReceivedEventArgs(securityToken);
                    this.OnSecurityTokenReceived(securityTokenReceivedEventArgs);

                    if (!securityTokenReceivedEventArgs.Cancel)
                    {
                        ClaimsPrincipal claimsPrincipal = tokenReceiver.AuthenticateToken(securityTokenReceivedEventArgs.SecurityToken, true, HttpContext.Current.Request.RawUrl);
                        if (claimsPrincipal != null)
                        {
                            SecurityTokenValidatedEventArgs securityTokenValidatedEventArgs = new SecurityTokenValidatedEventArgs(claimsPrincipal);
                            this.OnSecurityTokenValidated(securityTokenValidatedEventArgs);
                            if (!securityTokenValidatedEventArgs.Cancel)
                            {
                                SessionAuthenticationModule current = FederatedAuthentication.SessionAuthenticationModule;

                                DateTime validFrom;
                                DateTime validTo;

                                tokenReceiver.ComputeSessionTokenLifeTime(securityTokenReceivedEventArgs.SecurityToken, out validFrom, out validTo);
                                SessionSecurityToken sessionToken = current.CreateSessionSecurityToken(securityTokenValidatedEventArgs.ClaimsPrincipal, this.GetSessionTokenContext(), validFrom, validTo, false);

                                SessionSecurityTokenCreatedEventArgs sessionSecurityTokenCreatedEventArgs = new SessionSecurityTokenCreatedEventArgs(sessionToken);
                                sessionSecurityTokenCreatedEventArgs.WriteSessionCookie = true;

                                this.OnSessionSecurityTokenCreated(sessionSecurityTokenCreatedEventArgs);

                                this.FederationAuthenticationModule.SetPrincipalAndWriteSessionToken(sessionSecurityTokenCreatedEventArgs.SessionToken, sessionSecurityTokenCreatedEventArgs.WriteSessionCookie);

                                this.OnSignedIn(EventArgs.Empty);

                                return(true);
                            }
                        }
                    }
                }

                return(false);
            }
            catch (Exception ex)
            {
                this.ErrorText = ex.Message;
                return(false);
            }
        }
예제 #2
0
        protected virtual void OnSecurityTokenReceived(SecurityTokenReceivedEventArgs e)
        {
            EventHandler <SecurityTokenReceivedEventArgs> eventHandler = (EventHandler <SecurityTokenReceivedEventArgs>) this.events[EventSecurityTokenReceived];

            if (eventHandler != null)
            {
                eventHandler(this, e);
            }
        }
예제 #3
0
 protected void WSFederationAuthenticationModule_SecurityTokenReceived( object sender, SecurityTokenReceivedEventArgs e )
 {
 }
예제 #4
0
 void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
     var test = 1;
 }
예제 #5
0
 protected void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
 }
예제 #6
0
        //</Snippet5>

        //<Snippet6>
        void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
        {
            //Augment token validation with your cusotm validation checks without invalidating the token.
            System.Diagnostics.Trace.WriteLine("Handling SecurityTokenReceived event");
        }
        private bool HandleResponseMessage()
        {
            try
            {
                var responseMessage = FederationAuthenticationModule.GetSignInResponseMessage( new HttpRequestWrapper( this.Context.Request ) );
                if ( responseMessage != null )
                {
                    string xmlTokenFromMessage = this.FederationAuthenticationModule.GetXmlTokenFromMessage( responseMessage, null );

                    FederationConfiguration serviceConfiguration = this.FederationAuthenticationModule.FederationConfiguration;
                    //ServiceConfiguration serviceConfiguration       = CUFSSecurityTokenServiceConfiguration.Current;
                    FederationPassiveTokenReceiver tokenReceiver = new FederationPassiveTokenReceiver( serviceConfiguration );
                    SecurityToken securityToken = tokenReceiver.ReadToken( xmlTokenFromMessage );

                    SecurityTokenReceivedEventArgs securityTokenReceivedEventArgs = new SecurityTokenReceivedEventArgs( securityToken );
                    this.OnSecurityTokenReceived( securityTokenReceivedEventArgs );

                    if ( !securityTokenReceivedEventArgs.Cancel )
                    {
                        ClaimsPrincipal claimsPrincipal = tokenReceiver.AuthenticateToken( securityTokenReceivedEventArgs.SecurityToken, true, HttpContext.Current.Request.RawUrl );
                        if ( claimsPrincipal != null )
                        {
                            SecurityTokenValidatedEventArgs securityTokenValidatedEventArgs = new SecurityTokenValidatedEventArgs( claimsPrincipal );
                            this.OnSecurityTokenValidated( securityTokenValidatedEventArgs );
                            if ( !securityTokenValidatedEventArgs.Cancel )
                            {
                                SessionAuthenticationModule current = FederatedAuthentication.SessionAuthenticationModule;

                                DateTime validFrom;
                                DateTime validTo;

                                tokenReceiver.ComputeSessionTokenLifeTime( securityTokenReceivedEventArgs.SecurityToken, out validFrom, out validTo );
                                SessionSecurityToken sessionToken = current.CreateSessionSecurityToken( securityTokenValidatedEventArgs.ClaimsPrincipal, this.GetSessionTokenContext(), validFrom, validTo, false );

                                SessionSecurityTokenCreatedEventArgs sessionSecurityTokenCreatedEventArgs = new SessionSecurityTokenCreatedEventArgs( sessionToken );
                                sessionSecurityTokenCreatedEventArgs.WriteSessionCookie = true;

                                this.OnSessionSecurityTokenCreated( sessionSecurityTokenCreatedEventArgs );

                                this.FederationAuthenticationModule.SetPrincipalAndWriteSessionToken( sessionSecurityTokenCreatedEventArgs.SessionToken, sessionSecurityTokenCreatedEventArgs.WriteSessionCookie );

                                this.OnSignedIn( EventArgs.Empty );

                                return true;
                            }
                        }
                    }
                }

                return false;
            }
            catch ( Exception ex )
            {
                this.ErrorText = ex.Message;
                return false;
            }
        }
 protected virtual void OnSecurityTokenReceived( SecurityTokenReceivedEventArgs e )
 {
     EventHandler<SecurityTokenReceivedEventArgs> eventHandler = (EventHandler<SecurityTokenReceivedEventArgs>)this.events[EventSecurityTokenReceived];
     if ( eventHandler != null )
     {
         eventHandler( this, e );
     }
 }
예제 #9
0
 void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
     e.Cancel = true;
 }
예제 #10
0
 void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
     var test = 1;
 }
        public void CustomAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
        {
            var auth = (CustomWSFederationAuthenticationModule)sender;

            Debug.WriteLine("SecurityTokenReceived. SecurityToken:" + e.SecurityToken + " SignInContext:" + e.SignInContext);
        }
 public void CustomAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
     var auth = (CustomWSFederationAuthenticationModule)sender;
     Debug.WriteLine("SecurityTokenReceived. SecurityToken:" + e.SecurityToken + " SignInContext:" + e.SignInContext);
 }
예제 #13
0
 void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
     //throw new NotImplementedException();
 }
예제 #14
0
 private void CustomAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
     SecurityTokenHelper.StoreSecurityToken(e.SecurityToken);
     Debug.WriteLine($"SecurityTokenReceived. SecurityToken ID: {e.SecurityToken.Id}");
 }
예제 #15
0
 void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
     e.Cancel = true;
 }
예제 #16
0
 void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
     System.Diagnostics.Trace.WriteLine("Handling SecurityTokenReceived event");
 }
예제 #17
0
 private void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e)
 {
     //Claims Principal not Available
     //Session.Add("SAML_Token", e.SecurityToken);
 }