Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added IPermissionDefinitionService for Abstractions Project #5841

Merged
merged 5 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DotNetNuke.Abstractions.Security.Permissions;

/// <summary>Information about the application of an instance of a folder permission.</summary>
public interface IFolderPermissionInfo : IPermissionInfo
{
/// <summary>Gets or sets the ID of the folder permission.</summary>
int FolderPermissionId { get; set; }

/// <summary>Gets or sets the folder ID to which the permission applies.</summary>
int FolderId { get; set; }

/// <summary>Gets or sets the path of the folder to which the permission applies.</summary>
string FolderPath { get; set; }

/// <summary>Gets or sets the portal ID of the folder to which the permission applies.</summary>
int PortalId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DotNetNuke.Abstractions.Security.Permissions;

/// <summary>Information about the definition of a permission.</summary>
public interface IPermissionDefinitionInfo
{
/// <summary>Gets or sets the Module Definition ID.</summary>
public int ModuleDefId { get; set; }

/// <summary>Gets or sets the Permission Code.</summary>
public string PermissionCode { get; set; }

/// <summary>Gets or sets the Permission ID.</summary>
public int PermissionId { get; set; }

/// <summary>Gets or sets the Permission Key.</summary>
public string PermissionKey { get; set; }

/// <summary>Gets or sets the Permission Name.</summary>
public string PermissionName { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DotNetNuke.Abstractions.Security.Permissions;

using System.Collections.Generic;

/// <summary>Handles the Business Control Layer for Permissions.</summary>
public interface IPermissionDefinitionService
{
/// <summary>Gets the permissions.</summary>
/// <returns>The permissions.</returns>
IEnumerable<IPermissionDefinitionInfo> GetDefinitions();

/// <summary>Gets the permissions by folder.</summary>
/// <returns>The permissions by folder.</returns>
IEnumerable<IPermissionDefinitionInfo> GetDefinitionsByFolder();

/// <summary>Gets the permissions by desktop module.</summary>
/// <returns>The permissions by desktop module.</returns>
IEnumerable<IPermissionDefinitionInfo> GetDefinitionsByPortalDesktopModule();

/// <summary>Gets the permissions by tab.</summary>
/// <returns>The permissions by tab.</returns>
IEnumerable<IPermissionDefinitionInfo> GetDefinitionsByTab();

/// <summary>Gets the permissions by <see cref="IPermissionDefinitionInfo.PermissionCode"/> and <see cref="IPermissionDefinitionInfo.PermissionKey"/>.</summary>
/// <param name="permissionCode">The permission code.</param>
/// <param name="permissionKey">The permission key.</param>
/// <returns>The permissions by tab.</returns>
IEnumerable<IPermissionDefinitionInfo> GetDefinitionsByCodeAndKey(string permissionCode, string permissionKey);

/// <summary>Gets the permissions by <see cref="IPermissionDefinitionInfo.ModuleDefId"/>.</summary>
/// <param name="moduleDefId">The module definition ID.</param>
/// <returns>The permissions by tab.</returns>
IEnumerable<IPermissionDefinitionInfo> GetDefinitionsByModuleDefId(int moduleDefId);

/// <summary>Gets the permissions by <see cref="IPermissionDefinitionInfo.ModuleDefId"/> and <see cref="IPermissionDefinitionInfo.PermissionCode"/> for the given module in the tab.</summary>
/// <param name="moduleId">The module ID.</param>
/// <param name="tabId">The tab ID.</param>
/// <returns>The permissions by tab.</returns>
IEnumerable<IPermissionDefinitionInfo> GetDefinitionsByModule(int moduleId, int tabId);

/// <summary>Adds a new permission.</summary>
/// <param name="permissionDefinition">The permission.</param>
/// <returns>The new permission ID.</returns>
int AddDefinition(IPermissionDefinitionInfo permissionDefinition);

/// <summary>Deletes an existing permission.</summary>
/// <param name="permissionDefinition">The permission to delete.</param>
void DeleteDefinition(IPermissionDefinitionInfo permissionDefinition);

/// <summary>Gets the permission by the <see cref="IPermissionDefinitionInfo.PermissionId"/>.</summary>
/// <param name="permissionDefinitionId">The permission ID.</param>
/// <returns>The permission.</returns>
IPermissionDefinitionInfo GetDefinition(int permissionDefinitionId);

/// <summary>Updates an existing permission.</summary>
/// <param name="permission">The permission.</param>
void UpdateDefinition(IPermissionDefinitionInfo permission);

/// <summary>Clears the permission definition cache.</summary>
/// <remarks>
/// <see cref="AddDefinition"/>, <see cref="UpdateDefinition"/> and <see cref="DeleteDefinition"/> will clear the cache automatically.
/// This method is only needed if you want to clear the cache manually.
/// </remarks>
void ClearCache();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DotNetNuke.Abstractions.Security.Permissions;

/// <summary>Information about an applied instance of a permission.</summary>
public interface IPermissionInfo : IPermissionDefinitionInfo
{
/// <summary>Gets or sets a value indicating whether gets and sets a flag that indicates whether the user or role has permission.</summary>
bool AllowAccess { get; set; }

/// <summary>Gets or sets the User's DisplayName.</summary>
string DisplayName { get; set; }

/// <summary>Gets or sets the Role ID.</summary>
int RoleId { get; set; }

/// <summary>Gets or sets the Role Name.</summary>
string RoleName { get; set; }

/// <summary>Gets or sets the User ID.</summary>
int UserId { get; set; }

/// <summary>Gets or sets the User Name.</summary>
string Username { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information
namespace DotNetNuke.Security.Permissions
{
using System;
using System.Collections;
using System.Collections.Generic;
using DotNetNuke.Common.Utilities;

using DotNetNuke.Common.Utilities;

[Serializable]
public class FolderPermissionCollection : CollectionBase
{
/// <summary>Initializes a new instance of the <see cref="FolderPermissionCollection"/> class.</summary>
{
/// <summary>Initializes a new instance of the <see cref="FolderPermissionCollection"/> class.</summary>
public FolderPermissionCollection()
{
}
/// <summary>Initializes a new instance of the <see cref="FolderPermissionCollection"/> class.</summary>
/// <param name="folderPermissions"></param>
}

/// <summary>Initializes a new instance of the <see cref="FolderPermissionCollection"/> class.</summary>
/// <param name="folderPermissions"></param>
public FolderPermissionCollection(ArrayList folderPermissions)
{
this.AddRange(folderPermissions);
}
/// <summary>Initializes a new instance of the <see cref="FolderPermissionCollection"/> class.</summary>
/// <param name="folderPermissions"></param>
}

/// <summary>Initializes a new instance of the <see cref="FolderPermissionCollection"/> class.</summary>
/// <param name="folderPermissions"></param>
public FolderPermissionCollection(FolderPermissionCollection folderPermissions)
{
this.AddRange(folderPermissions);
}
/// <summary>Initializes a new instance of the <see cref="FolderPermissionCollection"/> class.</summary>
/// <param name="folderPermissions"></param>
/// <param name="folderPath"></param>
}

/// <summary>Initializes a new instance of the <see cref="FolderPermissionCollection"/> class.</summary>
/// <param name="folderPermissions"></param>
/// <param name="folderPath"></param>
public FolderPermissionCollection(ArrayList folderPermissions, string folderPath)
{
foreach (FolderPermissionInfo permission in folderPermissions)
Expand Down Expand Up @@ -91,6 +91,14 @@ public int Add(FolderPermissionInfo value, bool checkForDuplicates)
return id;
}

public void AddRange(IEnumerable<FolderPermissionInfo> folderPermissions)
{
foreach (var permission in folderPermissions)
{
this.List.Add(permission);
}
}

public void AddRange(ArrayList folderPermissions)
{
foreach (FolderPermissionInfo permission in folderPermissions)
Expand Down
Loading