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

Format the interface code and add an obsolete attribute on it #57

Merged
merged 1 commit into from
Jul 28, 2020
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
@@ -1,90 +1,76 @@
// Copyright 2019 The casbin Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;
using NetCasbin.Effect;
using NetCasbin.Persist;
using NetCasbin.Rbac;

namespace NetCasbin
namespace NetCasbin.Abstractions
{

/// <summary>
/// ICoreEnforcer is the API interface of CoreEnforcer
/// </summary>
[Obsolete("The interface will be removed at next mainline version, you can see https://github.com/casbin/Casbin.NET/issues/56 to know more information.")]
public interface ICoreEnforcer
{

/// <summary>
/// <summary>
/// LoadModel reloads the model from the model CONF file. Because the policy is
/// Attached to a model, so the policy is invalidated and needs to be reloaded by
/// calling LoadPolicy().
/// </summary>
void LoadModel();
void LoadModel();

/// <summary>
/// Gets the current model.
/// </summary>
/// <returns>The model of the enforcer.</returns>
Model.Model GetModel();
Model.Model GetModel();

/// <summary>
/// Sets the current model.
/// </summary>
/// <param name="model"></param>
void SetModel(Model.Model model);
void SetModel(Model.Model model);

/// <summary>
/// Gets the current adapter.
/// </summary>
/// <returns></returns>
IAdapter GetAdapter();
IAdapter GetAdapter();

/// <summary>
/// Sets an adapter.
/// </summary>
/// <param name="adapter"></param>
void SetAdapter(IAdapter adapter);
void SetAdapter(IAdapter adapter);

/// <summary>
/// Sets an watcher.
/// </summary>
/// <param name="watcher"></param>
/// <param name="useAsync">Whether use async update callback.</param>
void SetWatcher(IWatcher watcher, bool useAsync = true);
void SetWatcher(IWatcher watcher, bool useAsync = true);

/// <summary>
/// Sets the current role manager.
/// </summary>
/// <param name="roleManager"></param>
void SetRoleManager(IRoleManager roleManager);
void SetRoleManager(IRoleManager roleManager);

/// <summary>
/// Sets the current effector.
/// </summary>
/// <param name="effector"></param>
void SetEffector(IEffector effector);
void SetEffector(IEffector effector);

/// <summary>
/// Clears all policy.
/// </summary>
void ClearPolicy();
void ClearPolicy();

/// <summary>
/// Reloads the policy from file/database.
/// </summary>
void LoadPolicy();
void LoadPolicy();

/// <summary>
/// Reloads the policy from file/database.
Expand All @@ -96,7 +82,7 @@ public interface ICoreEnforcer
/// </summary>
/// <param name="filter">The filter used to specify which type of policy should be loaded.</param>
/// <returns></returns>
bool LoadFilteredPolicy(Filter filter);
bool LoadFilteredPolicy(Filter filter);

/// <summary>
/// Reloads a filtered policy from file/database.
Expand All @@ -109,13 +95,13 @@ public interface ICoreEnforcer
/// Returns true if the loaded policy has been filtered.
/// </summary>
/// <returns>if the loaded policy has been filtered.</returns>
bool IsFiltered();
bool IsFiltered();

/// <summary>
/// Saves the current policy (usually after changed with Casbin API)
/// back to file/database.
/// </summary>
void SavePolicy();
void SavePolicy();

/// <summary>
/// Saves the current policy (usually after changed with Casbin API)
Expand All @@ -128,26 +114,26 @@ public interface ICoreEnforcer
/// all access will be allowed by the enforce() function.
/// </summary>
/// <param name="enable"></param>
void EnableEnforce(bool enable);
void EnableEnforce(bool enable);

/// <summary>
/// Controls whether to save a policy rule automatically to the
/// adapter when it is added or removed.
/// </summary>
/// <param name="autoSave"></param>
void EnableAutoSave(bool autoSave);
void EnableAutoSave(bool autoSave);

/// <summary>
/// Controls whether to save a policy rule automatically
/// to the adapter when it is added or removed.
/// </summary>
/// <param name="autoBuildRoleLinks">Whether to automatically build the role links.</param>
void EnableAutoBuildRoleLinks(bool autoBuildRoleLinks);
void EnableAutoBuildRoleLinks(bool autoBuildRoleLinks);

/// <summary>
/// Manually rebuilds the role inheritance relations.
/// </summary>
void BuildRoleLinks();
void BuildRoleLinks();

/// <summary>
/// Decides whether a "subject" can access a "object" with the operation
Expand All @@ -156,7 +142,7 @@ public interface ICoreEnforcer
/// <param name="rvals">The request needs to be mediated, usually an array of strings,
/// can be class instances if ABAC is used.</param>
/// <returns>Whether to allow the request.</returns>
bool Enforce(params object[] rvals);
bool Enforce(params object[] rvals);
}

}
20 changes: 3 additions & 17 deletions NetCasbin/IEnforcer.cs → NetCasbin/Abstractions/IEnforcer.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
// Copyright 2019 The casbin Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NetCasbin
namespace NetCasbin.Abstractions
{

/// <summary>
/// IEnforcer is the API interface of Enforcer
/// </summary>
[Obsolete("The interface will be changed a lot at next mainline version, you can see https://github.com/casbin/Casbin.NET/issues/56 to know more information.")]
sagilio marked this conversation as resolved.
Show resolved Hide resolved
public interface IEnforcer : IManagementEnforcer
{

/// <summary>
/// Gets the roles that a user has.
/// </summary>
Expand Down
Loading