public async Task CreateAsync(CassandraRole role)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.CreateRoleAsync(role);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemplo n.º 2
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));
 }
Exemplo n.º 3
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));
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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());
        }
Exemplo n.º 6
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 <CassandraUser> FindByEmailAsync(string email)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindUserByEmailAsync(email));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <CassandraUser> >(ex));

            return(resultList.FirstOrDefault());
        }
Exemplo n.º 8
0
 public async Task AddClaimAsync(CassandraUser user, Claim claim)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         var claimHandle = new ClaimHandle()
         {
             Type   = claim.Type,
             Value  = claim.Value,
             UserId = user.Id
         };
         await ResilientSessionContainer.ResilientSession.CreateClaimAsync(claimHandle);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemplo n.º 9
0
        public async Task <IList <Claim> > GetClaimsAsync(CassandraUser user)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindClaimHandleByUserIdAsync(user.Id));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <ClaimHandle> >(ex));

            var query = from item in resultList
                        let c = new Claim(item.Type, item.Value)
                                select c;

            return(query.ToList());
        }
Exemplo n.º 10
0
        public async Task <IList <UserLoginInfo> > GetLoginsAsync(CassandraUser user)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindLoginsByUserIdAsync(user.Id));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <ProviderLoginHandle> >(ex));

            var query = from item in resultList
                        let c = new UserLoginInfo(item.LoginProvider, item.ProviderKey)
                                select c;

            return(query.ToList());
        }
Exemplo n.º 11
0
 public async Task RemoveLoginAsync(CassandraUser user, UserLoginInfo login)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         ProviderLoginHandle providerLogin = new ProviderLoginHandle()
         {
             LoginProvider = login.LoginProvider,
             ProviderKey   = login.ProviderKey,
             TenantId      = ResilientSessionContainer.ResilientSession.TenantId,
             UserId        = user.Id
         };
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteLoginsAsync(providerLogin);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
Exemplo n.º 12
0
        public async Task <CassandraUser> FindAsync(UserLoginInfo login)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindLoginByProviderAsync(login.LoginProvider, login.ProviderKey));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <ProviderLoginHandle> >(ex));

            var plhList = resultList.ToList();

            if (!plhList.Any())
            {
                return(null);
            }

            var result = await FindByIdAsync(plhList.First().UserId);

            return(result);
        }
        public async Task <IQueryable <CassandraRole> > GetAllRoles()
        {
            Exception ex     = null;
            var       result = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync <IEnumerable <CassandraRole> >(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindRolesByTenantIdAsync());
            },
                async (e) =>
            {
                ex = e;
                return(new TryWithAwaitInCatchExcpetionHandleResult <IEnumerable <CassandraRole> >
                {
                    RethrowException = true,
                    DefaultResult = null
                });
            }
                );

            return(result.AsQueryable());
        }