From c1b71e0e3af9e5b17beef6971a86d925db53ccf7 Mon Sep 17 00:00:00 2001 From: forge-bot Date: Tue, 14 Jul 2026 10:29:48 +0000 Subject: [PATCH] =?UTF-8?q?Reviewer=20=EC=97=AD=ED=95=A0=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EB=B3=B4=EA=B3=A0=EC=84=9C=20smoke=20(runtime-role?= =?UTF-8?q?-matrix-live-20260714101723-v7-reviewer-001)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../klaroworks/runtime/role/RoleContext.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/com/klaroworks/runtime/role/RoleContext.java diff --git a/src/main/java/com/klaroworks/runtime/role/RoleContext.java b/src/main/java/com/klaroworks/runtime/role/RoleContext.java new file mode 100644 index 0000000..51c18ec --- /dev/null +++ b/src/main/java/com/klaroworks/runtime/role/RoleContext.java @@ -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 attributes; + + public RoleContext(String userId) { + this(userId, new ConcurrentHashMap<>()); + } + + public RoleContext(String userId, Map 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 getAttributes() { + return Map.copyOf(attributes); + } + + public Object getAttribute(String key) { + return attributes.get(key); + } + + public RoleContext withAttribute(String key, Object value) { + Map 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 + "}"; + } +}