public AccessToken GenerateToken(IdentityToken identityToken, SecurityResourceDto resource)
        {
            AccessToken token = new AccessToken();

            ResourceBussiness resourceBa = new ResourceBussiness();

            var secutiryResource = resourceBa.GetSingle(it => it.SecurityResourceId == resource.SecurityResourceId);

            int  userId     = 0;
            long resourceId = 0;

            if (secutiryResource != null)
            {
                resourceId = secutiryResource.SecurityResourceId;
            }
            int.TryParse(identityToken.SubjectId, out userId);

            var operationList = resourceBa.GetAllUserOperations(userId, resourceId);

            token.Operations.AddRange(operationList);
            token.Resource = secutiryResource;
            token.UserName = identityToken.UserName;
            return(token);
        }
Exemplo n.º 2
0
        public Framework.Common.CommonBase.BaseDto GetSingle(long id)
        {
            var result = resourceBussiness.GetSingle(it => it.SecurityResourceId == id);

            return(result);
        }