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); } }
protected void WSFederationAuthenticationModule_SecurityTokenReceived( object sender, SecurityTokenReceivedEventArgs e ) { }
void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e) { var test = 1; }
protected void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e) { }
//</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 ); } }
void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e) { e.Cancel = true; }
public void CustomAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e) { var auth = (CustomWSFederationAuthenticationModule)sender; Debug.WriteLine("SecurityTokenReceived. SecurityToken:" + e.SecurityToken + " SignInContext:" + e.SignInContext); }
void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e) { //throw new NotImplementedException(); }
private void CustomAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e) { SecurityTokenHelper.StoreSecurityToken(e.SecurityToken); Debug.WriteLine($"SecurityTokenReceived. SecurityToken ID: {e.SecurityToken.Id}"); }
void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e) { System.Diagnostics.Trace.WriteLine("Handling SecurityTokenReceived event"); }
private void WSFederationAuthenticationModule_SecurityTokenReceived(object sender, SecurityTokenReceivedEventArgs e) { //Claims Principal not Available //Session.Add("SAML_Token", e.SecurityToken); }