Data Pipeline Patterns
Permission Matrix
A simple permission matrix maps a role to the actions that role can perform.
Permission Matrix
PermissionMatrix.java
public class PermissionMatrix {
static String actionsFor(String role) {
if (role.equals("viewer")) {
return "read";
}
if (role.equals("editor")) {
return "read,write";
}
return "read,write,delete";
}
public static void main(String[] args) {
String role = ;
String actions = actionsFor(role);
boolean canDelete = actions.contains("delete");
System.out.println("role=" + role);
System.out.println("actions=" + actions);
System.out.println("delete=" + canDelete);
}
}
public class PermissionMatrix {
static String actionsFor(String role) {
if (role.equals("viewer")) {
return "read";
}
if (role.equals("editor")) {
return "read,write";
}
return "read,write,delete";
}
public static void main(String[] args) {
String role = ;
String actions = actionsFor(role);
boolean canDelete = actions.contains("delete");
System.out.println("role=" + role);
System.out.println("actions=" + actions);
System.out.println("delete=" + canDelete);
}
}
public class PermissionMatrix {
static String actionsFor(String role) {
if (role.equals("viewer")) {
return "read";
}
if (role.equals("editor")) {
return "read,write";
}
return "read,write,delete";
}
public static void main(String[] args) {
String role = ;
String actions = actionsFor(role);
boolean canDelete = actions.contains("delete");
System.out.println("role=" + role);
System.out.println("actions=" + actions);
System.out.println("delete=" + canDelete);
}
}
role mapping
The role decides which action list flows to the rest of the program.
derived permission
The delete flag is derived from the action list, keeping the final check visible.