Record Class OAuth2Config
java.lang.Object
java.lang.Record
cloud.opencode.base.oauth2.OAuth2Config
public record OAuth2Config(String clientId, String clientSecret, String authorizationEndpoint, String tokenEndpoint, String userInfoEndpoint, String revocationEndpoint, String deviceAuthorizationEndpoint, String redirectUri, Set<String> scopes, GrantType grantType, boolean usePkce, Duration connectTimeout, Duration readTimeout, Duration refreshThreshold)
extends Record
OAuth2 Configuration Record
OAuth2 配置记录
Immutable configuration for OAuth2 client.
OAuth2 客户端的不可变配置。
Features | 主要功能:
- Client credentials - 客户端凭证
- Endpoint configuration - 端点配置
- Scope management - 权限范围管理
- PKCE settings - PKCE 设置
- Timeout configuration - 超时配置
Usage Examples | 使用示例:
// Build configuration
OAuth2Config config = OAuth2Config.builder()
.clientId("your-client-id")
.clientSecret("your-client-secret")
.authorizationEndpoint("https://oauth.example.com/authorize")
.tokenEndpoint("https://oauth.example.com/token")
.redirectUri("https://yourapp.com/callback")
.scopes("openid", "email", "profile")
.build();
Thread Safety | 线程安全:
This class is immutable and thread-safe.
此类是不可变的,线程安全。
- Since:
- JDK 25, opencode-base-oauth2 V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOAuth2Config Builder OAuth2Config 构建器 -
Constructor Summary
ConstructorsConstructorDescriptionOAuth2Config(String clientId, String clientSecret, String authorizationEndpoint, String tokenEndpoint, String userInfoEndpoint, String revocationEndpoint, String deviceAuthorizationEndpoint, String redirectUri, Set<String> scopes, GrantType grantType, boolean usePkce, Duration connectTimeout, Duration readTimeout, Duration refreshThreshold) Compact constructor with validation 带验证的紧凑构造器 -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theauthorizationEndpointrecord component.static OAuth2Config.Builderbuilder()Create a new builder 创建新的构建器clientId()Returns the value of theclientIdrecord component.Returns the value of theclientSecretrecord component.Returns the value of theconnectTimeoutrecord component.Returns the value of thedeviceAuthorizationEndpointrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thegrantTyperecord component.booleanCheck if device authorization endpoint is configured 检查是否配置了设备授权端点final inthashCode()Returns a hash code value for this object.booleanCheck if revocation endpoint is configured 检查是否配置了撤销端点booleanCheck if user info endpoint is configured 检查是否配置了用户信息端点booleanCheck if this config is for authorization code flow 检查此配置是否用于授权码流程booleanCheck if this config is for client credentials flow 检查此配置是否用于客户端凭证流程booleanCheck if this config is for device code flow 检查此配置是否用于设备码流程Returns the value of thereadTimeoutrecord component.Returns the value of theredirectUrirecord component.Returns the value of therefreshThresholdrecord component.Returns the value of therevocationEndpointrecord component.scopes()Returns the value of thescopesrecord component.Returns the value of thetokenEndpointrecord component.final StringtoString()Returns a string representation of this record class.booleanusePkce()Returns the value of theusePkcerecord component.Returns the value of theuserInfoEndpointrecord component.
-
Constructor Details
-
OAuth2Config
public OAuth2Config(String clientId, String clientSecret, String authorizationEndpoint, String tokenEndpoint, String userInfoEndpoint, String revocationEndpoint, String deviceAuthorizationEndpoint, String redirectUri, Set<String> scopes, GrantType grantType, boolean usePkce, Duration connectTimeout, Duration readTimeout, Duration refreshThreshold) Compact constructor with validation 带验证的紧凑构造器
-
-
Method Details
-
isAuthorizationCodeFlow
public boolean isAuthorizationCodeFlow()Check if this config is for authorization code flow 检查此配置是否用于授权码流程- Returns:
- true if authorization code flow | 授权码流程返回 true
-
isClientCredentialsFlow
public boolean isClientCredentialsFlow()Check if this config is for client credentials flow 检查此配置是否用于客户端凭证流程- Returns:
- true if client credentials flow | 客户端凭证流程返回 true
-
isDeviceCodeFlow
public boolean isDeviceCodeFlow()Check if this config is for device code flow 检查此配置是否用于设备码流程- Returns:
- true if device code flow | 设备码流程返回 true
-
hasUserInfoEndpoint
public boolean hasUserInfoEndpoint()Check if user info endpoint is configured 检查是否配置了用户信息端点- Returns:
- true if configured | 已配置返回 true
-
hasRevocationEndpoint
public boolean hasRevocationEndpoint()Check if revocation endpoint is configured 检查是否配置了撤销端点- Returns:
- true if configured | 已配置返回 true
-
hasDeviceAuthorizationEndpoint
public boolean hasDeviceAuthorizationEndpoint()Check if device authorization endpoint is configured 检查是否配置了设备授权端点- Returns:
- true if configured | 已配置返回 true
-
builder
Create a new builder 创建新的构建器- Returns:
- the builder | 构建器
-
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. -
clientId
Returns the value of theclientIdrecord component.- Returns:
- the value of the
clientIdrecord component
-
clientSecret
Returns the value of theclientSecretrecord component.- Returns:
- the value of the
clientSecretrecord component
-
authorizationEndpoint
Returns the value of theauthorizationEndpointrecord component.- Returns:
- the value of the
authorizationEndpointrecord component
-
tokenEndpoint
Returns the value of thetokenEndpointrecord component.- Returns:
- the value of the
tokenEndpointrecord component
-
userInfoEndpoint
Returns the value of theuserInfoEndpointrecord component.- Returns:
- the value of the
userInfoEndpointrecord component
-
revocationEndpoint
Returns the value of therevocationEndpointrecord component.- Returns:
- the value of the
revocationEndpointrecord component
-
deviceAuthorizationEndpoint
Returns the value of thedeviceAuthorizationEndpointrecord component.- Returns:
- the value of the
deviceAuthorizationEndpointrecord component
-
redirectUri
Returns the value of theredirectUrirecord component.- Returns:
- the value of the
redirectUrirecord component
-
scopes
-
grantType
Returns the value of thegrantTyperecord component.- Returns:
- the value of the
grantTyperecord component
-
usePkce
public boolean usePkce()Returns the value of theusePkcerecord component.- Returns:
- the value of the
usePkcerecord component
-
connectTimeout
Returns the value of theconnectTimeoutrecord component.- Returns:
- the value of the
connectTimeoutrecord component
-
readTimeout
Returns the value of thereadTimeoutrecord component.- Returns:
- the value of the
readTimeoutrecord component
-
refreshThreshold
Returns the value of therefreshThresholdrecord component.- Returns:
- the value of the
refreshThresholdrecord component
-