Esempio n. 1
0
        internal static DefaultAuthorizationPolicy DeserializeDefaultAuthorizationPolicy(JsonElement element)
        {
            Optional <AllowedPrincipals> allowedPrincipals   = default;
            Optional <IList <string> >   allowedApplications = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("allowedPrincipals"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    allowedPrincipals = AllowedPrincipals.DeserializeAllowedPrincipals(property.Value);
                    continue;
                }
                if (property.NameEquals("allowedApplications"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    allowedApplications = array;
                    continue;
                }
            }
            return(new DefaultAuthorizationPolicy(allowedPrincipals.Value, Optional.ToList(allowedApplications)));
        }
Esempio n. 2
0
 internal DefaultAuthorizationPolicy(AllowedPrincipals allowedPrincipals, IList <string> allowedApplications)
 {
     AllowedPrincipals   = allowedPrincipals;
     AllowedApplications = allowedApplications;
 }