Beispiel #1
0
        public string Token(string deviceID)
        {
            var device = _deviceService.GetDevice(deviceID);
            var token  = _jwt.GetJWTToken(device);

            return(token);
        }
        public void TestToken()
        {
            JWTGenerator        jwtGen   = new JWTGenerator();
            List <TokenKeyItem> tokenKey = new List <TokenKeyItem>();

            tokenKey.Add(new TokenKeyItem
            {
                k   = "Mjg2NTFjYzZkNDljMjhjYjJmNGEwOTk1YmY=",
                kty = "oct",
                kid = "0001"
            });

            JWTService.TokenKeysHolder.keys = tokenKey;
            var token = jwtGen.GetJWTToken(_device);
            JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
            var readedToken = handler.ReadJwtToken(token);

            Assert.Equal(_device.OriginalID, readedToken.Payload.Claims.Single(x => x.Type == "serialID").Value);
        }
Beispiel #3
0
 public string GetJWTToken(Device device)
 {
     return(_jwtGen.GetJWTToken(device));
 }