Esempio n. 1
0
        /// <summary>
        /// Generates the JWT corresponding to the given payload.
        /// </summary>
        /// <param name="payload">The payload to generate the JWT from</param>
        /// <returns>The JWT string</returns>
        public string Generate(JWTPayload payload)
        {
            string serializedPayload = Base64UrlEncoder.Encode(payload.Serialize());
            string headerAndPayload  = $"{_jwtHeader}.{serializedPayload}";

            string signature = sign(headerAndPayload);

            return($"{headerAndPayload}.{signature}");
        }
Esempio n. 2
0
        /// <summary>
        /// Parses a JWT.
        /// </summary>
        /// <param name="jwt">JWT string</param>
        /// <returns>The parsed JWTPayload</returns>
        public static JWTPayload Parse(string jwt)
        {
            var splitted = jwt.Split('.');
            var payload  = splitted[1];

            var plainPayload = Base64UrlEncoder.Decode(payload);

            return(JWTPayload.Parse(plainPayload));
        }
Esempio n. 3
0
 /// <summary>
 /// Generates the JWT corresponding to the given payload.
 /// </summary>
 /// <param name="payload">The payload to generate the JWT from</param>
 /// <returns>The JWT string</returns>
 public string Generate(JWTPayload payload)
 {
     throw new NotImplementedException();
 }