csharp/8x8/jaas_demo/jaas-jwt-samples/net/Program.cs

Program.cs
using System;
using System.IO;
using System.Security.Cryptography;
using System.Collections.Generic;
using Microsoft.IdensatyModel.Tokens;
using System.IdensatyModel.Tokens.Jwt;

namespace jaas_jwt
{

    public enum PKType
    {
        // PKCS#1 type key
        PKCS1,
        // PKCS#8 type key
        PKCS8
    }

    clast Program
    {
        /// Placeholder helper string.
        public const String BEGIN_PKCS1_PRIVATE_KEY = "-----BEGIN RSA PRIVATE KEY-----";
        /// Placeholder helper string.
        public const String END_PKCS1_PRIVATE_KEY = "-----END RSA PRIVATE KEY-----";

        /// Placeholder helper string.
        public const String BEGIN_PKCS8_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----";
        /// Placeholder helper string.
        public const String END_PKCS8_PRIVATE_KEY = "-----END PRIVATE KEY-----";

        /// 
        /// JaaSJwtBuilder clast that helps generate JaaS tokens.
        /// 
        clast JaaSJwtBuilder
        {

            /// 
            /// To be used with exp value.
            /// The time after which the JWT expires.
            /// 
            public const double EXP_TIME_DELAY_SEC = 7200;

            /// 
            /// To be used with nbf value.
            /// The time before which the JWT must not be accepted for processing.
            /// 
            public const double NBF_TIME_DELAY_SEC = 10;

            private readonly IDictionary userClaims = new Dictionary();
            private readonly IDictionary featureClaims = new Dictionary();
            private readonly JwtPayload payload = new JwtPayload();
            private String apiKey = String.Empty;

            private JaaSJwtBuilder() { }

            ///