Record Class ParResponse
java.lang.Object
java.lang.Record
cloud.opencode.base.oauth2.par.ParResponse
Pushed Authorization Request Response (RFC 9126)
推送授权请求响应(RFC 9126)
Immutable record representing the response from a Pushed Authorization Request (PAR) endpoint as defined in RFC 9126. Contains the request_uri that the client uses to reference the authorization request in a subsequent authorization request.
不可变记录,表示 RFC 9126 定义的推送授权请求(PAR)端点的响应。包含客户端在后续授权请求中 用于引用授权请求的 request_uri。
Features | 主要功能:
- RFC 9126 compliant PAR response - 符合 RFC 9126 的 PAR 响应
- Expiration tracking with createdAt timestamp - 通过 createdAt 时间戳跟踪过期
- Convenience methods for expiration checking - 便捷的过期检查方法
Usage Examples | 使用示例:
// Check PAR response validity
// 检查 PAR 响应的有效性
ParResponse response = par.push(params);
if (!response.isExpired()) {
String authUrl = par.buildAuthorizationUrl(authEndpoint, response, clientId);
// Redirect user to authUrl
}
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: Yes (validates requestUri) - 空值安全: 是(验证 requestUri)
- Since:
- JDK 25, opencode-base-oauth2 V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionParResponse(String requestUri, int expiresIn, Instant createdAt) Compact constructor with validation. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecreatedAtrecord component.final booleanIndicates whether some other object is "equal to" this one.Get the expiration time.intReturns the value of theexpiresInrecord component.final inthashCode()Returns a hash code value for this object.booleanCheck if the PAR response has expired.longGet the remaining time in seconds before expiration.Returns the value of therequestUrirecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ParResponse
-
-
Method Details
-
isExpired
public boolean isExpired()Check if the PAR response has expired. 检查 PAR 响应是否已过期。- Returns:
- true if expired | 已过期返回 true
-
expiresAt
-
remainingSeconds
public long remainingSeconds()Get the remaining time in seconds before expiration. 获取过期前的剩余时间(秒)。- Returns:
- remaining seconds, or 0 if expired | 剩余秒数,已过期则返回 0
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
requestUri
Returns the value of therequestUrirecord component.- Returns:
- the value of the
requestUrirecord component
-
expiresIn
public int expiresIn()Returns the value of theexpiresInrecord component.- Returns:
- the value of the
expiresInrecord component
-
createdAt
Returns the value of thecreatedAtrecord component.- Returns:
- the value of the
createdAtrecord component
-