-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide new authorization role for user admin
- Loading branch information
mebo4b
committed
Nov 20, 2020
1 parent
831c2e5
commit 1962b75
Showing
18 changed files
with
224 additions
and
208 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
src/main/java/de/caritas/cob/userservice/api/authorization/Authorities.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,68 @@ | ||
package de.caritas.cob.userservice.api.authorization; | ||
|
||
import static java.util.Arrays.asList; | ||
import static java.util.Collections.emptyList; | ||
import static java.util.Collections.singletonList; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Stream; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
/** | ||
* Definition of all authorities and of the role-authority-mapping. | ||
*/ | ||
@AllArgsConstructor | ||
@Getter | ||
public enum Authorities { | ||
|
||
CONSULTANT(UserRole.CONSULTANT, singletonList(Authority.CONSULTANT_DEFAULT)), | ||
USER(UserRole.USER, singletonList(Authority.USER_DEFAULT)), | ||
U25_CONSULTANT(UserRole.U25_CONSULTANT, singletonList(Authority.USE_FEEDBACK)), | ||
U25_MAIN_CONSULTANT(UserRole.U25_MAIN_CONSULTANT, asList( | ||
Authority.VIEW_ALL_FEEDBACK_SESSIONS, Authority.VIEW_ALL_PEER_SESSIONS, | ||
Authority.ASSIGN_CONSULTANT_TO_SESSION, Authority.ASSIGN_CONSULTANT_TO_ENQUIRY, | ||
Authority.VIEW_AGENCY_CONSULTANTS)), | ||
TECHNICAL(UserRole.TECHNICAL, singletonList(Authority.TECHNICAL_DEFAULT)), | ||
KREUZBUND_CONSULTANT(UserRole.KREUZBUND_CONSULTANT, asList( | ||
Authority.CONSULTANT_DEFAULT, Authority.CREATE_NEW_CHAT, | ||
Authority.START_CHAT, Authority.STOP_CHAT, Authority.UPDATE_CHAT)), | ||
USER_ADMIN(UserRole.USER_ADMIN, singletonList(Authority.USER_ADMIN)); | ||
|
||
private final UserRole userRole; | ||
private final List<String> auhorities; | ||
|
||
public static List<String> getAuthoritiesByUserRole(UserRole userRole) { | ||
Optional<Authorities> authorityByUserRole = Stream.of(values()) | ||
.filter(authority -> authority.userRole.equals(userRole)) | ||
.findFirst(); | ||
|
||
return authorityByUserRole.isPresent() ? | ||
authorityByUserRole.get().getAuhorities() : emptyList(); | ||
} | ||
|
||
public static class Authority { | ||
|
||
private Authority() {} | ||
|
||
public static final String PREFIX = "AUTHORIZATION_"; | ||
public static final String CONSULTANT_DEFAULT = PREFIX + "CONSULTANT_DEFAULT"; | ||
public static final String USER_DEFAULT = PREFIX + "USER_DEFAULT"; | ||
public static final String USE_FEEDBACK = PREFIX + "USE_FEEDBACK"; | ||
public static final String VIEW_ALL_FEEDBACK_SESSIONS = PREFIX + "VIEW_ALL_FEEDBACK_SESSIONS"; | ||
public static final String VIEW_ALL_PEER_SESSIONS = PREFIX + "VIEW_ALL_PEER_SESSIONS"; | ||
public static final String ASSIGN_CONSULTANT_TO_SESSION = | ||
PREFIX + "ASSIGN_CONSULTANT_TO_SESSION"; | ||
public static final String ASSIGN_CONSULTANT_TO_ENQUIRY = | ||
PREFIX + "ASSIGN_CONSULTANT_TO_ENQUIRY"; | ||
public static final String VIEW_AGENCY_CONSULTANTS = PREFIX + "VIEW_AGENCY_CONSULTANTS"; | ||
public static final String TECHNICAL_DEFAULT = PREFIX + "TECHNICAL_DEFAULT"; | ||
public static final String CREATE_NEW_CHAT = PREFIX + "CREATE_NEW_CHAT"; | ||
public static final String START_CHAT = PREFIX + "START_CHAT"; | ||
public static final String STOP_CHAT = PREFIX + "STOP_CHAT"; | ||
public static final String UPDATE_CHAT = PREFIX + "UPDATE_CHAT"; | ||
public static final String USER_ADMIN = PREFIX + "USER_ADMIN"; | ||
} | ||
|
||
} |
66 changes: 0 additions & 66 deletions
66
src/main/java/de/caritas/cob/userservice/api/authorization/Authority.java
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.