aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/user
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-04-15 10:05:14 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-04-15 10:18:15 +0200
commitc0cfa08a3f6d538a684135e2711442a18bd7ddf0 (patch)
tree26ef1d9866327847f9056fa91cf81816a7e128d6 /controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/user
parentc5c5015d4c4aeb1615f86a1b1aa3744bd3ff0722 (diff)
Make Roles static
Diffstat (limited to 'controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/user')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/user/Roles.java22
1 files changed, 7 insertions, 15 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/user/Roles.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/user/Roles.java
index 5f63ad1f185..0eff7de3f9f 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/user/Roles.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/user/Roles.java
@@ -16,18 +16,17 @@ import java.util.List;
*/
public class Roles {
- /** Creates a new UserRoles which can be used for serialisation and listing of bound user roles. */
- public Roles() { }
+ private Roles() { }
/** Returns the list of {@link TenantRole}s a {@link UserId} may be a member of. */
- public List<TenantRole> tenantRoles(TenantName tenant) {
+ public static List<TenantRole> tenantRoles(TenantName tenant) {
return List.of(Role.tenantOwner(tenant),
Role.tenantAdmin(tenant),
Role.tenantOperator(tenant));
}
/** Returns the list of {@link ApplicationRole}s a {@link UserId} may be a member of. */
- public List<ApplicationRole> applicationRoles(TenantName tenant, ApplicationName application) {
+ public static List<ApplicationRole> applicationRoles(TenantName tenant, ApplicationName application) {
return List.of(Role.applicationAdmin(tenant, application),
Role.applicationOperator(tenant, application),
Role.applicationDeveloper(tenant, application),
@@ -35,23 +34,16 @@ public class Roles {
}
/** Returns the {@link Role} the given value represents. */
- public Role toRole(String value) {
+ public static Role toRole(String value) {
String[] parts = value.split("\\.");
- if (parts.length == 1) return toOperatorRole(parts[0]);
+ if (parts.length == 1 && parts[0].equals("hostedOperator")) return Role.hostedOperator();
if (parts.length == 2) return toRole(TenantName.from(parts[0]), parts[1]);
if (parts.length == 3) return toRole(TenantName.from(parts[0]), ApplicationName.from(parts[1]), parts[2]);
throw new IllegalArgumentException("Malformed or illegal role value '" + value + "'.");
}
- public Role toOperatorRole(String roleName) {
- switch (roleName) {
- case "hostedOperator": return Role.hostedOperator();
- default: throw new IllegalArgumentException("Malformed or illegal role name '" + roleName + "'.");
- }
- }
-
/** Returns the {@link Role} the given tenant, application and role names correspond to. */
- public Role toRole(TenantName tenant, String roleName) {
+ public static Role toRole(TenantName tenant, String roleName) {
switch (roleName) {
case "tenantOwner": return Role.tenantOwner(tenant);
case "tenantAdmin": return Role.tenantAdmin(tenant);
@@ -61,7 +53,7 @@ public class Roles {
}
/** Returns the {@link Role} the given tenant and role names correspond to. */
- public Role toRole(TenantName tenant, ApplicationName application, String roleName) {
+ public static Role toRole(TenantName tenant, ApplicationName application, String roleName) {
switch (roleName) {
case "applicationAdmin": return Role.applicationAdmin(tenant, application);
case "applicationOperator": return Role.applicationOperator(tenant, application);