public bool TryIssueToken(EndpointAddress appliesTo, IClaimsPrincipal principal, string tokenType, out TokenResponse response)
        {
            SecurityToken token = null;
            response = new TokenResponse { TokenType = tokenType };

            var result = TryIssueToken(appliesTo, principal, tokenType, out token);
            if (result == false)
            {
                return false;
            }

            var swt = token as SimpleWebToken;
            if (swt != null)
            {
                response.TokenString = swt.RawToken;
                response.ContentType = "text";
            }
            else
            {
                var handler = FederatedAuthentication.ServiceConfiguration.SecurityTokenHandlers;
                var sb = new StringBuilder(128);
                handler.WriteToken(new XmlTextWriter(new StringWriter(sb)), token);

                response.ContentType = "text/xml";
                response.TokenString = sb.ToString();
            }

            return result;
        }
 public WrapResult(TokenResponse response)
 {
     TokenResponse = response;
 }
        public bool TryIssueToken(EndpointAddress appliesTo, ClaimsPrincipal principal, string tokenType, out TokenResponse response)
        {
            SecurityToken token = null;
            response = new TokenResponse { TokenType = tokenType };

            var result = TryIssueToken(appliesTo, principal, tokenType, out token);
            if (result == false)
            {
                return false;
            }

            if (tokenType == TokenTypes.JsonWebToken || tokenType == TokenTypes.SimpleWebToken)
            {
                var handler = FederatedAuthentication.FederationConfiguration.IdentityConfiguration.SecurityTokenHandlers[tokenType];
                response.TokenString = handler.WriteToken(token);
                response.ContentType = "text";
            }
            else
            {
                var handler = FederatedAuthentication.FederationConfiguration.IdentityConfiguration.SecurityTokenHandlers;
                var sb = new StringBuilder(128);
                handler.WriteToken(new XmlTextWriter(new StringWriter(sb)), token);

                response.ContentType = "text/xml";
                response.TokenString = sb.ToString();
            }

            return result;
        }