public bool IsContentAccessAllowed( int contentID, SecureRequestContext.ContentType contentType, out List <GroupPermissions> allowedUserGroups) { allowedUserGroups = null; if (!IsUseSecurityRules) { return(true); } bool isAllowed = false; if (!IsContentIdValid(contentID)) { return(false); } allowedUserGroups = GetGroupsPermittedToContent( CurrentUserSecurityContext.CurrentUserGroupPermissions, contentID, contentType); isAllowed = (allowedUserGroups != null && allowedUserGroups.Count > 0); return(isAllowed); }
public List <GroupPermissions> GetGroupsPermittedToContent( List <GroupPermissions> userGroupsPermissions, int contentID, SecureRequestContext.ContentType contentType) { List <GroupPermissions> allowedUserGroups = null; if (userGroupsPermissions == null) { Logger.LogError(5, "NULL userGroupsPermissions detected, abandoning GetGroupsPermittedToContent ..."); return(null); } foreach (GroupPermissions usrGroupPerms in userGroupsPermissions) { if (usrGroupPerms == null) { Logger.LogWarning("NULL usrGroupPerms detected, skiping it ..."); continue; } if (usrGroupPerms.GroupContentPermissions != null && usrGroupPerms.GroupContentPermissions.Count > 0) { foreach (GroupPermissions.GroupContentPermission grpContentPerm in usrGroupPerms.GroupContentPermissions) { if (grpContentPerm.ContentType == contentType && grpContentPerm.ContentID > 0 && grpContentPerm.ContentID == contentID ) { if (allowedUserGroups == null) { allowedUserGroups = new List <GroupPermissions>(); } allowedUserGroups.Add(usrGroupPerms); } } } } return(allowedUserGroups); }
public List <GroupContentPermission> GetGroupContentPermissions(List <MGSecurityTag> groupContentSecKeyValPairs) { if (groupContentSecKeyValPairs == null) { Logger.LogError(5, "Cannot GetGroupContentPermissions from NULL list of SecurityTags!"); return(null); } List <GroupContentPermission> groupContentPerms = null; try { groupContentPerms = new List <GroupContentPermission>(); GroupContentPermission groupContentPerm = null; SecureRequestContext.ContentType contentType = SecureRequestContext.ContentType.UNKNOWN; int contentID = -1; foreach (MGSecurityTag securityTag in groupContentSecKeyValPairs) { contentType = SecureRequestContext.ContentType.UNKNOWN; contentID = -1; if (securityTag.Name == null || securityTag.Name == String.Empty) { Logger.LogWarning("NULL security tag name detected, skipping it ..."); continue; } try { contentType = (SecureRequestContext.ContentType) Enum.Parse(typeof(SecureRequestContext.ContentType), securityTag.Name.ToUpper()); } catch (Exception ex) { Logger.LogError(5, "Problem parsing security tag " + securityTag.Name.ToUpper() + " at " + ex.StackTrace); return(null); } if (contentType != SecureRequestContext.ContentType.UNKNOWN) { groupContentPerm = new GroupContentPermission(); groupContentPerm.ContentType = contentType; if (securityTag.SubType > 0) { contentID = securityTag.SubType; } groupContentPerm.ContentID = contentID; groupContentPerms.Add(groupContentPerm); } } } catch (Exception ex) { Logger.LogError(5, "Error getting groupContentPermissions at " + ex.StackTrace); return(null); } return(groupContentPerms); }
public ContentType() { typeOfContent = SecureRequestContext.ContentType.UNKNOWN; }