private void InitForm(LoginOptions options) { switch (options.DialogLocation) { case LoginOptions.Location.CenterToParent: StartPosition = FormStartPosition.CenterParent; break; case LoginOptions.Location.CenterToScreen: StartPosition = FormStartPosition.CenterScreen; break; } Text = options.Caption; if (options.DialogBorder) { cancelButton.Visible = false; FormBorderStyle = FormBorderStyle.Fixed3D; } }
private static string Authenticate(AdfsOptions adfs, LoginOptions options) { if (TokenIssued()) { return(tokenOutput); } if (string.IsNullOrEmpty(adfs.Realm)) { adfs.Realm = GetAudienceUri(); } if (form != null) { form.Close(); } form = new LoginForm(adfs.IdpEndpoint, adfs.Realm, options); form.ShowDialog(); tokenOutput = form.Output; return(tokenOutput); }
/// <summary> /// This method brings up the standard ADFS logon dialog for the user to login. If login is successful, true is returned /// </summary> /// <param name="adfs">ADFS options</param> /// <param name="options">Options for the logon dialog</param> /// <returns></returns> public static bool Login(AdfsOptions adfs, LoginOptions options = null) { if (IsAuthenticated()) { return(true); } if (options == null) { options = new LoginOptions(); } if (string.IsNullOrEmpty(adfs.Realm)) { adfs.Realm = GetAudienceUri(); } if (form != null) { form.Close(); } form = new LoginForm(adfs.IdpEndpoint, adfs.Realm, options); form.ShowDialog(); return(IsAuthenticated()); }
/// <summary> /// This method brings up the standard ADFS logon dialog for the user to login. /// If login is successful the token will be returned as a GenericXmlSecurityToken, suitable for use with WCF. /// </summary> /// <param name="adfs">ADFS options</param> /// <param name="options">Options for the logon dialog</param> /// <returns>GenericXmlSecurityToken token</returns> public static GenericXmlSecurityToken LoginAndReturnGenericXmlSecurityToken(AdfsOptions adfs, LoginOptions options = null) { options = options ?? new LoginOptions(); options.TokenOutput = TokenOutput.ReturnRstr; var rstr = Authenticate(adfs, options); if (rstr == null) { return(null); } return(new RstrHelper().DeserializeTokenFromRstrString(rstr)); }
/// <summary> /// This method brings up the standard ADFS logon dialog for the user to login. /// If login is successful the token string will be returned. /// </summary> /// <param name="adfs">ADFS options</param> /// <param name="options">Options for the logon dialog</param> /// <returns>SAML token string</returns> public static string LoginAndReturnTokenString(AdfsOptions adfs, LoginOptions options = null) { options = options ?? new LoginOptions(); options.TokenOutput = TokenOutput.ReturnTokenString; return(Authenticate(adfs, options)); }