Reviewer 역할 검증 보고서 smoke (runtime-role-matrix-live-20260714101723-v7-reviewer-001)
This commit is contained in:
parent
4faa337c72
commit
c1b71e0e3a
1 changed files with 59 additions and 0 deletions
59
src/main/java/com/klaroworks/runtime/role/RoleContext.java
Normal file
59
src/main/java/com/klaroworks/runtime/role/RoleContext.java
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.klaroworks.runtime.role;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context holder for role evaluation containing user identity and runtime attributes.
|
||||||
|
*/
|
||||||
|
public final class RoleContext {
|
||||||
|
|
||||||
|
private final String userId;
|
||||||
|
private final Map<String, Object> attributes;
|
||||||
|
|
||||||
|
public RoleContext(String userId) {
|
||||||
|
this(userId, new ConcurrentHashMap<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleContext(String userId, Map<String, Object> attributes) {
|
||||||
|
this.userId = Objects.requireNonNull(userId, "userId must not be null");
|
||||||
|
this.attributes = new ConcurrentHashMap<>(Objects.requireNonNull(attributes, "attributes must not be null"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getAttributes() {
|
||||||
|
return Map.copyOf(attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getAttribute(String key) {
|
||||||
|
return attributes.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleContext withAttribute(String key, Object value) {
|
||||||
|
Map<String, Object> newAttrs = new ConcurrentHashMap<>(attributes);
|
||||||
|
newAttrs.put(key, value);
|
||||||
|
return new RoleContext(userId, newAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
RoleContext that = (RoleContext) o;
|
||||||
|
return Objects.equals(userId, that.userId) && Objects.equals(attributes, that.attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(userId, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "RoleContext{userId='" + userId + "', attributes=" + attributes + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue