Exemplo n.º 1
0
        internal static CertBasedSecurityPrincipal DeserializeCertBasedSecurityPrincipal(JsonElement element)
        {
            Optional <string>         cert           = default;
            Optional <LedgerRoleName> ledgerRoleName = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("cert"))
                {
                    cert = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("ledgerRoleName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    ledgerRoleName = new LedgerRoleName(property.Value.GetString());
                    continue;
                }
            }
            return(new CertBasedSecurityPrincipal(cert.Value, Optional.ToNullable(ledgerRoleName)));
        }
Exemplo n.º 2
0
        internal static AadBasedSecurityPrincipal DeserializeAadBasedSecurityPrincipal(JsonElement element)
        {
            Optional <string>         principalId    = default;
            Optional <Guid>           tenantId       = default;
            Optional <LedgerRoleName> ledgerRoleName = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("principalId"))
                {
                    principalId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tenantId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    tenantId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("ledgerRoleName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    ledgerRoleName = new LedgerRoleName(property.Value.GetString());
                    continue;
                }
            }
            return(new AadBasedSecurityPrincipal(principalId.Value, Optional.ToNullable(tenantId), Optional.ToNullable(ledgerRoleName)));
        }