Beispiel #1
0
        public JWToken(string token, JWTSignatureUtil sigUtil)
        {
            m_token = token;

            // TODO: Make this code have a LOT more defense agaisnt malciousness.
            var parts = m_token.Split('.');

            try
            {
                Header = DecodeBase64(parts[0]);
                Payload = LitJson.JsonMapper.ToObject<PayloadOptions>(DecodeBase64(parts[1]));
                HasValidSignature = sigUtil.Verify(body: parts[0] + "." + parts[1], signature: parts[2]);
            }
            catch (FormatException)
            {
                throw new JWTokenException("Invalid Base64");
            }
            catch (IndexOutOfRangeException)
            {
                throw new JWTokenException("Invalid token format");
            }
            catch (LitJson.JsonException jse)
            {
                throw new JWTokenException(jse.Message);
            }
        }
Beispiel #2
0
        public JWToken(string token, JWTSignatureUtil sigUtil)
        {
            m_token = token;

            // TODO: Make this code have a LOT more defense agaisnt malciousness.
            var parts = m_token.Split('.');

            try
            {
                Header = DecodeBase64(parts[0]);
                if (!sigUtil.Verify(body: parts[0] + "." + parts[1], signature: parts[2]))
                {
                    throw new JWTokenException("Invalid Signature");
                }
                Payload = LitJson.JsonMapper.ToObject <PayloadOptions>(DecodeBase64(parts[1]));
                if (Payload.Exp < DateTime.UtcNow)
                {
                    throw new JWTokenException("Token Expired");
                }
            }
            catch (FormatException)
            {
                throw new JWTokenException("Invalid Base64");
            }
            catch (IndexOutOfRangeException)
            {
                throw new JWTokenException("Invalid token format");
            }
            catch (LitJson.JsonException jse)
            {
                throw new JWTokenException(jse.Message);
            }
        }
Beispiel #3
0
        public JWToken(PayloadOptions payloadOptions, JWTSignatureUtil sigUtil)
        {
            Header  = ValidHeader;
            Payload = payloadOptions;

            var body = EncodeBase64(Header) + "." + EncodeBase64(LitJson.JsonMapper.ToJson(payloadOptions));

            m_token = body + "." + sigUtil.Sign(body);
        }
Beispiel #4
0
        public JWToken(PayloadOptions payloadOptions, JWTSignatureUtil sigUtil)
        {
            Header = ValidHeader;
            Payload = payloadOptions;
            HasValidSignature = true;

            var body = EncodeBase64(Header) + "." + EncodeBase64(LitJson.JsonMapper.ToJson(payloadOptions));

            m_token = body + "." + sigUtil.Sign(body);
        }
Beispiel #5
0
 public RemoteConsole(string defaultPrompt) : base(defaultPrompt)
 {
     m_Server = null;
     m_Config = null;
     m_Scrollback = new List<string>();
     m_DataEvent = new ManualResetEvent(false);
     m_InputData = new List<string>();
     m_LineNumber = 0;
     m_Connections = new Dictionary<UUID, ConsoleConnection>();
     m_AllowedOrigin = String.Empty;
     m_sigUtil = new JWTSignatureUtil(publicKeyPath: "./server.crt");
 }
 public JWTUserAuthenticationGateway(IUserService userService)
 {
     _userService = userService;
     m_sigUtil = new JWTSignatureUtil(privateKeyPath: "./server.p12", publicKeyPath:"./server.crt");
 }