appauth4cj库
介绍
appauth4cj专注于实现OAuth 2.0和OpenID Connect协议, 为移动应用、桌面应用及Web应用提供安全、标准化的身份认证与授权解决方案。
- 协议实现与标准化支持
- 安全增强与最佳实践
- 令牌管理与生命周期控制
- 跨平台与多场景适配
- 开发效率与灵活性优化
appauth4cj
场景:授权代码,动态客户端注册,通过高级配置控制用于授权的浏览器
1. AuthorizationRequest
1.1 主要接口
public class AuthorizationRequest <: AuthorizationManagementRequest{
/*
* 获取作用域
*
* 返回值 - Set<String>
*/
public func getScopeSet(): Set<String>
/*
* 获取提示值
*
* 返回值 - Set<String>
*/
public func getPromptValues(): Set<String>
/*
* 获取ui设置值
*
* 返回值 - Set<String>
*/
public func getUiLocales(): Set<String>
/*
* 获取状态
*
* 返回值 - String
*/
public func getState(): String
/*
* 获取语言环境
*
* 返回值 - Set<String>
*/
public func getClaimsLocales(): Set<String>
/*
* 为持久存储或本地传输生成授权请求JSON
*
* 返回值 - JsonObject
*/
public override func jsonSerialize(): JsonObject
/*
* 为持久存储或本地传输生成授权请求JSON,将json转换成字符串
*
* 返回值 - String
*/
public override func jsonSerializeString(): String
/*
* 从JSON字符串中读取授权请求,如果提供的JSON与预期结构不匹配,则报错
*
* 参数 - json 包含授权请求的json对象
*
* 返回值 - AuthorizationRequest
*/
public static func jsonDeserialize(json: JsonObject): AuthorizationRequest
/*
* JSON字符串转换为JSON对象形式,在执行jsonDeserialize(json: JsonObject)方法
*
* 参数 - jsonStr 包含授权请求的json字符串
*
* 返回值 - AuthorizationRequest
*/
public static func jsonDeserialize(jsonStr: String): AuthorizationRequest
}
public class AuthorizationRequest_Builder {
/*
* 创建授权请求生成器
*
* 参数 - configuration 配置项
* 参数 - clientId 客户端ID
* 参数 - responseType 响应类型
* 参数 - redirectUri 重定向Uri
*/
public init(
configuration: AuthorizationServiceConfiguration,
clientId: String,
responseType: String,
redirectUri: Uri
)
/*
* 设置授权请求生成器配置
*
* 参数 - configuration 授权请求生成器配置
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setAuthorizationServiceConfiguration(configuration: AuthorizationServiceConfiguration): AuthorizationRequest_Builder
/*
* 设置授权请求生成器客户端ID
*
* 参数 - clientId 客户端ID
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setClientId(clientId: String): AuthorizationRequest_Builder
/*
* 设置显示
*
* 参数 - display 显示
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setDisplay(display: String): AuthorizationRequest_Builder
/*
* 设置登录提示
*
* 参数 - loginHint 登录提示
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setLoginHint(loginHint: String): AuthorizationRequest_Builder
/*
* 设置提示
*
* 参数 - prompt 提示
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setPrompt(prompt: String): AuthorizationRequest_Builder
/*
* 设置提示值
*
* 参数 - promptValues 提示值
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setPromptValues(promptValues: String): AuthorizationRequest_Builder
/*
* 设置Ui本地语言
*
* 参数 - uiLocales Ui本地语言
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setUiLocales(uiLocales: String): AuthorizationRequest_Builder
/*
* 设置Ui本地语言值
*
* 参数 - promptValues Ui本地语言值集合
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setUiLocalesValues(promptValues: Array<String>): AuthorizationRequest_Builder
/*
* 设置响应类型
*
* 参数 - responseType 响应类型
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setResponseType(responseType: String): AuthorizationRequest_Builder
/*
* 设置重定向Uri
*
* 参数 - redirectUri 重定向Uri
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setRedirectUri(redirectUri: Uri): AuthorizationRequest_Builder
/*
* 设置范围
*
* 参数 - scope 范围
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setScope(scope: String): AuthorizationRequest_Builder
/*
* 设置范围值集合
*
* 参数 - scopes 范围值集合
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setScopes(scopes: Array<String>): AuthorizationRequest_Builder
/*
* 设置状态
*
* 参数 - state 状态
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setState(state: String): AuthorizationRequest_Builder
/*
* 设置一次性令牌
*
* 参数 - nonce 一次性令牌
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setNonce(nonce: String): AuthorizationRequest_Builder
/*
* 设置代码验证器
*
* 参数 - codeVerifier 代码验证器
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setCodeVerifier(codeVerifier: String): AuthorizationRequest_Builder
/*
* 设置代码验证器
*
* 参数 - codeVerifier 代码验证器
* 参数 - codeVerifierChallenge 代码验证器验证
* 参数 - codeVerifierChallengeMethod 代码验证器验证方法
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setCodeVerifier(codeVerifier: String, codeVerifierChallenge: String, codeVerifierChallengeMethod: String): AuthorizationRequest_Builder
/*
* 设置响应模式
*
* 参数 - responseMode 响应模式
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setResponseMode(responseMode: String): AuthorizationRequest_Builder
/*
* 设置claims
*
* 参数 - claims JSON对象
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setClaims(claims: JsonObject): AuthorizationRequest_Builder
/*
* 设置本地claims
*
* 参数 - claims 本地claims集合
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setClaimsLocales(claimsLocalesValues: Array<String>): AuthorizationRequest_Builder
/*
* 设置其他参数
*
* 参数 - additionalParameters 其他参数
*
* 返回值 - AuthorizationRequest_Builder
*/
public func setAdditionalParameters(additionalParameters: HashMap<String, String>): AuthorizationRequest_Builder
/*
* 返回 授权请求器
*
* 返回值 - AuthorizationRequest
*/
public func build(): AuthorizationRequest
}
2. AuthorizationResponse
2.1 主要接口
public class AuthorizationResponse <: AuthorizationManagementResponse {
/*
* 获取范围
*
* 返回值 - Set<String>
*/
public func getScopeSet(): Set<String>
/*
* 创建令牌交换请求
*
* 返回值 - TokenRequest
*/
public func createTokenExchangeRequest(): TokenRequest
/*
* 创建令牌交换请求
*
* 参数 - additionalExchangeParameters 其他交换参数
*
* 返回值 - TokenRequest
*/
public func createTokenExchangeRequest(additionalExchangeParameters: Map<String, String>): TokenRequest
/*
* 获取状态
*
* 返回值 - String
*/
public override func getState(): String
/*
* 返回为持久存储或本地传输授权请求的JSON字符串
*
* 返回值 - String
*/
public override func jsonSerializeString(): String
/*
* 返回为持久存储或本地传输授权请求的JSON
*
* 返回值 - JsonObject
*/
public override func jsonSerialize(): JsonObject
/*
* 从由生成的JSON中读取授权响应
*
* 参数 - json 授权响应的JSON对象
*
* 返回值 - AuthorizationResponse
*/
public static func jsonDeserialize(json: JsonObject): AuthorizationResponse
/*
* 从由生成的JSON字符串中读取授权响应
*
* 参数 - jsonStr 授权响应的JSON字符串
*
* 返回值 - AuthorizationResponse
*/
public static func jsonDeserialize(jsonStr: String): AuthorizationResponse
}
public class AuthorizationResponse_Builder {
/*
* 授权响应生成器初始化器
*
* 参数 - request 授权响应
*/
public init(request: AuthorizationRequest)
/*
* 从uri中读取数据生成授权响应
*
* 参数 - uri uri
*
* 返回值 - AuthorizationResponse_Builder
*/
public func fromUri(uri: Uri): AuthorizationResponse_Builder
/*
* 设置状态
*
* 参数 - state 状态
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setState(state: String): AuthorizationResponse_Builder
/*
* 设置令牌类型
*
* 参数 - tokenType 令牌类型
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setTokenType(tokenType: String): AuthorizationResponse_Builder
/*
* 设置授权码
*
* 参数 - authorizationCode 授权码
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setAuthorizationCode(authorizationCode: String): AuthorizationResponse_Builder
/*
* 设置访问令牌
*
* 参数 - accessToken 访问令牌
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setAccessToken(accessToken: String): AuthorizationResponse_Builder
/*
* 设置访问令牌有效期
*
* 参数 - expirationTime 访问令牌有效期
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setAccessTokenExpiresIn(expirationTime: Int64): AuthorizationResponse_Builder
/*
* 设置访问令牌过期时间
*
* 参数 - expirationTime 访问令牌过期时间
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setAccessTokenExpirationTime(expirationTime: Int64): AuthorizationResponse_Builder
/*
* 设置Id令牌
*
* 参数 - idToken Id令牌
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setIdToken(idToken: String): AuthorizationResponse_Builder
/*
* 设置范围
*
* 参数 - scope 范围值
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setScope(scope: String): AuthorizationResponse_Builder
/*
* 设置范围集合
*
* 参数 - scopes 范围值集合
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setScopes(scopes: Array<String>): AuthorizationResponse_Builder
/*
* 设置其他参数
*
* 参数 - additionalParameters 其他参数
*
* 返回值 - AuthorizationResponse_Builder
*/
public func setAdditionalParameters(additionalParameters: Map<String, String>): AuthorizationResponse_Builder
/*
* AuthorizationResponse构造器
*
*/
public func build()
}
3. AppAuthConfiguration
3.1 AppAuthConfiguration
public class AppAuthConfiguration {
/*
* 创建AppAuthConfiguration
*
* 参数 - browserMatcher
* 参数 - connectionBuilder
* 参数 - skipIssuerHttpsCheck
*
* 返回值 - AppAuthConfiguration
*/
public static func build(browserMatcher!: String, connectionBuilder!: ConnectionBuilder, skipIssuerHttpsCheck!: Bool): AppAuthConfiguration
/*
* 获取mBrowserMatcher
*
* 返回值 - Unit
*/
public func getBrowserMatcher()
/*
* 获取mConnectionBuilder
*
* 返回值 - ConnectionBuilder
*/
public func getConnectionBuilder(): ConnectionBuilder
/*
* 获取mSkipIssuerHttpsCheck
*
* 返回值 - Bool
*/
public func getSkipIssuerHttpsCheck(): Bool
}
4. 令牌请求与响应
4.1 TokenRequest
public class TokenRequest {
/*
* 获取作用域集合
*
* 返回值: Set<String> 作用域集合
*/
public func getScopeSet(): Set<String>
/*
* 获取请求参数
*
* 返回值: Map<String, String> 请求参数
*/
public func getRequestParameters(): Map<String, String>
/*
* JSON序列化
*
* 返回值: JsonObject JSON对象
*/
public func jsonSerialize(): JsonObject
/*
* JSON序列化为字符串
*
* 返回值: String JSON字符串
*/
public func jsonSerializeString(): String
/*
* 从JSON反序列化
*
* 参数:
* json - JsonObject JSON对象
*
* 返回值: TokenRequest 令牌请求
*/
public static func jsonDeserialize(json: JsonObject): TokenRequest
/*
* 从JSON反序列化
*
* 参数:
* json - String JSON字符串
*
* 返回值: TokenRequest 令牌请求
*/
public static func jsonDeserialize(json: String): TokenRequest
}
4.2 TokenResponse
public class TokenResponse {
/*
* 获取作用域集合
*
* 返回值: Set<String> 作用域集合
*/
public func getScopeSet(): Set<String>
/*
* JSON序列化
*
* 返回值: JsonObject JSON对象
*/
public func jsonSerialize(): JsonObject
/*
* JSON序列化为字符串
*
* 返回值: String JSON字符串
*/
public func jsonSerializeString(): String
/*
* 从JSON反序列化
*
* 参数:
* json - JsonObject JSON对象
*
* 返回值: TokenResponse 令牌响应
*/
public static func jsonDeserialize(json: JsonObject): TokenResponse
/*
* 从JSON字符串反序列化
*
* 参数:
* jsonStr - String JSON字符串
*
* 返回值: TokenResponse 令牌响应
*/
public static func jsonDeserialize(jsonStr: String): TokenResponse
}
5. 认证服务
5.1 AuthState
public class AuthState {
/*
* 使用配置初始化
*
* 参数:
* config - AuthorizationServiceConfiguration 授权服务配置
*/
public init(config: AuthorizationServiceConfiguration)
/*
* 使用授权响应或错误初始化
*
* 参数:
* authResponse - AuthorizationResponse? 授权响应
* authError - AuthorizationException? 授权错误
*/
public init(authResponse: ?AuthorizationResponse, authError: ?AuthorizationException)
/*
* 使用注册响应初始化
*
* 参数:
* regResponse - RegistrationResponse? 注册响应
*/
public init(regResponse: ?RegistrationResponse)
/*
* 使用授权响应、令牌响应或授权异常初始化
*
* 参数:
* authResponse - AuthorizationResponse? 授权响应
* tokenResponse - TokenResponse? 令牌响应
* authException - AuthorizationException? 授权异常
*/
public init(authResponse: ?AuthorizationResponse, tokenResponse: ?TokenResponse, authException: ?AuthorizationException)
/*
* 获取刷新令牌
*
* 返回值: String 刷新令牌
*/
public func getRefreshToken(): String
/*
* 获取作用域
*
* 返回值: String 作用域
*/
public func getScope(): String
/*
* 获取作用域集合
*
* 返回值: Set<String> 作用域集合
*/
public func getScopeSet(): Set<String>
/*
* 获取最后的授权响应
*
* 返回值: Option<AuthorizationResponse> 最后的授权响应
*/
public func getLastAuthorizationResponse(): Option<AuthorizationResponse>
/*
* 获取最后的令牌响应
*
* 返回值: Option<TokenResponse> 最后的令牌响应
*/
public func getLastTokenResponse(): Option<TokenResponse>
/*
* 获取最后的注册响应
*
* 返回值: Option<RegistrationResponse> 最后的注册响应
*/
public func getLastRegistrationResponse(): Option<RegistrationResponse>
/*
* 获取授权服务配置
*
* 返回值: AuthorizationServiceConfiguration 授权服务配置
*/
public func getAuthorizationServiceConfiguration(): AuthorizationServiceConfiguration
/*
* 获取访问令牌
*
* 返回值: String 访问令牌
*/
public func getAccessToken(): String
/*
* 获取访问令牌过期时间
*
* 返回值: Int64 访问令牌过期时间
*/
public func getAccessTokenExpirationTime(): Int64
/*
* 获取ID令牌
*
* 返回值: String ID令牌
*/
public func getIdToken(): String
/*
* 获取解析后的ID令牌
*
* 返回值: Option<IdToken> 解析后的ID令牌
*/
public func getParsedIdToken(): Option<IdToken>
/*
* 获取客户端密钥
*
* 返回值: String 客户端密钥
*/
public func getClientSecret(): String
/*
* 获取客户端密钥过期时间
*
* 返回值: Int64 客户端密钥过期时间
*/
public func getClientSecretExpirationTime(): Int64
/*
* 检查是否已授权
*
* 返回值: Bool 是否已授权
*/
public func isAuthorized(): Bool
/*
* 获取授权异常
*
* 返回值: Option<AuthorizationException> 授权异常
*/
public func getAuthorizationException(): Option<AuthorizationException>
/*
* 检查是否需要刷新令牌
*
* 返回值: Bool 是否需要刷新令牌
*/
public func getNeedsTokenRefresh(): Bool
/*
* 设置是否需要刷新令牌
*
* 参数:
* needsTokenRefresh - Bool 是否需要刷新令牌
*/
public func setNeedsTokenRefresh(needsTokenRefresh: Bool): Unit
/*
* 检查客户端密钥是否已过期
*
* 返回值: Bool 客户端密钥是否已过期
*/
public func hasClientSecretExpired(): Bool
/*
* 更新授权响应或错误
*
* 参数:
* authResponse - AuthorizationResponse? 授权响应
* authError - AuthorizationException? 授权错误
*/
public func update(authResponse: ?AuthorizationResponse, authError: ?AuthorizationException): Unit
/*
* 更新令牌响应或错误
*
* 参数:
* tokenResponse - TokenResponse? 令牌响应
* authError - AuthorizationException? 授权错误
*/
public func update(tokenResponse: ?TokenResponse, authError: ?AuthorizationException): Unit
/*
* 更新注册响应
*
* 参数:
* regResponse - RegistrationResponse? 注册响应
*/
public func update(regResponse: ?RegistrationResponse): Unit
/*
* 使用新令牌执行操作
*
* 参数:
* service - AuthorizationService? 授权服务
* action - AuthStateAction? 授权状态操作
*/
public func performActionWithFreshTokens(service: ?AuthorizationService, action: ?AuthStateAction): Unit
/*
* 使用新令牌执行操作
*
* 参数:
* service - AuthorizationService? 授权服务
* clientAuth - ClientAuthentication? 客户端认证
* action - AuthStateAction? 授权状态操作
*/
public func performActionWithFreshTokens(service: ?AuthorizationService, clientAuth: ?ClientAuthentication, action: ?AuthStateAction): Unit
/*
* 使用新令牌执行操作
*
* 参数:
* service - AuthorizationService? 授权服务
* refreshTokenAdditionalParams - Map<String, String> 刷新令牌附加参数
* action - AuthStateAction? 授权状态操作
*/
public func performActionWithFreshTokens(service: ?AuthorizationService, refreshTokenAdditionalParams: Map<String, String>, action: ?AuthStateAction): Unit
/*
* 使用新令牌执行操作
*
* 参数:
* service - AuthorizationService? 授权服务
* clientAuth - ClientAuthentication? 客户端认证
* refreshTokenAdditionalParams - Map<String, String> 刷新令牌附加参数
* action - AuthStateAction? 授权状态操作
*/
public func performActionWithFreshTokens(service: ?AuthorizationService, clientAuth: ?ClientAuthentication, refreshTokenAdditionalParams: Map<String, String>, action: ?AuthStateAction): Unit
/*
* 创建令牌刷新请求
*
* 返回值: TokenRequest 令牌刷新请求
*/
public func createTokenRefreshRequest(): TokenRequest
/*
* 创建令牌刷新请求
*
* 参数:
* additionalParameters - Map<String, String> 附加参数
*
* 返回值: TokenRequest 令牌刷新请求
*/
public func createTokenRefreshRequest(additionalParameters: Map<String, String>): TokenRequest
/*
* JSON序列化
*
* 返回值: JsonObject JSON对象
*/
public func jsonSerialize(): JsonObject
/*
* JSON序列化为字符串
*
* 返回值: String JSON字符串
*/
public func jsonSerializeString(): String
/*
* 从JSON反序列化
*
* 参数:
* json - JsonObject JSON对象
*
* 返回值: AuthState 授权状态
*/
public static func jsonDeserialize(json: JsonObject): AuthState
/*
* 从JSON字符串反序列化
*
* 参数:
* jsonStr - String JSON字符串
*
* 返回值: AuthState 授权状态
*/
public static func jsonDeserialize(jsonStr: String): AuthState
/*
* 获取客户端认证
*
* 返回值: ClientAuthentication 客户端认证
*/
public func getClientAuthentication(): ClientAuthentication
}
6. 注册请求与响应
6.1 ConnectionBuilder
public interface ConnectionBuilder {
func openConnection(): Unit
}
6.2 DefaultConnectionBuilder
public class DefaultConnectionBuilder <: ConnectionBuilder {
}
6.3 RegistrationRequest
public class RegistrationRequest {
/*
* 转换为JSON字符串
*
* 返回值: String JSON字符串
*/
public func toJsonString(): String
/*
* JSON序列化
*
* 返回值: JsonObject JSON对象
*/
public func jsonSerialize(): JsonObject
/*
* JSON序列化为字符串
*
* 返回值: String JSON字符串
*/
public func jsonSerializeString(): String
/*
* JSON序列化参数
*
* 返回值: JsonObject JSON对象
*/
public func jsonSerializeParams(): JsonObject
/*
* 从JSON反序列化
*
* 参数:
* json - JsonObject JSON对象
*/
public static func jsonDeserialize(json: JsonObject)
/*
* 从JSON字符串反序列化
*
* 参数:
* jsonStr - String JSON字符串
*/
public static func jsonDeserialize(jsonStr: String)
}
6.4 RegistrationResponse
public class RegistrationResponse {
/*
* 从JSON反序列化
*
* 参数:
* request - RegistrationRequest 注册请求
* jsonStr - String JSON字符串
*
* 返回值: RegistrationResponse 注册响应
*/
public static func fromJson(request: RegistrationRequest, jsonStr: String): RegistrationResponse
/*
* 从JSON反序列化
*
* 参数:
* request - RegistrationRequest 注册请求
* json - JsonObject JSON对象
*
* 返回值: RegistrationResponse 注册响应
*/
public static func fromJson(request: RegistrationRequest, json: JsonObject): RegistrationResponse
/*
* JSON序列化
*
* 返回值: JsonObject JSON对象
*/
public func jsonSerialize(): JsonObject
/*
* JSON序列化为字符串
*
* 返回值: String JSON字符串
*/
public func jsonSerializeString(): String
/*
* 从JSON反序列化
*
* 参数:
* json - JsonObject JSON对象
*
* 返回值: RegistrationResponse 注册响应
*/
public static func jsonDeserialize(json: JsonObject): RegistrationResponse
/*
* 从JSON字符串反序列化
*
* 参数:
* jsonStr - String JSON字符串
*
* 返回值: RegistrationResponse 注册响应
*/
public static func jsonDeserialize(jsonStr: String): RegistrationResponse
/*
* 检查客户端密钥是否已过期
*
* 返回值: Bool 客户端密钥是否已过期
*/
public func hasClientSecretExpired(): Bool
}
7. 认证接口实现和IDToken处理
7.1 ClientAuthentication
public interface ClientAuthentication {
/*
* 获取请求头
*
* 参数:
* clientId - String 客户端ID
*
* 返回值: Map<String, String> 请求头
*/
getRequestHeaders(clientId: String): Map<String, String>
/*
* 获取请求参数
*
* 参数:
* clientId - String 客户端ID
*
* 返回值: Map<String, String> 请求参数
*/
getRequestParameters(clientId: String): Map<String, String>
}
7.2 ClientSecretBasic
public class ClientSecretBasic <: ClientAuthentication {
/*
* 使用客户端密钥初始化
*
* 参数:
* clientSecret - String 客户端密钥
*/
public init(clientSecret: String)
/*
* 获取请求参数
*
* 参数:
* clientId - String 客户端ID
*
* 返回值: Map<String, String> 请求参数
*/
public override func getRequestParameters(clientId: String): Map<String, String>
/*
* 获取请求头
*
* 参数:
* clientId - String 客户端ID
*
* 返回值: Map<String, String> 请求头
*/
public override func getRequestHeaders(clientId: String): Map<String, String>
}
7.3 ClientSecretPost
public class ClientSecretPost <: ClientAuthentication {
/*
* 使用客户端密钥初始化
*
* 参数:
* clientSecret - String 客户端密钥
*/
public init(clientSecret: String)
/*
* 获取请求参数
*
* 参数:
* clientId - String 客户端ID
*
* 返回值: Map<String, String> 请求参数
*/
public override func getRequestParameters(clientId: String): Map<String, String>
/*
* 获取请求头
*
* 参数:
* clientId - String 客户端ID
*
* 返回值: Map<String, String> 请求头
*/
public override func getRequestHeaders(clientId: String): Map<String, String>
}
7.4 NoClientAuthentication
public class NoClientAuthentication <: ClientAuthentication {
/*
* 获取请求头
*
* 参数:
* clientId - String 客户端ID
*
* 返回值: Map<String, String> 请求头
*/
public override func getRequestHeaders(clientId: String): Map<String, String>
/*
* 获取请求参数
*
* 参数:
* clientId - String 客户端ID
*
* 返回值: Map<String, String> 请求参数
*/
public override func getRequestParameters(clientId: String): Map<String, String>
}
8. 会话结束请求与响应
8.1 EndSessionRequest
public class EndSessionRequest <: AuthorizationManagementRequest {
/*
* 创建结束会话请求
*
* 参数 - configuration 授权服务配置
* 参数 - idTokenHint ID令牌提示
* 参数 - postLogoutRedirectUri 登出后重定向Uri
* 参数 - state 状态
* 参数 - uiLocales UI语言环境
* 参数 - additionalParameters 附加参数
*/
public init(configuration: AuthorizationServiceConfiguration, idTokenHint: String, postLogoutRedirectUri: ?AuthUri, state: String, uiLocales: String, additionalParameters: Map<String, String>)
/*
* 获取状态值
*
* 返回值 - String
*/
public override func getState(): String
/*
* 获取登出后的重定向Uri
*
* 返回值 - ?AuthUri
*/
public func gePostLogoutRedirectUri(): ?AuthUri
/*
* 获取ID Token提示
*
* 返回值 - ?String
*/
public func getIdTokenHint(): ?String
/*
* 获取UI语言环境集合
*
* 返回值 - Set<String>
*/
public func getUiLocales(): Set<String>
/*
* 获取额外参数
*
* 返回值 - Map<String, String>
*/
public func geAdditionalParameters(): Map<String, String>
/*
* 构建结束会话请求的Uri
*
* 返回值 - AuthUri
*/
public func toUri(): AuthUri
/*
* 序列化为JSON对象
*
* 返回值 - JsonObject
*/
public func jsonSerialize(): JsonObject
/*
* 序列化为JSON字符串
*
* 返回值 - String
*/
public func jsonSerializeString(): String
/*
* 从JSON对象反序列化为EndSessionRequest对象
*
* 参数 - json JSON对象
*
* 返回值 - EndSessionRequest
*/
public static func jsonDeserialize(json: JsonObject): EndSessionRequest
/*
* 从JSON字符串反序列化为EndSessionRequest对象
*
* 参数 - jsonStr JSON字符串
*
* 返回值 - EndSessionRequest
*/
public static func jsonDeserialize(jsonStr: String): EndSessionRequest
}
public class EndSessionRequest_Builder {
/*
* 创建结束会话请求构建器
*
* 参数 - configuration 授权服务配置
*/
public init(configuration: AuthorizationServiceConfiguration)
/*
* 设置ID Token提示
*
* 参数 - idTokenHint ID Token提示
*
* 返回值 - EndSessionRequest_Builder
*/
public func setIdTokenHint(idTokenHint: String): EndSessionRequest_Builder
/*
* 设置登出后重定向Uri
*
* 参数 - postLogoutRedirectUri 登出后重定向Uri
*
* 返回值 - EndSessionRequest_Builder
*/
public func setPostLogoutRedirectUri(postLogoutRedirectUri: AuthUri): EndSessionRequest_Builder
/*
* 设置状态
*
* 参数 - state 状态
*
* 返回值 - EndSessionRequest_Builder
*/
public func setState(state: String): EndSessionRequest_Builder
/*
* 设置UI语言环境
*
* 参数 - uiLocales UI语言环境
*
* 返回值 - EndSessionRequest_Builder
*/
public func setUiLocales(uiLocales: String): EndSessionRequest_Builder
/*
* 设置UI语言环境值集合
*
* 参数 - uiLocalesValues UI语言环境值集合
*
* 返回值 - EndSessionRequest_Builder
*/
public func setUiLocalesValues(uiLocalesValues: Array<String>): EndSessionRequest_Builder
/*
* 设置额外参数
*
* 参数 - additionalParameters 额外参数
*
* 返回值 - EndSessionRequest_Builder
*/
public func setAdditionalParameters(additionalParameters: Map<String, String>): EndSessionRequest_Builder
/*
* 构建EndSessionRequest对象
*
* 返回值 - EndSessionRequest
*/
public func build(): EndSessionRequest
}
8.2 EndSessionResponse
public class EndSessionResponse <: AuthorizationManagementResponse {
/*
* 创建结束会话响应
*
* 参数 - request 结束会话请求
* 参数 - state 状态
*/
public init(request: EndSessionRequest, state: String)
/*
* 获取状态
*
* 返回值 - String
*/
public func getState(): String
/*
* 序列化为JSON对象
*
* 返回值 - JsonObject
*/
public func jsonSerialize(): JsonObject
/*
* 从JSON对象反序列化为EndSessionResponse对象
*
* 参数 - json JSON对象
*
* 返回值 - EndSessionResponse
*/
public static func jsonDeserialize(json: JsonObject): EndSessionResponse
/*
* 从JSON字符串反序列化为EndSessionResponse对象
*
* 参数 - jsonStr JSON字符串
*
* 返回值 - EndSessionResponse
*/
public static func jsonDeserialize(jsonStr: String): EndSessionResponse
}
public class EndSessionResponse_Builder {
/*
* 创建结束会话响应构建器
*
* 参数 - request 结束会话请求
*/
public init(request: EndSessionRequest)
/*
* 从Uri创建结束会话响应构建器
*
* 参数 - uri 授权Uri
*
* 返回值 - EndSessionResponse_Builder
*/
public func fromUri(uri: AuthUri): EndSessionResponse_Builder
/*
* 设置状态
*
* 参数 - state 状态
*
* 返回值 - EndSessionResponse_Builder
*/
public func setState(state: String): EndSessionResponse_Builder
/*
* 构建EndSessionResponse对象
*
* 返回值 - EndSessionResponse
*/
public func build()
}
8.3 AuthorizationServiceConfiguration
public class AuthorizationServiceConfiguration {
/*
* 使用授权端点和令牌端点初始化
*
* 参数:
* authorizationEndpoint - AuthUri 授权端点
* tokenEndpoint - AuthUri 令牌端点
*/
public init(authorizationEndpoint: AuthUri, tokenEndpoint: AuthUri)
/*
* 使用授权端点、令牌端点和注册端点初始化
*
* 参数:
* authorizationEndpoint - AuthUri 授权端点
* tokenEndpoint - AuthUri 令牌端点
* registrationEndpoint - ?AuthUri 注册端点
*/
public init(authorizationEndpoint: AuthUri, tokenEndpoint: AuthUri, registrationEndpoint: ?AuthUri)
/*
* 使用授权端点、令牌端点、注册端点和结束会话端点初始化
*
* 参数:
* authorizationEndpoint - AuthUri 授权端点
* tokenEndpoint - AuthUri 令牌端点
* registrationEndpoint - ?AuthUri 注册端点
* endSessionEndpoint - ?AuthUri 结束会话端点
*/
public init(authorizationEndpoint: AuthUri, tokenEndpoint: AuthUri, registrationEndpoint: ?AuthUri, endSessionEndpoint: ?AuthUri)
/*
* 使用发现文档初始化
*
* 参数:
* discoveryDoc - AuthorizationServiceDiscovery 发现文档
*/
public init(discoveryDoc: AuthorizationServiceDiscovery)
/*
* 转换为JSON
*
* 返回值: JsonObject JSON对象
*/
public func toJson(): JsonObject
/*
* 转换为JSON字符串
*
* 返回值: String JSON字符串
*/
public func toJsonString(): String
/*
* 从JSON反序列化
*
* 参数:
* json - JsonObject JSON对象
*
* 返回值: AuthorizationServiceConfiguration 授权服务配置
*/
public static func fromJson(json: JsonObject): AuthorizationServiceConfiguration
/*
* 从JSON字符串反序列化
*
* 参数:
* jsonStr - String JSON字符串
*
* 返回值: AuthorizationServiceConfiguration 授权服务配置
*/
public static func fromJson(jsonStr: String): AuthorizationServiceConfiguration
}
8.4 AuthorizationServiceDiscovery
public class AuthorizationServiceDiscovery {
/*
* 通过发现文档初始化
*
* 参数:
* discoveryDoc - JSONObject 发现文档
*
* 异常:
* JSONException - JSON解析异常
* MissingArgumentException - 缺少必要字段异常
*/
public init(discoveryDoc: JsonObject)
/*
* 获取发行方
*
* 返回值: String 发行方
*/
public func getIssuer(): String
/*
* 获取授权端点
*
* 返回值: AuthUri 授权端点
*/
public func getAuthorizationEndpoint(): AuthUri
/*
* 获取令牌端点
*
* 返回值: AuthUri 令牌端点
*/
public func getTokenEndpoint(): AuthUri
/*
* 获取结束会话端点
*
* 返回值: AuthUri 结束会话端点
*/
public func getEndSessionEndpoint(): AuthUri
/*
* 获取用户信息端点
*
* 返回值: AuthUri 用户信息端点
*/
public func getUserinfoEndpoint(): AuthUri
/*
* 获取JWKS URI
*
* 返回值: AuthUri JWKS URI
*/
public func getJwksUri(): AuthUri
/*
* 获取注册端点
*
* 返回值: AuthUri 注册端点
*/
public func getRegistrationEndpoint(): AuthUri
/*
* 获取支持的作用域
*
* 返回值: Array<String> 支持的作用域
*/
public func getScopesSupported(): Array<String>
/*
* 获取支持的响应类型
*
* 返回值: Array<String> 支持的响应类型
*/
public func getResponseTypesSupported(): Array<String>
/*
* 获取支持的响应模式
*
* 返回值: Array<String> 支持的响应模式
*/
public func getResponseModesSupported(): Array<String>
/*
* 获取支持的授权类型
*
* 返回值: Array<String> 支持的授权类型
*/
public func getGrantTypesSupported(): Array<String>
/*
* 获取支持的ACR值
*
* 返回值: Array<String> 支持的ACR值
*/
public func getAcrValuesSupported(): Array<String>
/*
* 获取支持的主题类型
*
* 返回值: Array<String> 支持的主题类型
*/
public func getSubjectTypesSupported(): Array<String>
/*
* 获取支持的ID令牌签名算法值
*
* 返回值: Array<String> 支持的ID令牌签名算法值
*/
public func getIdTokenSigningAlgorithmValuesSupported(): Array<String>
/*
* 获取支持的ID令牌加密算法值
*
* 返回值: Array<String> 支持的ID令牌加密算法值
*/
public func getIdTokenEncryptionAlgorithmValuesSupported(): Array<String>
/*
* 获取支持的ID令牌加密编码值
*
* 返回值: Array<String> 支持的ID令牌加密编码值
*/
public func getIdTokenEncryptionEncodingValuesSupported(): Array<String>
/*
* 获取支持的用户信息签名算法值
*
* 返回值: Array<String> 支持的用户信息签名算法值
*/
public func getUserinfoSigningAlgorithmValuesSupported(): Array<String>
/*
* 获取支持的用户信息加密算法值
*
* 返回值: Array<String> 支持的用户信息加密算法值
*/
public func getUserinfoEncryptionAlgorithmValuesSupported(): Array<String>
/*
* 获取支持的用户信息加密编码值
*
* 返回值: Array<String> 支持的用户信息加密编码值
*/
public func getUserinfoEncryptionEncodingValuesSupported(): Array<String>
/*
* 获取支持的请求对象签名算法值
*
* 返回值: Array<String> 支持的请求对象签名算法值
*/
public func getRequestObjectSigningAlgorithmValuesSupported(): Array<String>
/*
* 获取支持的请求对象加密算法值
*
* 返回值: Array<String> 支持的请求对象加密算法值
*/
public func getRequestObjectEncryptionAlgorithmValuesSupported(): Array<String>
/*
* 获取支持的请求对象加密编码值
*
* 返回值: Array<String> 支持的请求对象加密编码值
*/
public func getRequestObjectEncryptionEncodingValuesSupported(): Array<String>
/*
* 获取支持的令牌端点认证方法
*
* 返回值: Array<String> 支持的令牌端点认证方法
*/
public func getTokenEndpointAuthMethodsSupported(): Array<String>
/*
* 获取支持的令牌端点认证签名算法值
*
* 返回值: Array<String> 支持的令牌端点认证签名算法值
*/
public func getTokenEndpointAuthSigningAlgorithmValuesSupported(): Array<String>
/*
* 获取支持的显示值
*
* 返回值: Array<String> 支持的显示值
*/
public func getDisplayValuesSupported(): Array<String>
/*
* 获取支持的声明类型
*
* 返回值: Array<String> 支持的声明类型
*/
public func getClaimTypesSupported(): Array<String>
/*
* 获取支持的声明
*
* 返回值: Array<String> 支持的声明
*/
public func getClaimsSupported(): Array<String>
/*
* 获取服务文档
*
* 返回值: AuthUri 服务文档
*/
public func getServiceDocumentation(): AuthUri
/*
* 获取支持的声明语言环境
*
* 返回值: Array<String> 支持的声明语言环境
*/
public func getClaimsLocalesSupported(): Array<String>
/*
* 获取支持的UI语言环境
*
* 返回值: Array<String> 支持的UI语言环境
*/
public func getUiLocalesSupported(): Array<String>
/*
* 检查是否支持声明参数
*
* 返回值: Bool 是否支持声明参数
*/
public func isClaimsParameterSupported(): Bool
/*
* 检查是否支持请求参数
*
* 返回值: Bool 是否支持请求参数
*/
public func isRequestParameterSupported(): Bool
/*
* 检查是否支持请求URI参数
*
* 返回值: Bool 是否支持请求URI参数
*/
public func isRequestUriParameterSupported(): Bool
/*
* 检查是否需要请求URI注册
*
* 返回值: Bool 是否需要请求URI注册
*/
public func requireRequestUriRegistration(): Bool
/*
* 获取操作策略URI
*
* 返回值: AuthUri 操作策略URI
*/
public func getOpPolicyUri(): AuthUri
/*
* 获取操作服务条款URI
*
* 返回值: AuthUri 操作服务条款URI
*/
public func getOpTosUri(): AuthUri
}
8.5 AuthorizationManagementRequest
public interface AuthorizationManagementRequest {
/*
* JSON序列化
*
* 返回值: JsonObject JSON对象
*/
func jsonSerialize(): JsonObject
/*
* JSON序列化为字符串
*
* 返回值: String JSON字符串
*/
func jsonSerializeString(): String
/*
* 获取状态
*
* 返回值: String 状态
*/
func getState(): String
/*
* 转换为URI
*
* 返回值: Uri URI对象
*/
func toUri(): Uri
}
8.6 AuthorizationManagementResponse
public abstract class AuthorizationManagementResponse {
/*
* 获取状态
*
* 返回值: String 状态
*/
public func getState(): String
/*
* JSON序列化
*
* 返回值: JsonObject JSON对象
*/
public func jsonSerialize(): JsonObject
/*
* JSON序列化为字符串
*
* 返回值: String JSON字符串
*/
public open func jsonSerializeString(): String
}
8.7 AuthorizationManagementUtil
public class AuthorizationManagementUtil {
/*
* 生成随机状态
*
* 返回值: String 随机状态
*/
public static func generateRandomState(): String
/*
* 获取请求类型
*
* 参数:
* request - AuthorizationManagementRequest 授权管理请求
*
* 返回值: ?String 请求类型
*/
public static func requestTypeFor(request: AuthorizationManagementRequest): ?String
}
8.8 AuthorizationService
public class AuthorizationService {
/*
* 创建授权服务实例
*/
public AuthorizationService()
/*
* 执行令牌请求
*
* 参数 - request 令牌请求
* 参数 - callback 回调函数,处理令牌响应或授权异常
*
* 返回值 - void
*/
public func performTokenRequest(request: TokenRequest, callback: (?TokenResponse, ?AuthorizationException) -> Bool)
/*
* 执行令牌请求
*
* 参数 - request 令牌请求
* 参数 - clientAuthentication 客户端认证信息
* 参数 - callback 回调函数,处理令牌响应或授权异常
*
* 返回值 - void
*/
public func performTokenRequest(request: TokenRequest, clientAuthentication: ClientAuthentication, callback: (?TokenResponse, ?AuthorizationException) -> Bool)
}
8.9 GrantTypeValues
public class GrantTypeValues {
public static let AUTHORIZATION_CODE: String = "authorization_code"
public static let IMPLICIT: String = "implicit"
public static let REFRESH_TOKEN: String = "refresh_token"
}
8.10 NoClientAuthentication
public class NoClientAuthentication <: ClientAuthentication {
/*
* 默认实例
*/
public static let INSTANCE: NoClientAuthentication
/*
* 认证方式名称
*/
public static let NAME: String
/*
* 获取请求头信息
*
* 参数 - clientId 客户端ID
*
* 返回值 - Map<String, String> 请求头映射
*/
public override func getRequestHeaders(clientId: String): Map<String, String>
/*
* 获取请求参数
*
* 参数 - clientId 客户端ID
*
* 返回值 - Map<String, String> 请求参数映射
*/
public override func getRequestParameters(clientId: String): Map<String, String>
}
8.11 Pair
public class Pair {
/*
* 创建键值对对象
*
* 参数 - key 键
* 参数 - value 值
*/
public init(key: String, value: String)
/*
* 获取键
*
* 返回值 - String
*/
public func getKey(): String
/*
* 获取值
*
* 返回值 - String
*/
public func getValue(): String
/*
* 比较两个Pair对象是否相等
*
* 参数 - that 另一个Pair对象
*
* 返回值 - Bool
*/
public operator func ==(that: Pair): Bool
}
8.12 AuthUri
public abstract class AuthUri {
/*
* 判断URI是否为不透明的
*
* 返回值 - Bool
*/
public func isOpaque(): Bool
/*
* 获取解码后的用户信息
*
* 返回值 - String
*/
public func getUserInfo(): String
/*
* 获取编码后的用户信息
*
* 返回值 - String
*/
public func getEncodedUserInfo(): String
/*
* 获取主机名
*
* 返回值 - String
*/
public func getHost(): String
/*
* 获取端口号
*
* 返回值 - Int64
*/
public func getPort(): Int64
/*
* 获取查询参数名称集合
*
* 返回值 - TreeSet<String>
*
* 异常 - IllegalArgumentException 如果URI是不透明的
*/
public func getQueryParameterNames(): TreeSet<String>
/*
* 根据键获取查询参数值列表
*
* 参数 - key 查询参数的键
*
* 返回值 - ArrayList<String>
*
* 异常 - IllegalArgumentException 如果URI是不透明的
* 异常 - NoneValueException 如果键为空
*/
public func getQueryParameters(key: String): ArrayList<String>
/*
* 根据键获取查询参数值
*
* 参数 - key 查询参数的键
*
* 返回值 - String
*
* 异常 - IllegalArgumentException 如果URI是不透明的
* 异常 - NoneValueException 如果键为空
*/
public func getQueryParameter(key: String): String
/*
* 判断URI是否为分层的
*
* 返回值 - Bool
*/
public func isHierarchical(): Bool
/*
* 获取URI的方案部分
*
* 返回值 - String
*/
public func getScheme(): String
/*
* 获取URI的方案特定部分(解码后)
*
* 返回值 - String
*/
public func getSchemeSpecificPart(): String
/*
* 获取URI的方案特定部分(编码后)
*
* 返回值 - String
*/
public func getEncodedSchemeSpecificPart(): String
/*
* 获取URI的权限部分(解码后)
*
* 返回值 - String
*/
public func getAuthority(): String
/*
* 获取URI的权限部分(编码后)
*
* 返回值 - String
*/
public func getEncodedAuthority(): String
/*
* 获取URI的路径部分(解码后)
*
* 返回值 - String
*/
public func getPath(): String
/*
* 获取URI的路径部分(编码后)
*
* 返回值 - String
*/
public func getEncodedPath(): String
/*
* 获取URI的查询部分(解码后)
*
* 返回值 - String
*/
public func getQuery(): String
/*
* 获取URI的查询部分(编码后)
*
* 返回值 - String
*/
public func getEncodedQuery(): String
/*
* 获取URI的片段部分(解码后)
*
* 返回值 - String
*/
public func getFragment(): String
/*
* 获取URI的片段部分(编码后)
*
* 返回值 - String
*/
public func getEncodedFragment(): String
/*
* 将URI转换为字符串表示
*
* 返回值 - String
*/
public func toString(): String
/*
* 创建URI构建器
*
* 返回值 - Uri_Builder
*/
public func buildUpon(): Uri_Builder
/*
* 从部分组件创建URI
*
* 参数 - scheme URI方案
* 参数 - ssp 方案特定部分
* 参数 - fragment 片段标识符
*
* 返回值 - AuthUri
*
* 异常 - NoneValueException 如果scheme或ssp为空
*/
public static func fromParts(scheme: String, ssp: String, fragment: String): AuthUri
/*
* 解析URI字符串
*
* 参数 - uriString 需要解析的URI字符串
*
* 返回值 - AuthUri
*/
public static func parse(uriString: String): AuthUri
/*
* 对字符串进行URL编码
*
* 参数 - s 需要编码的字符串
*
* 返回值 - String
*/
public static func encode(s: String): String
/*
* 对字符串进行URL编码,允许指定不需要编码的字符
*
* 参数 - s 需要编码的字符串
* 参数 - allow 不需要编码的字符集合
*
* 返回值 - String
*/
public static func encode(s: String, allow: String): String
/*
* 对URL编码的字符串进行解码
*
* 参数 - s 需要解码的字符串
*
* 返回值 - String
*/
public static func decode(s: String): String
/*
* 对URL编码的字符串进行解码
*
* 参数 - s 需要解码的字符串
* 参数 - convertPlus 是否将加号转换为空格
* 参数 - throwOnFailure 解码失败时是否抛出异常
*
* 返回值 - String
*/
public static func decode(s: String, convertPlus: Bool, throwOnFailure: Bool): String
}
public class Uri_Builder {
/*
* 构造一个新的Uri_Builder实例
*/
public Uri_Builder()
/*
* 设置URI的scheme部分
*
* 参数 - scheme URI的scheme
*
* 返回值 - Uri_Builder
*/
public func setScheme(scheme: String): Uri_Builder
/*
* 设置URI的不透明部分(解码后的值)
*
* 参数 - opaquePart URI的不透明部分
*
* 返回值 - Uri_Builder
*/
public func decodedOpaquePart(opaquePart: String): Uri_Builder
/*
* 设置URI的不透明部分(编码后的值)
*
* 参数 - opaquePart URI的不透明部分
*
* 返回值 - Uri_Builder
*/
public func encodedOpaquePart(opaquePart: String): Uri_Builder
/*
* 设置URI的authority部分(解码后的值)
*
* 参数 - authority URI的authority部分
*
* 返回值 - Uri_Builder
*/
public func decodedAuthority(authority: String): Uri_Builder
/*
* 设置URI的authority部分(编码后的值)
*
* 参数 - authority URI的authority部分
*
* 返回值 - Uri_Builder
*/
public func encodedAuthority(authority: String): Uri_Builder
/*
* 设置URI的path部分(解码后的值)
*
* 参数 - path URI的path部分
*
* 返回值 - Uri_Builder
*/
public func decodedPath(path: String): Uri_Builder
/*
* 设置URI的path部分(编码后的值)
*
* 参数 - path URI的path部分
*
* 返回值 - Uri_Builder
*/
public func encodedPath(path: String): Uri_Builder
/*
* 向URI的path部分追加一个解码后的路径段
*
* 参数 - newSegment 要追加的路径段
*
* 返回值 - Uri_Builder
*/
public func appendDecodedPath(newSegment: String): Uri_Builder
/*
* 向URI的path部分追加一个编码后的路径段
*
* 参数 - newSegment 要追加的路径段
*
* 返回值 - Uri_Builder
*/
public func appendEncodedPath(newSegment: String): Uri_Builder
/*
* 设置URI的query部分(解码后的值)
*
* 参数 - query URI的query部分
*
* 返回值 - Uri_Builder
*/
public func decodedQuery(query: String): Uri_Builder
/*
* 设置URI的query部分(编码后的值)
*
* 参数 - query URI的query部分
*
* 返回值 - Uri_Builder
*/
public func encodedQuery(query: String): Uri_Builder
/*
* 设置URI的fragment部分(解码后的值)
*
* 参数 - fragment URI的fragment部分
*
* 返回值 - Uri_Builder
*/
public func decodedFragment(fragment: String): Uri_Builder
/*
* 设置URI的fragment部分(编码后的值)
*
* 参数 - fragment URI的fragment部分
*
* 返回值 - Uri_Builder
*/
public func encodedFragment(fragment: String): Uri_Builder
/*
* 向URI的query部分追加一个参数
*
* 参数 - key 参数名
* 参数 - value 参数值
*
* 返回值 - Uri_Builder
*/
public func appendQueryParameter(key: String, value: String): Uri_Builder
/*
* 清除URI的query部分
*
* 返回值 - Uri_Builder
*/
public func clearQuery(): Uri_Builder
/*
* 根据当前设置构建AuthUri实例
*
* 返回值 - AuthUri
*
* 异常 - NoneValueException 如果是不透明URI但没有设置scheme
*/
public func build(): AuthUri
}
9. 其他接口
9.1 UriUtil
public class UriUtil {
/*
* 解析uri
*
* 参数 - uri uri
*
* 返回值 - Option<AuthUri>
*/
public static func parseUriIfAvailable(uri: String): Option<AuthUri>
/*
* 如果不为空,追加查询参数
*
* 参数 - builder
* 参数 - paramName
* 参数 - value
*
* 返回值 - Uri_Builder
*/
public static func appendQueryParameterIfNotNull(builder: Uri_Builder, paramName: String, value: String): Uri_Builder
/*
* 查找Int64类型的参数
*
* 参数 - uri
* 参数 - param
*
* 返回值 - Option<Int64>
*/
public static func getInt64QueryParameter(uri: AuthUri, param: String): Option<Int64>
/*
* 从map参数中编码url
*
* 参数 - parameters
*
* 返回值 - String
*/
public static func formUrlEncode(parameters: Map<String, String>): String
/*
* 从String参数中编码url
*
* 参数 - value
*
* 返回值 - String
*/
public static func formUrlEncodeValue(value: String): String
/*
* 从String参数中解码url
*
* 参数 - encoded
*
* 返回值 - ArrayList<Pair>
*/
public static func formUrlDecode(encoded: String): ArrayList<Pair>
/*
* 从String参数中解码url放入map中
*
* 参数 - encoded
*
* 返回值 - HashMap<String, String>
*/
public static func formUrlDecodeUnique(encoded: String): HashMap<String, String>
}
9.2 CodeVerifierUtil
public class CodeVerifierUtil {
/*
* 检查代码验证器
*
* 参数 - codeVerifier 代码验证器
*
* 返回值 - Unit
*/
public static func checkCodeVerifier(codeVerifier: String): Unit
/*
* 生成随机码验证器
*
* 返回值 - String
*/
public static func generateRandomCodeVerifier(): String
/*
* 生成随机代码验证器
*
* 参数 - entropySource 生成随机代码验证器的熵源
* 参数 - entropyBytes 生成随机代码验证器的熵字节数
*
* 返回值 - String
*/
public static func generateRandomCodeVerifier(entropySource: SecureRandom, entropyBytes: Int64): String
/*
* 尝试生成代码验证器
*
* 参数 - codeVerifier 代码验证器
*
* 返回值 - String
*/
public static func deriveCodeVerifierChallenge(codeVerifier: String): String
/*
* 获取代码验证器尝试方法
*
* 返回值 - String
*/
public static func getCodeVerifierChallengeMethod(): String
9.3 AuthorizationException
public class AuthorizationException {
/*
* 返回根据提供的错误字符串匹配异常类型
*
* 参数 - error 错误字符串
*
* 返回值 - AuthorizationException
*/
public static func byStringAuthorizationRequestErrors(error: String): AuthorizationException
/*
* 返回根据提供的错误字符串匹配异常类型
*
* 参数 - error 错误字符串
*
* 返回值 - AuthorizationException
*/
public static func byStringTokenRequestErrors(error: String): AuthorizationException
/*
* 返回根据提供的错误字符串匹配异常类型
*
* 参数 - error 错误字符串
*
* 返回值 - AuthorizationException
*/
public static func byStringRegistrationRequestErrors(error: String): AuthorizationException
/*
* 根据已有AuthorizationRequestErrors和TokenRequestErrors错误加上一部分信息创建新Exception
*
* 参数 - ex 错误字符串
* 参数 - errorOverride 错误字符串
* 参数 - errorDescriptionOverride 错误字符串
* 参数 - errorUriOverride 错误字符串
*
* 返回值 - AuthorizationException
*/
public static func fromOAuthTemplate(ex: AuthorizationException, errorOverride: String, errorDescriptionOverride: String, errorUriOverride: Uri): AuthorizationException
/*
* 根据json字符串创建新的JsonException
*
* 参数 - json json字符串
*
* 返回值 - JsonException
*/
public static func fromJson(json: String): JsonException
/*
* 根据json数据创建新的JsonException
*
* 参数 - json json对象
*
* 返回值 - JsonException
*/
public static func fromJson(json: JsonObject): JsonException
/*
* 从Intent获取数据创建AuthorizationException
*
* 参数 - data Intent数据
*
* 返回值 - AuthorizationException
*/
public static func fromIntent(data: Intent): AuthorizationException
/*
* tojson返回的值转化成字符串
*
* 返回值 - String
*/
public func toJsonString(): String
/*
* 返回json对象
*
* 返回值 - JsonObject
*/
public func toJson(): JsonObject
/*
* 将toJson生成的数据转换成Intent
*
* 返回值 - JsonObject
*/
public func toIntent(): Intent
/*
* 返回map映射的exception
*
* 参数 - exceptions exception的集合
*
* 返回值 - Map<String, AuthorizationException>
*/
public static func exceptionMapByString(exceptions: ArrayList<AuthorizationException>): Map<String, AuthorizationException>
/*
* 错误相等方法
*
* 参数 - obj 错误对象
*
* 返回值 - Bool
*/
public func equals(obj: Object): Bool
/*
* 返回hashCode值
*
* 返回值 - Int32
*/
public func hashCode(): Int32
/*
* 返回toJsonString()方法修改后的字符串
*
* 返回值 - String
*/
public func toString(): String
}