Reviewer 역할 검증 보고서 smoke (runtime-role-matrix-live-20260714101723-v7-reviewer-001)

This commit is contained in:
forge-bot 2026-07-14 10:32:03 +00:00
parent f51456868b
commit be4d2414a8

View file

@ -0,0 +1,80 @@
package com.klaroworks.runtime.role;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
/**
* Role context interface for role-based access control.
* Used by RoleMatrixRuntimeTest for context management testing.
*/
public interface RoleContext {
/**
* Get the current user ID.
* @return user identifier
*/
String getUserId();
/**
* Get the current role.
* @return role name
*/
String getRole();
/**
* Get permissions associated with this context.
* @return immutable map of permissions
*/
Map<String, Boolean> getPermissions();
/**
* Check if a specific permission is granted.
* @param permission permission key
* @return true if granted
*/
boolean hasPermission(String permission);
/**
* Simple implementation of RoleContext.
*/
class SimpleRoleContext implements RoleContext {
private final String userId;
private final String role;
private final Map<String, Boolean> permissions;
public SimpleRoleContext(String userId, String role, Map<String, Boolean> permissions) {
this.userId = userId;
this.role = role;
this.permissions = permissions != null ? Collections.unmodifiableMap(new HashMap<>(permissions)) : Collections.emptyMap();
}
@Override
public String getUserId() {
return userId;
}
@Override
public String getRole() {
return role;
}
@Override
public Map<String, Boolean> getPermissions() {
return permissions;
}
@Override
public boolean hasPermission(String permission) {
return permissions.getOrDefault(permission, false);
}
public static SimpleRoleContext of(String userId, String role) {
return new SimpleRoleContext(userId, role, Map.of(
"read", true,
"write", role.equals("ADMIN") || role.equals("MANAGER"),
"delete", role.equals("ADMIN")
));
}
}
}