コード例 #1
0
        private string GenerateTokenSegmentFromEnvelope(JsonWebTokenEnvelope envelope)
        {
            //zumo takes the kid is a string
            var header = new { alg = envelope.Algorithm, typ = envelope.Type, kid = envelope.KeyId.ToString() };

            byte[] headerBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(header, Formatting.None));
            return(this.Base64UrlEncode(headerBytes));
        }
コード例 #2
0
 public JsonWebToken(JsonWebTokenClaims claims, dynamic credentials, JsonWebTokenEnvelope envelope, string key)
 {
     this.Envelope             = envelope;
     this.envelopeTokenSegment = GenerateTokenSegmentFromEnvelope(Envelope);
     this.Claims                    = claims;
     this.Claims.Credentials        = credentials;
     this.Claims.CryptedCredentials = EncryptCredentials(credentials, key);
     this.claimsTokenSegment        = GenerateTokenSegmentFromClaims(Claims);
     this.Signature                 = BuildSignature(key);
 }
コード例 #3
0
ファイル: JsonWebToken.cs プロジェクト: chimpinano/ZumoSharp
 public JsonWebToken(JsonWebTokenClaims claims, dynamic credentials, JsonWebTokenEnvelope envelope, string key)
 {
     this.Envelope = envelope;
     this.envelopeTokenSegment = GenerateTokenSegmentFromEnvelope(Envelope);
     this.Claims = claims;
     this.Claims.Credentials = credentials;
     this.Claims.CryptedCredentials = EncryptCredentials(credentials, key);
     this.claimsTokenSegment = GenerateTokenSegmentFromClaims(Claims);
     this.Signature = BuildSignature(key);
 }
コード例 #4
0
        private void ValidateEnvelope(JsonWebTokenEnvelope envelope)
        {
            if (envelope.Type != "JWT")
            {
                throw new Exception("Unsupported token type");
            }

            if (envelope.Algorithm != "HS256")
            {
                throw new Exception("Unsupported crypto algorithm");
            }
        }
コード例 #5
0
        private void ValidateEnvelope(JsonWebTokenEnvelope envelope)
        {
            if (envelope.Type != "JWT")
            {
                throw new Exception("Unsupported token type");
            }

            if (envelope.Algorithm != "HS256")
            {
                throw new Exception("Unsupported crypto algorithm");
            }
        }
コード例 #6
0
ファイル: JsonWebToken.cs プロジェクト: chimpinano/ZumoSharp
 private string GenerateTokenSegmentFromEnvelope(JsonWebTokenEnvelope envelope)
 {
     //zumo takes the kid is a string
     var header = new { alg = envelope.Algorithm, typ = envelope.Type, kid = envelope.KeyId.ToString()};
     byte[] headerBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(header, Formatting.None));
     return this.Base64UrlEncode(headerBytes);
 }