Class CustomProvider
java.lang.Object
cloud.opencode.base.oauth2.provider.CustomProvider
- All Implemented Interfaces:
OAuth2Provider
Custom OAuth2 Provider
自定义 OAuth2 Provider
A configurable OAuth2 provider for custom authorization servers.
用于自定义授权服务器的可配置 OAuth2 提供者。
Features | 主要功能:
- Fully configurable endpoints - 完全可配置的端点
- Custom default scopes - 自定义默认范围
- Immutable after creation - 创建后不可变
Usage Examples | 使用示例:
// Create a custom provider
OAuth2Provider provider = CustomProvider.builder()
.name("MyProvider")
.authorizationEndpoint("https://auth.example.com/authorize")
.tokenEndpoint("https://auth.example.com/token")
.userInfoEndpoint("https://auth.example.com/userinfo")
.defaultScopes("openid", "profile", "email")
.build();
// Use the provider
OAuth2Client client = OAuth2Client.builder()
.provider(provider)
.clientId("my-client-id")
.clientSecret("my-client-secret")
.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 classCustomProvider Builder CustomProvider 构建器 -
Method Summary
Modifier and TypeMethodDescriptionGet the authorization endpoint URL 获取授权端点 URLstatic CustomProvider.Builderbuilder()Create a new builder 创建新的构建器Get the default scopes for this provider 获取此提供者的默认权限范围Get the device authorization endpoint URL 获取设备授权端点 URLbooleanstatic CustomProvider.Builderfrom(OAuth2Provider provider) Create a builder from an existing provider 从现有 Provider 创建构建器inthashCode()issuer()Get the issuer 获取发行者jwksUri()Get the JWKS URI 获取 JWKS URIname()Get the provider name 获取提供者名称Get the revocation endpoint URL 获取撤销端点 URLtoConfig(String clientId, String clientSecret, String redirectUri, Set<String> additionalScopes, GrantType grantType) Convert this provider to an OAuth2Config with custom settings 将此提供者转换为带有自定义设置的 OAuth2ConfigGet the token endpoint URL 获取令牌端点 URLtoString()Get the user info endpoint URL 获取用户信息端点 URLMethods inherited from interface OAuth2Provider
requiresPkce, supportsDeviceCode, toConfig, toConfig
-
Method Details
-
name
Description copied from interface:OAuth2ProviderGet the provider name 获取提供者名称- Specified by:
namein interfaceOAuth2Provider- Returns:
- the provider name | 提供者名称
-
authorizationEndpoint
Description copied from interface:OAuth2ProviderGet the authorization endpoint URL 获取授权端点 URL- Specified by:
authorizationEndpointin interfaceOAuth2Provider- Returns:
- the authorization endpoint | 授权端点
-
tokenEndpoint
Description copied from interface:OAuth2ProviderGet the token endpoint URL 获取令牌端点 URL- Specified by:
tokenEndpointin interfaceOAuth2Provider- Returns:
- the token endpoint | 令牌端点
-
userInfoEndpoint
Description copied from interface:OAuth2ProviderGet the user info endpoint URL 获取用户信息端点 URL- Specified by:
userInfoEndpointin interfaceOAuth2Provider- Returns:
- the user info endpoint, or null if not supported | 用户信息端点,不支持则返回 null
-
revocationEndpoint
Description copied from interface:OAuth2ProviderGet the revocation endpoint URL 获取撤销端点 URL- Specified by:
revocationEndpointin interfaceOAuth2Provider- Returns:
- the revocation endpoint, or null if not supported | 撤销端点,不支持则返回 null
-
deviceAuthorizationEndpoint
Description copied from interface:OAuth2ProviderGet the device authorization endpoint URL 获取设备授权端点 URL- Specified by:
deviceAuthorizationEndpointin interfaceOAuth2Provider- Returns:
- the device authorization endpoint, or null if not supported | 设备授权端点,不支持则返回 null
-
defaultScopes
Description copied from interface:OAuth2ProviderGet the default scopes for this provider 获取此提供者的默认权限范围- Specified by:
defaultScopesin interfaceOAuth2Provider- Returns:
- the default scopes | 默认权限范围
-
jwksUri
-
issuer
-
toConfig
public OAuth2Config toConfig(String clientId, String clientSecret, String redirectUri, Set<String> additionalScopes, GrantType grantType) Description copied from interface:OAuth2ProviderConvert this provider to an OAuth2Config with custom settings 将此提供者转换为带有自定义设置的 OAuth2Config- Specified by:
toConfigin interfaceOAuth2Provider- Parameters:
clientId- the client ID | 客户端 IDclientSecret- the client secret | 客户端密钥redirectUri- the redirect URI | 重定向 URIadditionalScopes- additional scopes | 额外权限范围grantType- the grant type | 授权类型- Returns:
- the OAuth2Config | OAuth2 配置
-
builder
Create a new builder 创建新的构建器- Returns:
- the builder | 构建器
-
from
Create a builder from an existing provider 从现有 Provider 创建构建器- Parameters:
provider- the provider to copy | 要复制的 Provider- Returns:
- the builder | 构建器
-
equals
-
hashCode
-
toString
-