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)

内部帮助程序用于检查令牌是否具有所需的形状“Bearer [大长字符串]”。

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 集。

参数:

activity - Bot Framework 或模拟器中的传入活动
authHeader - 作为请求的一部分包含的持有者令牌
credentials - 机器人的凭据提供程序。
channelProvider - 机器人的通道服务提供商。

返回:

表示要执行的工作的任务。

authenticateRequest

public static CompletableFuture authenticateRequest(Activity activity, String authHeader, CredentialProvider credentials, ChannelProvider channelProvider, AuthenticationConfiguration authConfig)

对请求进行身份验证,并将活动的 Activity#getServiceUrl() 添加到受信任的 URL 集。

参数:

activity - Bot Framework 或模拟器中的传入活动
authHeader - 作为请求的一部分包含的持有者令牌
credentials - 机器人的凭据提供程序。
channelProvider - 机器人的通道服务提供商。
authConfig - 可选的身份验证配置。

返回:

表示要执行的工作的任务。

getAppIdFromClaims

public static String getAppIdFromClaims(Map claims)

从声明获取 AppId。

在 v1 令牌中,AppId 位于 AppIdClaim 声明中。 在 v2 令牌中,AppId 位于 AuthorizedParty 声明中。

参数:

claims - 声明的映射。

返回:

如果找到 appId 声明的值(如果找不到合适的声明,则为 null)。

引发:

java.lang.IllegalArgumentException - 缺少声明

isValidTokenFormat

public static boolean isValidTokenFormat(String authHeader)

内部帮助程序用于检查令牌是否具有所需的形状“Bearer [大长字符串]”。

参数:

authHeader - 包含令牌标头的字符串。

返回:

如果令牌有效,则为 true;否则为 false。

validateAuthHeader

public static CompletableFuture validateAuthHeader(String authHeader, CredentialProvider credentials, ChannelProvider channelProvider, String channelId, String serviceUrl)

验证传入请求的身份验证标头。

参数:

authHeader - 要验证的身份验证标头。
credentials - 机器人的凭据提供程序。
channelProvider - 机器人的通道服务提供商。
channelId - 发送请求的通道的 ID。
serviceUrl - 活动的服务 URL。

返回:

表示要执行的工作的任务。
     On Call:

validateAuthHeader

public static CompletableFuture validateAuthHeader(String authHeader, CredentialProvider credentials, ChannelProvider channelProvider, String channelId, String serviceUrl, AuthenticationConfiguration authConfig)

验证传入请求的身份验证标头。

参数:

authHeader - 要验证的身份验证标头。
credentials - 机器人的凭据提供程序。
channelProvider - 机器人的通道服务提供商。
channelId - 发送请求的通道的 ID。
serviceUrl - 活动的服务 URL。
authConfig - 身份验证配置。

返回:

表示要执行的工作的任务。

适用于