-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from bioinformatics-ua/imp/rbac
RBAC + Restrictions to admin/non admin and restrictions for each web plugin
- Loading branch information
Showing
35 changed files
with
1,161 additions
and
158 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
dicoogle/src/main/java/pt/ua/dicoogle/server/users/Role.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ | ||
* | ||
* This file is part of Dicoogle/dicoogle. | ||
* | ||
* Dicoogle/dicoogle is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Dicoogle/dicoogle is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package pt.ua.dicoogle.server.users; | ||
|
||
/** | ||
* Created by bastiao on 23/01/16. | ||
*/ | ||
public class Role { | ||
|
||
|
||
private String name; | ||
public Role(String name) | ||
{ | ||
this.name = name; | ||
|
||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
return "Role{" + | ||
"name='" + name + '\'' + | ||
'}'; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
|
||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
Role role = (Role) o; | ||
|
||
return !(name != null ? !name.equals(role.name) : role.name != null); | ||
|
||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return name != null ? name.hashCode() : 0; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
dicoogle/src/main/java/pt/ua/dicoogle/server/users/RoleManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ | ||
* | ||
* This file is part of Dicoogle/dicoogle. | ||
* | ||
* Dicoogle/dicoogle is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Dicoogle/dicoogle is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package pt.ua.dicoogle.server.users; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* Created by bastiao on 23/01/16. | ||
*/ | ||
public interface RoleManager { | ||
|
||
public boolean hasRole(User user, Role r); | ||
public Collection<Role> getRoles(); | ||
public void addRole(Role r); | ||
public Role getRole(String name); | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
dicoogle/src/main/java/pt/ua/dicoogle/server/users/RolesStruct.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ | ||
* | ||
* This file is part of Dicoogle/dicoogle. | ||
* | ||
* Dicoogle/dicoogle is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Dicoogle/dicoogle is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package pt.ua.dicoogle.server.users; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* Created by bastiao on 23/01/16. | ||
*/ | ||
public class RolesStruct implements RoleManager{ | ||
|
||
private static RolesStruct instance = null ; | ||
|
||
private Set<Role> roles = new HashSet<>(); | ||
private Map<String, Role> rolesMap = new HashMap<String, Role>(); | ||
|
||
public static synchronized RolesStruct getInstance() { | ||
if (instance == null) { | ||
instance = new RolesStruct(); | ||
} | ||
|
||
return instance; | ||
} | ||
private RolesStruct(){ | ||
reset(); | ||
} | ||
|
||
public void reset(){ | ||
roles = new HashSet<>(); | ||
} | ||
|
||
@Override | ||
public boolean hasRole(User user, Role r) { | ||
if (user==null||r==null) | ||
return false; | ||
return UsersStruct.getInstance().getUser(user.getUsername()).hasRole(r); | ||
} | ||
|
||
@Override | ||
public Set<Role> getRoles() { | ||
return this.roles; | ||
} | ||
|
||
@Override | ||
public void addRole(Role r) { | ||
this.roles.add(r); | ||
this.rolesMap.put(r.getName(), r); | ||
|
||
} | ||
|
||
@Override | ||
public Role getRole(String name) { | ||
|
||
return this.rolesMap.get(name); | ||
} | ||
} |
Oops, something went wrong.