Exemple #1
0
        public async Task <IdentityServerStoreAppliedInfo> DeleteClientIdsByUserIdAsync(string userId,
                                                                                        IEnumerable <string> clientIds)
        {
            var result = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                var query                 = from item in clientIds
                                    let c = new IdentityServerUserClientId()
                {
                    ClientId = item, UserId = userId
                }
                select c;
                IdentityServerStoreAppliedInfo appliedInfo = null;
                foreach (var insertRecord in query)
                {
                    appliedInfo =
                        await ResilientSessionContainer.ResilientSession.DeleteClientIdFromUserAsync(insertRecord);
                    if (appliedInfo.Applied == false || appliedInfo.Exception != null)
                    {
                        break;
                    }
                }
                return(appliedInfo);
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IdentityServerStoreAppliedInfo>(ex));

            return(result);
        }
Exemple #2
0
        public async Task <IdentityServerStoreAppliedInfo> AddScopesToIdentityServerUserAsync(
            string userId, IEnumerable <string> scopes)
        {
            var result = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                var query                 = from item in scopes
                                    let c = new IdentityServerUserAllowedScope {
                    ScopeName = item, UserId = userId
                }
                select c;
                IdentityServerStoreAppliedInfo appliedInfo = null;
                foreach (var insertRecord in query)
                {
                    appliedInfo =
                        await
                        ResilientSessionContainer.ResilientSession.UpsertAllowedScopeIntoUsersAsync(insertRecord);
                    if (appliedInfo.Applied == false || appliedInfo.Exception != null)
                    {
                        break;
                    }
                }
                return(appliedInfo);
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IdentityServerStoreAppliedInfo>(ex));

            return(result);
        }
Exemple #3
0
 public async Task UpdateIdentityServerUserAsync(IdentityServerUser user)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.UpdateIdentityServerUserAsync(user);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #4
0
 public async Task AddScopeSecretsAsync(string name, IEnumerable <Secret> secrets)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.AddScopeSecretsByNameAsync(name, secrets);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #5
0
 public async Task CreateScopeAsync(Scope scope)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.UpsertScopeAsync(scope);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #6
0
 public async Task UpdateScopeByNameAsync(string name, IEnumerable <PropertyValue> properties)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.UpdateScopeByNameAsync(name, properties);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #7
0
 public async Task DeleteScopeClaimsAsync(string name, IEnumerable <ScopeClaim> claims)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteScopeClaimsFromScopeByNameAsync(name, claims);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #8
0
 public async Task StoreManyAsync(IEnumerable<IDocumentRecord> documentRecords)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async () =>
         {
             await ResilientSessionContainer.EstablishSessionAsync();
             await ResilientSessionContainer.ResilientSession.UpsertManyFlattenedDocumentAsync(documentRecords);
         },
         async (ex) => ResilientSessionContainer.HandleCassandraException<Task>(ex));
 }
 public async Task UpdateClaimsInClientAsync(string clientId, IEnumerable <Claim> claims)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.UpdateClaimsInClientByIdAsync(clientId, claims);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #10
0
 public async Task RemoveClaimAsync(CassandraUser user, Claim claim)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteClaimHandleByUserIdTypeAndValueAsync(user.Id, claim.Type, claim.Value);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #11
0
 public async Task RemoveByIdAsync(Guid id)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async () =>
         {
             await ResilientSessionContainer.EstablishSessionAsync();
             await ResilientSessionContainer.ResilientSession.DeleteFlattenedDocumentByIdAsync(id);
         },
         async (ex) => ResilientSessionContainer.HandleCassandraException<Task>(ex));
 }
Exemple #12
0
 public async Task RemoveFromRoleAsync(CassandraUser user, string roleName)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.RemoveFromRoleAsync(user.Id, roleName);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
 public async Task RevokeAsync(string subject, string client)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteTokensByClientIdAndSubjectId(client, subject);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
 public async Task CleanupClientByIdAsync(string clientId)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.CleanupClientByIdAsync(clientId);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
 public async Task DeleteSecretProtectedValue(ProtectedSecretQueryValues queryValues)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteSecretProtectedValue(queryValues);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #16
0
 public async Task DeleteAsync(CassandraUser user)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteUserAsync(user);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
 public async Task UpdateAsync(CassandraRole role)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.UpdateRoleAsync(role);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
 public async Task DeleteScopesFromClientAsync(string clientId, IEnumerable <string> scopes)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteScopesFromClientByIdAsync(clientId, scopes);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
 public async Task RemoveAsync(string key)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteRefreshTokenByKey(key);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #20
0
 public async Task StoreAsync(string key, global::IdentityServer3.Core.Models.AuthorizationCode value)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.CreateAuthorizationCodeHandleAsync(key, value);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
 public async Task CreateClientAsync(Client client)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.UpsertClientAsync(
             new FlattenedClientHandle(client));
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #22
0
 public async Task<IDocumentRecord> GetByIdAsync(Guid id)
 {
     var result = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async () =>
         {
             await ResilientSessionContainer.EstablishSessionAsync();
             return await ResilientSessionContainer.ResilientSession.FindFlattenedDocumentByIdAsync(id);
         },
         async (ex) => ResilientSessionContainer.HandleCassandraException<IDocumentRecord>(ex));
     return result;
 }
 public async Task StoreAsync(string key, RefreshToken value)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         var flat = new FlattenedRefreshTokenHandle(key, value);
         await ResilientSessionContainer.ResilientSession.CreateRefreshTokenHandleAsync(flat);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #24
0
        public async Task <IPage <ClaimHandle> > PageClaimsAsync(Guid userId, int pageSize, byte[] pagingState)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.PageClaimsAsync(userId, pageSize, pagingState));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IPage <ClaimHandle> >(ex));

            return(resultList);
        }
        public async Task <CassandraRole> FindByIdAsync(Guid roleId)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindRoleByIdAsync(roleId));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <CassandraRole> >(ex));

            return(resultList.FirstOrDefault());
        }
 public async Task AddRedirectUrisToClientAsync(string clientId, IEnumerable <string> redirectUris)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await
         ResilientSessionContainer.ResilientSession.AddRedirectUrisToClientByIdAsync(clientId,
                                                                                     redirectUris);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemple #27
0
        public async Task <IList <string> > GetRolesAsync(CassandraUser user)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindRoleNamesByUserIdAsync(user.Id));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <string> >(ex));

            return(resultList.ToList());
        }
Exemple #28
0
        public async Task <bool> IsInRoleAsync(CassandraUser user, string roleName)
        {
            var result = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.IsUserInRoleAsync(user.Id, roleName));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <bool>(ex));

            return(result);
        }
Exemple #29
0
        public async Task <CassandraUser> FindByNameAsync(string userName)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindUserByUserNameAsync(userName));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <CassandraUser> >(ex));

            return(resultList.FirstOrDefault());
        }
        public async Task <ProtectedSecretHandle> FindSecretProtectedValue(ProtectedSecretQueryValues queryValues)
        {
            var result = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindSecretProtectedValue(queryValues));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <ProtectedSecretHandle>(ex));

            return(result);
        }