Esempio n. 1
0
        public void WriteTo(JwtProperty property, string expected)
        {
            using (var bufferWriter = new PooledByteBufferWriter())
            {
                using (var writer = new Utf8JsonWriter(bufferWriter))
                {
                    writer.WriteStartObject();
                    property.WriteTo(writer);
                    writer.WriteEndObject();
                }

                Assert.Equal(expected, Encoding.UTF8.GetString(bufferWriter.WrittenSpan.ToArray()));
            }
        }
Esempio n. 2
0
        public bool TryGetValue(ReadOnlySpan <byte> key, out JwtProperty value)
        {
            for (int i = 0; i < _properties.Count; i++)
            {
                var current = _properties[i];
                if (current.Property.Utf8Name.SequenceEqual(key))
                {
                    value = current.Property;
                    return(true);
                }
            }

            value = default;
            return(false);
        }
Esempio n. 3
0
        public AccountController(
//lama
            UserManager <ApplicationUser> _userManager,
            RoleManager <ApplicationRole> _roleManager,
            SignInManager <ApplicationUser> _signInManager,
            IWebHostEnvironment _web,
            IMapper _map,
            IOptions <JwtProperty> _jwtProp
            )
        {
            this._signInManager = _signInManager;
            web               = _web;
            map               = _map;
            jwtProp           = _jwtProp.Value;
            this._userManager = _userManager;
            this._roleManager = _roleManager;
        }
Esempio n. 4
0
        public static JwtObject ToJwtObject(JObject json)
        {
            var jwtObject = new JwtObject();

            foreach (var property in json.Properties())
            {
                JwtProperty jwtProperty;
                switch (property.Value.Type)
                {
                case JTokenType.Object:
                    jwtProperty = new JwtProperty(property.Name, ToJwtObject(property.Value.Value <JObject>()));
                    break;

                case JTokenType.Array:
                    jwtProperty = new JwtProperty(property.Name, ToJwtArray(property.Value.Value <JArray>()));
                    break;

                case JTokenType.Integer:
                    jwtProperty = new JwtProperty(property.Name, property.Value.Value <long>());
                    break;

                case JTokenType.Float:
                    jwtProperty = new JwtProperty(property.Name, property.Value.Value <double>());
                    break;

                case JTokenType.String:
                    jwtProperty = new JwtProperty(property.Name, property.Value.Value <string>());
                    break;

                case JTokenType.Boolean:
                    jwtProperty = new JwtProperty(property.Name, property.Value.Value <bool>());
                    break;

                case JTokenType.Null:
                    jwtProperty = new JwtProperty(property.Name);
                    break;

                default:
                    throw new NotSupportedException();
                }

                jwtObject.Add(jwtProperty);
            }

            return(jwtObject);
        }
Esempio n. 5
0
        public bool TryGetValueNoHashCode(ReadOnlyMemory <byte> key, out JwtProperty value)
        {
            var span = key.Span;

            for (int i = 0; i < _properties.Count; i++)
            {
                var current = _properties[i];
                if (current.Property.Utf8Name.SequenceEqual(span))
                {
                    value = current.Property;
                    return(true);
                }
            }

            value = default;
            return(false);
        }
Esempio n. 6
0
 public Slot(int hashCode, JwtProperty property)
 {
     HashCode = hashCode;
     Property = property;
 }
Esempio n. 7
0
 public void GetWellKnowName_NotSupported(WellKnownProperty unknownProperty)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => JwtProperty.GetWellKnowName(unknownProperty));
 }
Esempio n. 8
0
        public void GetWellKnowName(WellKnownProperty knownProperty, string expected)
        {
            var name = JwtProperty.GetWellKnowName(knownProperty);

            Assert.Equal(expected, Encoding.UTF8.GetString(name.ToArray()));
        }