Record Class ResourceIndicator
java.lang.Object
java.lang.Record
cloud.opencode.base.oauth2.security.ResourceIndicator
Resource Indicator (RFC 8707)
资源指示器(RFC 8707)
Represents an OAuth 2.0 resource indicator as defined in RFC 8707. Resource indicators allow clients to indicate the target resource server when requesting tokens, enabling the authorization server to restrict tokens to specific audiences.
表示 RFC 8707 定义的 OAuth 2.0 资源指示器。资源指示器允许客户端在请求 Token 时指示 目标资源服务器,使授权服务器能够将 Token 限制到特定受众。
Features | 主要功能:
- RFC 8707 compliant resource indicator - 符合 RFC 8707 的资源指示器
- URI validation on construction - 构造时进行 URI 验证
- Immutable record - 不可变记录
Usage Examples | 使用示例:
// Create a resource indicator
// 创建资源指示器
ResourceIndicator resource = ResourceIndicator.of("https://api.example.com");
// Use in authorization request
// 在授权请求中使用
params.put("resource", resource.toParam());
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: Yes (validates inputs) - 空值安全: 是(验证输入)
- Since:
- JDK 25, opencode-base-oauth2 V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static ResourceIndicatorCreate a ResourceIndicator from a URI string.resource()Returns the value of theresourcerecord component.toParam()Get the resource URI string suitable for use as a request parameter.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ResourceIndicator
Compact constructor with validation. 带验证的紧凑构造器。- Throws:
NullPointerException- if resource is null | 如果 resource 为 null 则抛出IllegalArgumentException- if resource is blank or not a valid URI | 如果 resource 为空白或不是有效的 URI 则抛出
-
-
Method Details
-
toParam
Get the resource URI string suitable for use as a request parameter. 获取适合用作请求参数的资源 URI 字符串。- Returns:
- the resource URI string | 资源 URI 字符串
-
of
Create a ResourceIndicator from a URI string. 从 URI 字符串创建 ResourceIndicator。- Parameters:
resource- the resource URI string | 资源 URI 字符串- Returns:
- the resource indicator | 资源指示器
- Throws:
NullPointerException- if resource is null | 如果 resource 为 null 则抛出IllegalArgumentException- if resource is blank or not a valid URI | 如果 resource 为空白或不是有效的 URI 则抛出
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
resource
Returns the value of theresourcerecord component.- Returns:
- the value of the
resourcerecord component
-