示例#1
0
        public JsonWebEncryptedToken Authenticate(TokenOptions tokenOptions, Dictionary <string, string> tokenClaims)
        {
            Tuple <string, string> key = KeyIssuer.GenerateAsymmetricKey();

            tokenOptions.KeyIssuer = key.Item2;
            this.token             = tokenIssuer.EncryptedToken(tokenOptions, tokenClaims);
            return(this.Authenticate(key.Item2));
        }
示例#2
0
        static void Main(string[] args)
        {
            string             secretKey = KeyIssuer.GenerateSharedSymmetricKey();
            SigningCredentials a         = GetSigningCredentials();

            var key = new byte[64];

            using (var generator = RandomNumberGenerator.Create())
                generator.GetBytes(key);
            string apiKey = Convert.ToBase64String(key);


            //// Initialization.
            //string myPassword = "******";
            //string mysaltKey = "mysaltkey";

            //// Generate API key.
            //string apiKey = RESTWebAPIKey.GenerateAPIKey(myPassword, mysaltKey);



            //// Token issuer
            // TokenIssuer issuer = new TokenIssuer();
            //issuer.ShareKeyOutofBand("MyRelyingPartApp", secretKey);

            //// Relying Party
            // RelyingParty app = new RelyingParty();
            // app.ShareKeyOutofBand(secretKey);
            //// // A client of the relying party app gets the token
            // string token = issuer.GetToken("MyRelyingPartApp", "opensesame");

            //// With the token, the client now presents the token and
            ////  calls the method requiring authorization
            // app.Authenticate(token);
            // app.TheMethodRequiringAuthZ();
        }