Exemplo n.º 1
0
 /// <summary>
 /// Authorizes Resource before save.
 /// </summary>
 /// <param name="dataAccess">Object of ResourceDataAccess class.</param>
 internal void AuthorizeResourcesBeforeSave(ResourceDataAccess dataAccess)
 {
     if (IsSecurityAwareControl && SelectedIdList != null)
     {
         int authorizedResourcesCount = dataAccess.GetAuthorizedResources <CategoryNode>(AuthenticatedToken,
                                                                                         Constants.PermissionRequiredForAssociation, SelectedList as IEnumerable <CategoryNode>).Count();
         if (authorizedResourcesCount != SelectedList.Count)
         {
             throw new UnauthorizedAccessException(string.Format(CultureInfo.CurrentCulture,
                                                                 GlobalResource.UnauthorizedAccessExceptionMultipleResources, Constants.PermissionRequiredForAssociation));
         }
     }
 }
Exemplo n.º 2
0
        void BibTexExportLink_Click(object sender, EventArgs e)
        {
            if (SubjectResource == null)
            {
                return;
            }

            ScholarlyWork scholarlyWorkObj = null;

            using (ResourceDataAccess resourceDAL = new ResourceDataAccess(this.CreateContext()))
            {
                scholarlyWorkObj = (ScholarlyWork)resourceDAL.GetScholarlyWorkWithCitedScholarlyWorks(SubjectResource.Id);

                if (scholarlyWorkObj != null)
                {
                    ICollection <ScholarlyWork> citationsList = scholarlyWorkObj.Cites;
                    List <ScholarlyWork>        citations     = resourceDAL.GetAuthorizedResources <ScholarlyWork>
                                                                    (AuthenticatedToken, UserResourcePermissions.Read, citationsList).ToList();
                    if (citations.Count > 0)
                    {
                        String fileNameToSend = scholarlyWorkObj.Id.ToString() + _bibExtention;
                        String value          = _attachment + fileNameToSend;
                        this.Page.Response.ContentType = _contentTypeOctetStream;
                        this.Page.Response.AddHeader(_responseHeader, value);
                        this.Page.Response.Clear();
                        BibTeXConverter bibConverter = new BibTeXConverter(BibTeXParserBehavior.IgnoreParseErrors);

                        foreach (ScholarlyWork swork in citations)
                        {
                            swork.Authors.Load();
                            swork.Editors.Load();
                        }
                        bibConverter.Export(citations, this.Page.Response.OutputStream);
                        this.Page.Response.Flush();
                        this.Page.Response.End();
                    }
                    else
                    {
                        BibTexExportLink.Visible = false;
                        SeperatorLabel.Visible   = false;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Filter category nodes based on Read permission.
        /// </summary>
        /// <param name="token">Authenticated Token.</param>
        /// <param name="rootCategoryNode">Root CategoryNode Object.</param>
        /// <param name="dataAccess">ResourceDataAccess Object.</param>
        /// <returns>List of Authorized Resources</returns>
        private IEnumerable <Guid> GetAuthorizedCategoryNodes(AuthenticatedToken token, CategoryNode rootCategoryNode,
                                                              ResourceDataAccess dataAccess)
        {
            ICollection <CategoryNode> categoryNodes = new List <CategoryNode>();

            categoryNodes = AddChildCategoryNodes(rootCategoryNode, categoryNodes);

            var authorizedCatNodes = dataAccess.GetAuthorizedResources <CategoryNode>(token,
                                                                                      UserResourcePermissions.Read, categoryNodes);

            if (authorizedCatNodes != null)
            {
                return(authorizedCatNodes.Select(tuple => tuple.Id).ToList());
            }
            else
            {
                return(new List <Guid>());
            }
        }