JwtTokenValidation 类
- java.lang.Object
- com.microsoft.bot.connector.authentication.JwtTokenValidation
public final class JwtTokenValidation
包含用于对传入的 HTTP 请求进行身份验证的帮助程序方法。
方法摘要
修饰符和类型 |
方法和描述 |
static
java.util.concurrent.CompletableFuture<ClaimsIdentity>
|
authenticateRequest(Activity activity, String authHeader, CredentialProvider credentials, ChannelProvider channelProvider)
对请求进行身份验证,并将活动的 Activity#getServiceUrl() 添加到受信任的 URL 集。
|
static
java.util.concurrent.CompletableFuture<ClaimsIdentity>
|
authenticateRequest(Activity activity, String authHeader, CredentialProvider credentials, ChannelProvider channelProvider, AuthenticationConfiguration authConfig)
对请求进行身份验证,并将活动的 Activity#getServiceUrl() 添加到受信任的 URL 集。
|
static
java.lang.String
|
getAppIdFromClaims(Map<String,String> claims)
从声明获取应用ID。
|
static
boolean
|
isValidTokenFormat(String authHeader)
用于检查令牌是否具有预期形状的“持有者 [大长字符串]”的内部帮助程序。
|
static
java.util.concurrent.CompletableFuture<ClaimsIdentity>
|
validateAuthHeader(String authHeader, CredentialProvider credentials, ChannelProvider channelProvider, String channelId, String serviceUrl)
验证传入请求的身份验证标头。
|
static
java.util.concurrent.CompletableFuture<ClaimsIdentity>
|
validateAuthHeader(String authHeader, CredentialProvider credentials, ChannelProvider channelProvider, String channelId, String serviceUrl, AuthenticationConfiguration authConfig)
验证传入请求的身份验证标头。
|
方法继承自 java.lang.Object
java.lang.Object.clone
java.lang.Object.equals
java.lang.Object.finalize
java.lang.Object.getClass
java.lang.Object.hashCode
java.lang.Object.notify
java.lang.Object.notifyAll
java.lang.Object.toString
java.lang.Object.wait
java.lang.Object.wait
java.lang.Object.wait
方法详细信息
authenticateRequest
public static CompletableFuture authenticateRequest(Activity activity, String authHeader, CredentialProvider credentials, ChannelProvider channelProvider)
对请求进行身份验证,并将活动的 Activity#getServiceUrl() 添加到受信任的 URL 集。
Parameters:
activity
- 来自 Bot Framework 或 Emulator 的传入活动
authHeader
- 作为请求的一部分包含的持有者令牌
credentials
- 机器人的凭据提供程序。
channelProvider
- 机器人的通道服务提供商。
Returns:
一个任务,表示排队要执行的工作。
authenticateRequest
public static CompletableFuture authenticateRequest(Activity activity, String authHeader, CredentialProvider credentials, ChannelProvider channelProvider, AuthenticationConfiguration authConfig)
对请求进行身份验证,并将活动的 Activity#getServiceUrl() 添加到受信任的 URL 集。
Parameters:
activity
- 来自 Bot Framework 或 Emulator 的传入活动
authHeader
- 作为请求的一部分包含的持有者令牌
credentials
- 机器人的凭据提供程序。
channelProvider
- 机器人的通道服务提供商。
authConfig
- 可选的身份验证配置。
Returns:
一个任务,表示排队要执行的工作。
getAppIdFromClaims
public static String getAppIdFromClaims(Map claims)
从声明获取 AppId。
在 v1 令牌中,AppId 位于 AppIdClaim 声明中。 在 v2 令牌中,AppId 位于 AuthorizedParty 声明中。
Parameters:
claims
- 声明的映射。
Returns:
如果找到 appId 声明,则其值 (null(如果找不到合适的声明) )。
Throws:
java.lang.IllegalArgumentException
- 缺少声明
isValidTokenFormat
public static boolean isValidTokenFormat(String authHeader)
用于检查令牌是否具有预期形状的“持有者 [大长字符串]”的内部帮助程序。
Parameters:
authHeader
- 包含令牌标头的字符串。
Returns:
如果令牌有效,则为 True;如果无效,则为 false。
validateAuthHeader
public static CompletableFuture validateAuthHeader(String authHeader, CredentialProvider credentials, ChannelProvider channelProvider, String channelId, String serviceUrl)
验证传入请求的身份验证标头。
Parameters:
authHeader
- 要验证的身份验证标头。
credentials
- 机器人的凭据提供程序。
channelProvider
- 机器人的通道服务提供商。
channelId
- 发送请求的通道的 ID。
serviceUrl
- 活动的服务 URL。
Returns:
一个任务,表示排队要执行的工作。
On Call:
validateAuthHeader
public static CompletableFuture validateAuthHeader(String authHeader, CredentialProvider credentials, ChannelProvider channelProvider, String channelId, String serviceUrl, AuthenticationConfiguration authConfig)
验证传入请求的身份验证标头。
Parameters:
authHeader
- 要验证的身份验证标头。
credentials
- 机器人的凭据提供程序。
channelProvider
- 机器人的通道服务提供商。
channelId
- 发送请求的通道的 ID。
serviceUrl
- 活动的服务 URL。
authConfig
- 身份验证配置。
Returns:
一个任务,表示排队要执行的工作。
适用于