Class OAuth2Scope

java.lang.Object
cloud.opencode.base.oauth2.OAuth2Scope

public final class OAuth2Scope extends Object
OAuth2 Scope OAuth2 权限范围

Represents OAuth2 scopes for authorization requests.

表示授权请求的 OAuth2 权限范围。

Features | 主要功能:

  • Predefined standard scopes - 预定义标准范围
  • Provider-specific scopes - 特定提供者范围
  • Scope combination utilities - 范围组合工具

Usage Examples | 使用示例:

// Use predefined scopes
Set<String> scopes = OAuth2Scope.combine(
    OAuth2Scope.OPENID,
    OAuth2Scope.EMAIL,
    OAuth2Scope.PROFILE
);

// Google Gmail scope
String gmailScope = OAuth2Scope.Google.GMAIL_READONLY;

// Microsoft Graph scope
String graphScope = OAuth2Scope.Microsoft.USER_READ;

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 Classes
    Modifier and Type
    Class
    Description
    static final class 
    GitHub-specific scopes GitHub 特定范围
    static final class 
    Google-specific scopes Google 特定范围
    static final class 
    Microsoft-specific scopes Microsoft 特定范围
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Address scope - access to address claim Address 范围 - 访问地址声明
    static final String
    Email scope - access to email and email_verified claims Email 范围 - 访问电子邮件和电子邮件验证声明
    static final String
    Offline access scope - request refresh token Offline access 范围 - 请求刷新令牌
    static final String
    OpenID scope - required for OIDC OpenID 范围 - OIDC 必需
    static final String
    Phone scope - access to phone_number and phone_number_verified claims Phone 范围 - 访问电话号码和电话号码验证声明
    static final String
    Profile scope - access to user profile claims Profile 范围 - 访问用户资料声明
  • Method Summary

    Modifier and Type
    Method
    Description
    static Set<String>
    combine(String... scopes)
    Combine multiple scopes into a set 将多个范围组合成一个集合
    static Set<String>
    combine(Set<String>... scopeSets)
    Combine scope sets 组合范围集合
    static Set<String>
    Get default OIDC scopes 获取默认 OIDC 范围
    static Set<String>
    parse(String scopeString)
    Parse space-separated scope string to set 将空格分隔的范围字符串解析为集合
    static String
    toString(String... scopes)
    Convert scopes to space-separated string 将范围转换为空格分隔的字符串
    static String
    toString(Set<String> scopes)
    Convert scopes to space-separated string 将范围转换为空格分隔的字符串

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • OPENID

      public static final String OPENID
      OpenID scope - required for OIDC OpenID 范围 - OIDC 必需
      See Also:
    • PROFILE

      public static final String PROFILE
      Profile scope - access to user profile claims Profile 范围 - 访问用户资料声明
      See Also:
    • EMAIL

      public static final String EMAIL
      Email scope - access to email and email_verified claims Email 范围 - 访问电子邮件和电子邮件验证声明
      See Also:
    • ADDRESS

      public static final String ADDRESS
      Address scope - access to address claim Address 范围 - 访问地址声明
      See Also:
    • PHONE

      public static final String PHONE
      Phone scope - access to phone_number and phone_number_verified claims Phone 范围 - 访问电话号码和电话号码验证声明
      See Also:
    • OFFLINE_ACCESS

      public static final String OFFLINE_ACCESS
      Offline access scope - request refresh token Offline access 范围 - 请求刷新令牌
      See Also:
  • Method Details

    • combine

      public static Set<String> combine(String... scopes)
      Combine multiple scopes into a set 将多个范围组合成一个集合
      Parameters:
      scopes - the scopes to combine | 要组合的范围
      Returns:
      the combined scope set | 组合的范围集合
    • combine

      @SafeVarargs public static Set<String> combine(Set<String>... scopeSets)
      Combine scope sets 组合范围集合
      Parameters:
      scopeSets - the scope sets to combine | 要组合的范围集合
      Returns:
      the combined scope set | 组合的范围集合
    • toString

      public static String toString(Set<String> scopes)
      Convert scopes to space-separated string 将范围转换为空格分隔的字符串
      Parameters:
      scopes - the scopes | 范围
      Returns:
      the space-separated string | 空格分隔的字符串
    • toString

      public static String toString(String... scopes)
      Convert scopes to space-separated string 将范围转换为空格分隔的字符串
      Parameters:
      scopes - the scopes | 范围
      Returns:
      the space-separated string | 空格分隔的字符串
    • parse

      public static Set<String> parse(String scopeString)
      Parse space-separated scope string to set 将空格分隔的范围字符串解析为集合
      Parameters:
      scopeString - the scope string | 范围字符串
      Returns:
      the scope set | 范围集合
    • defaultOidc

      public static Set<String> defaultOidc()
      Get default OIDC scopes 获取默认 OIDC 范围
      Returns:
      the default OIDC scopes | 默认 OIDC 范围