Beispiel #1
0
        public async Task <IdentityResult> DeletePropertyAsync(Neo4jIdentityServer4Client client,
                                                               Neo4jIdentityServer4ClientProperty property,
                                                               CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            client.ThrowIfNull(nameof(client));
            property.ThrowIfNull(nameof(property));
            try
            {
                var cypher = $@"
                MATCH (client:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasProperty}]->(property:{
                        IdSrv4ClientProperty
                    })
                WHERE client.ClientId = $p0 AND property.Key = $p1 AND property.Value = $p2 
                DETACH DELETE property";

                await Session.RunAsync(cypher,
                                       Params.Create(
                                           client.ClientId,
                                           property.Key,
                                           property.Value
                                           ));
                await RaiseClientChangeEventAsync(client);

                return(IdentityResult.Success);
            }
            catch (ClientException ex)
            {
                return(ex.ToIdentityResult());
            }
        }
Beispiel #2
0
        public async Task <Neo4jIdentityServer4ClientProperty> FindPropertyAsync(Neo4jIdentityServer4Client client,
                                                                                 Neo4jIdentityServer4ClientProperty property,
                                                                                 CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            client.ThrowIfNull(nameof(client));
            property.ThrowIfNull(nameof(property));
            var cypher = $@"
                MATCH (client:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasProperty}]->(property:{
                    IdSrv4ClientProperty
                })
                WHERE client.ClientId = $p0 AND property.Key = $p1 AND property.Value = $p2  
                RETURN property{{ .* }}";

            var result = await Session.RunAsync(cypher,
                                                Params.Create(
                                                    client.ClientId,
                                                    property.Key,
                                                    property.Value

                                                    ));

            var foundRecord =
                await result.SingleOrDefaultAsync(r => r.MapTo <Neo4jIdentityServer4ClientProperty>("property"));

            return(foundRecord);
        }
Beispiel #3
0
        public async Task <IdentityResult> AddPropertyToClientAsync(Neo4jIdentityServer4Client client,
                                                                    Neo4jIdentityServer4ClientProperty property,
                                                                    CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            client.ThrowIfNull(nameof(client));
            property.ThrowIfNull(nameof(property));
            try
            {
                var cypher = $@"
                MATCH (client:{IdSrv4Client} {{ClientId: $p0}})
                CREATE UNIQUE(
                    (client)-[:{Neo4jConstants.Relationships.HasProperty}]->
                    (:{IdSrv4ClientProperty} {"$p1".AsMapForNoNull(property)}))";



                var result = await Session.RunAsync(cypher, Params.Create(client.ClientId, property));
                await RaiseClientChangeEventAsync(client);

                return(IdentityResult.Success);
            }
            catch (ClientException ex)
            {
                return(ex.ToIdentityResult());
            }
        }
 /// <summary>
 /// Maps an entity to a model.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <returns></returns>
 public static KeyValuePair <string, string> ToModel(this Neo4jIdentityServer4ClientProperty entity)
 {
     return(Mapper.Map <KeyValuePair <string, string> >(entity));
 }