Skip to content

Commit

Permalink
Role manager abstract class(interface) added.
Browse files Browse the repository at this point in the history
Role manager abstract class(interface) added.

Changes in include directives.

Made necessary changes

Removed .github folder.
  • Loading branch information
divy9881 committed Mar 6, 2020
1 parent ff73c5e commit 6c67bd8
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 81 deletions.
8 changes: 0 additions & 8 deletions .github/FUNDING.yml

This file was deleted.

16 changes: 1 addition & 15 deletions src/effect/DefaultEffector.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
// Copyright 2018 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.

#include <string>

#include "Effect.h"
#include "Effector.h"
#include "exception/CasbinEffectExceptions.h"
#include "exception/UnsupportedOperationException.h"

/**
* DefaultEffector is default effector for Casbin.
Expand Down
14 changes: 0 additions & 14 deletions src/effect/Effect.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
// Copyright 2018 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.

enum Effect{
Allow, Indeterminate, Deny
};
Expand Down
14 changes: 0 additions & 14 deletions src/effect/Effector.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
// Copyright 2018 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.

#include <string>

#include "Effect.h"
Expand Down
24 changes: 0 additions & 24 deletions src/exception/CasbinEffectExceptions.h

This file was deleted.

10 changes: 10 additions & 0 deletions src/exception/IllegalArgumentException.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <string>

// Exception class for unsupported operations.
class IllegalArgumentException{
std::string error_message;
public:
IllegalArgumentException(std::string error_message){
this->error_message = error_message;
}
};
10 changes: 10 additions & 0 deletions src/exception/UnsupportedOperationException.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <string>

// Exception class for unsupported operations.
class UnsupportedOperationException{
std::string error_message;
public:
UnsupportedOperationException(std::string error_message){
this->error_message = error_message;
}
};
1 change: 0 additions & 1 deletion src/main/placeholder.txt

This file was deleted.

1 change: 0 additions & 1 deletion src/model/placeholder.txt

This file was deleted.

1 change: 0 additions & 1 deletion src/persist/placeholder.txt

This file was deleted.

65 changes: 65 additions & 0 deletions src/rbac/RoleManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <string>
#include <vector>

using namespace std;

class RoleManager {
public:
/**
* Clear clears all stored data and resets the role manager to the initial state.
*/
virtual void clear() = 0;

/**
* addLink adds the inheritance link between two roles. role: name1 and role: name2.
* domain is a prefix to the roles.
*
* @param name1 the first role (or user).
* @param name2 the second role.
* @param domain the domain the roles belong to.
*/
virtual void addLink(string name1, string name2, string domain[]) = 0;

/**
* deleteLink deletes the inheritance link between two roles. role: name1 and role: name2.
* domain is a prefix to the roles.
*
* @param name1 the first role (or user).
* @param name2 the second role.
* @param domain the domain the roles belong to.
*/
virtual void deleteLink(string name1, string name2, string domain[]) = 0;

/**
* hasLink determines whether a link exists between two roles. role: name1 inherits role: name2.
* domain is a prefix to the roles.
*
* @param name1 the first role (or a user).
* @param name2 the second role.
* @param domain the domain the roles belong to.
* @return whether name1 inherits name2 (name1 has role name2).
*/
virtual bool hasLink(string name1, string name2, string domain[]) = 0;

/**
* getRoles gets the roles that a user inherits.
* domain is a prefix to the roles.
*
* @param name the user (or a role).
* @param domain the domain the roles belong to.
* @return the roles.
*/
virtual vector<string> getRoles(string name, string domain[]) = 0;

/**
* getUsers gets the users that inherits a role.
* @param name the role.
* @return the users.
*/
virtual vector<string> getUsers(string name) = 0;

/**
* printRoles prints all the roles to log.
*/
virtual void printRoles() = 0;
};
1 change: 0 additions & 1 deletion src/rbac/placeholder.txt

This file was deleted.

1 change: 0 additions & 1 deletion src/util/placeholder.txt

This file was deleted.

1 change: 0 additions & 1 deletion test/placeholder.txt

This file was deleted.

0 comments on commit 6c67bd8

Please sign in to comment.