private void _btnSignin_Click_1(object sender, RoutedEventArgs e)
        {
            var dialog = new SignInWindow()
            {
                AcsNamespace = "ttacssample",
                Realm = "https://" + Constants.WebHost + "/webservicesecurity/",
                Owner = this
            };

            if (dialog.ShowDialog().Value)
            {
                RSTR = dialog.Response;
                _txtDebug.Text = RSTR.SecurityTokenString;
            }
        }
        private static void ParseValues(JsonNotifyRequestSecurityTokenResponse rstr)
        {
            rstr.ValidFrom = ulong.Parse(rstr.Created).ToDateTimeFromEpoch();
            rstr.ValidTo = ulong.Parse(rstr.Expires).ToDateTimeFromEpoch();
            rstr.SecurityTokenString = HttpUtility.HtmlDecode(rstr.SecurityTokenString);
            var xml = XElement.Parse(rstr.SecurityTokenString);

            string idAttribute = "";
            string tokenType = "";

            switch (rstr.TokenType)
            {
                case SecurityTokenTypes.Saml11:
                    idAttribute = "AssertionID";
                    tokenType = SecurityTokenTypes.Saml11;
                    break;
                case SecurityTokenTypes.Saml2:
                    idAttribute = "ID";
                    tokenType = SecurityTokenTypes.Saml2;
                    break;
                case SecurityTokenTypes.SWT:
                    idAttribute = "Id";
                    tokenType = SecurityTokenTypes.SWT;
                    break;
            }

            if (tokenType == SecurityTokenTypes.Saml11 || tokenType == SecurityTokenTypes.Saml2)
            {
                var tokenId = xml.Attribute(idAttribute);
                var xmlElement = xml.ToXmlElement();
                SecurityKeyIdentifierClause clause = null;
                
                if (tokenId != null)
                {
                    clause = new SamlAssertionKeyIdentifierClause(tokenId.Value);
                }

                rstr.SecurityToken = new GenericXmlSecurityToken(
                    xmlElement,
                    null,
                    rstr.ValidFrom,
                    rstr.ValidTo,
                    clause,
                    clause,
                    new ReadOnlyCollection<IAuthorizationPolicy>(new List<IAuthorizationPolicy>()));
            }
        }
 private void OnScriptNotify(object sender, ScriptNotifyEventArgs e)
 {
     this.Response = JsonNotifyRequestSecurityTokenResponse.FromJson(e.Data);
     this.DialogResult = true;
     this.Close();
 }