diff --git a/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java
index a587516c5..54ba59213 100644
--- a/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java
+++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java
@@ -41,6 +41,8 @@
import com.microsoft.bot.schema.ExpectedReplies;
import com.microsoft.bot.schema.ResourceResponse;
import com.microsoft.bot.schema.Serialization;
+import com.microsoft.bot.schema.SignInResource;
+import com.microsoft.bot.schema.TokenExchangeRequest;
import com.microsoft.bot.schema.TokenExchangeState;
import com.microsoft.bot.schema.TokenResponse;
import com.microsoft.bot.schema.TokenStatus;
@@ -78,8 +80,10 @@
*
* {@link TurnContext} {@link Activity} {@link Bot} {@link Middleware}
*/
-public class BotFrameworkAdapter extends BotAdapter
- implements AdapterIntegration, UserTokenProvider {
+public class BotFrameworkAdapter extends BotAdapter implements
+ AdapterIntegration,
+ UserTokenProvider,
+ ConnectorClientBuilder {
/**
* Key to store InvokeResponse.
*/
@@ -151,19 +155,10 @@ public BotFrameworkAdapter(CredentialProvider withCredentialProvider) {
* @param withRetryStrategy Retry policy for retrying HTTP operations.
* @param withMiddleware The middleware to initially add to the adapter.
*/
- public BotFrameworkAdapter(
- CredentialProvider withCredentialProvider,
- ChannelProvider withChannelProvider,
- RetryStrategy withRetryStrategy,
- Middleware withMiddleware
- ) {
- this(
- withCredentialProvider,
- new AuthenticationConfiguration(),
- withChannelProvider,
- withRetryStrategy,
- withMiddleware
- );
+ public BotFrameworkAdapter(CredentialProvider withCredentialProvider, ChannelProvider withChannelProvider,
+ RetryStrategy withRetryStrategy, Middleware withMiddleware) {
+ this(withCredentialProvider, new AuthenticationConfiguration(), withChannelProvider, withRetryStrategy,
+ withMiddleware);
}
/**
@@ -176,13 +171,8 @@ public BotFrameworkAdapter(
* @param withRetryStrategy Retry policy for retrying HTTP operations.
* @param withMiddleware The middleware to initially add to the adapter.
*/
- public BotFrameworkAdapter(
- CredentialProvider withCredentialProvider,
- AuthenticationConfiguration withAuthConfig,
- ChannelProvider withChannelProvider,
- RetryStrategy withRetryStrategy,
- Middleware withMiddleware
- ) {
+ public BotFrameworkAdapter(CredentialProvider withCredentialProvider, AuthenticationConfiguration withAuthConfig,
+ ChannelProvider withChannelProvider, RetryStrategy withRetryStrategy, Middleware withMiddleware) {
if (withCredentialProvider == null) {
throw new IllegalArgumentException("CredentialProvider cannot be null");
}
@@ -220,13 +210,8 @@ public BotFrameworkAdapter(
* @param withRetryStrategy Retry policy for retrying HTTP operations.
* @param withMiddleware The middleware to initially add to the adapter.
*/
- public BotFrameworkAdapter(
- AppCredentials withCredentials,
- AuthenticationConfiguration withAuthConfig,
- ChannelProvider withChannelProvider,
- RetryStrategy withRetryStrategy,
- Middleware withMiddleware
- ) {
+ public BotFrameworkAdapter(AppCredentials withCredentials, AuthenticationConfiguration withAuthConfig,
+ ChannelProvider withChannelProvider, RetryStrategy withRetryStrategy, Middleware withMiddleware) {
if (withCredentials == null) {
throw new IllegalArgumentException("credentials");
}
@@ -281,11 +266,8 @@ public BotFrameworkAdapter(
* @throws IllegalArgumentException botAppId, reference, or callback is null.
*/
@Override
- public CompletableFuture continueConversation(
- String botAppId,
- ConversationReference reference,
- BotCallbackHandler callback
- ) {
+ public CompletableFuture continueConversation(String botAppId, ConversationReference reference,
+ BotCallbackHandler callback) {
if (reference == null) {
return Async.completeExceptionally(new IllegalArgumentException("reference"));
}
@@ -322,14 +304,9 @@ public CompletableFuture continueConversation(
* @param callback The method to call for the result bot turn.
* @return A task that represents the work queued to execute.
*/
- public CompletableFuture continueConversation(
- ClaimsIdentity claimsIdentity,
- ConversationReference reference,
- BotCallbackHandler callback
- ) {
- return continueConversation(
- claimsIdentity, reference, getBotFrameworkOAuthScope(), callback
- );
+ public CompletableFuture continueConversation(ClaimsIdentity claimsIdentity, ConversationReference reference,
+ BotCallbackHandler callback) {
+ return continueConversation(claimsIdentity, reference, getBotFrameworkOAuthScope(), callback);
}
/**
@@ -348,12 +325,8 @@ claimsIdentity, reference, getBotFrameworkOAuthScope(), callback
* @param callback The method to call for the result bot turn.
* @return A task that represents the work queued to execute.
*/
- public CompletableFuture continueConversation(
- ClaimsIdentity claimsIdentity,
- ConversationReference reference,
- String audience,
- BotCallbackHandler callback
- ) {
+ public CompletableFuture continueConversation(ClaimsIdentity claimsIdentity, ConversationReference reference,
+ String audience, BotCallbackHandler callback) {
if (claimsIdentity == null) {
return Async.completeExceptionally(new IllegalArgumentException("claimsIdentity"));
}
@@ -367,34 +340,30 @@ public CompletableFuture continueConversation(
}
if (StringUtils.isEmpty(audience)) {
- return Async.completeExceptionally(new IllegalArgumentException(
- "audience cannot be null or empty"
- ));
+ return Async.completeExceptionally(new IllegalArgumentException("audience cannot be null or empty"));
}
CompletableFuture pipelineResult = new CompletableFuture<>();
- try (TurnContextImpl context =
- new TurnContextImpl(this, reference.getContinuationActivity())) {
+ try (TurnContextImpl context = new TurnContextImpl(this, reference.getContinuationActivity())) {
context.getTurnState().add(BOT_IDENTITY_KEY, claimsIdentity);
context.getTurnState().add(OAUTH_SCOPE_KEY, audience);
String appIdFromClaims = JwtTokenValidation.getAppIdFromClaims(claimsIdentity.claims());
- return credentialProvider.isValidAppId(appIdFromClaims)
- .thenCompose(isValidAppId -> {
- // If we receive a valid app id in the incoming token claims, add the
- // channel service URL to the trusted services list so we can send messages back.
- if (!StringUtils.isEmpty(appIdFromClaims) && isValidAppId) {
- AppCredentials.trustServiceUrl(reference.getServiceUrl());
- }
+ return credentialProvider.isValidAppId(appIdFromClaims).thenCompose(isValidAppId -> {
+ // If we receive a valid app id in the incoming token claims, add the
+ // channel service URL to the trusted services list so we can send messages
+ // back.
+ if (!StringUtils.isEmpty(appIdFromClaims) && isValidAppId) {
+ AppCredentials.trustServiceUrl(reference.getServiceUrl());
+ }
- return createConnectorClient(
- reference.getServiceUrl(), claimsIdentity, audience
- ).thenCompose(connectorClient -> {
- context.getTurnState().add(CONNECTOR_CLIENT_KEY, connectorClient);
- return runPipeline(context, callback);
- });
- });
+ return createConnectorClient(reference.getServiceUrl(), claimsIdentity, audience)
+ .thenCompose(connectorClient -> {
+ context.getTurnState().add(CONNECTOR_CLIENT_KEY, connectorClient);
+ return runPipeline(context, callback);
+ });
+ });
} catch (Exception e) {
pipelineResult.completeExceptionally(e);
}
@@ -430,18 +399,15 @@ public BotFrameworkAdapter use(Middleware middleware) {
* returned.
* @throws IllegalArgumentException Activity is null.
*/
- public CompletableFuture processActivity(
- String authHeader,
- Activity activity,
- BotCallbackHandler callback
- ) {
+ public CompletableFuture processActivity(String authHeader, Activity activity,
+ BotCallbackHandler callback) {
if (activity == null) {
return Async.completeExceptionally(new IllegalArgumentException("Activity"));
}
- return JwtTokenValidation.authenticateRequest(
- activity, authHeader, credentialProvider, channelProvider, authConfiguration
- ).thenCompose(claimsIdentity -> processActivity(claimsIdentity, activity, callback));
+ return JwtTokenValidation
+ .authenticateRequest(activity, authHeader, credentialProvider, channelProvider, authConfiguration)
+ .thenCompose(claimsIdentity -> processActivity(claimsIdentity, activity, callback));
}
/**
@@ -458,11 +424,8 @@ public CompletableFuture processActivity(
* returned.
* @throws IllegalArgumentException Activity is null.
*/
- public CompletableFuture processActivity(
- ClaimsIdentity identity,
- Activity activity,
- BotCallbackHandler callback
- ) {
+ public CompletableFuture processActivity(ClaimsIdentity identity, Activity activity,
+ BotCallbackHandler callback) {
if (activity == null) {
return Async.completeExceptionally(new IllegalArgumentException("Activity"));
}
@@ -522,30 +485,27 @@ public CompletableFuture processActivity(
return pipelineResult;
}
- @SuppressWarnings({"PMD"})
+ @SuppressWarnings("PMD")
private CompletableFuture generateCallerId(ClaimsIdentity claimsIdentity) {
- return credentialProvider.isAuthenticationDisabled()
- .thenApply(
- is_auth_disabled -> {
- // Is the bot accepting all incoming messages?
- if (is_auth_disabled) {
- return null;
- }
+ return credentialProvider.isAuthenticationDisabled().thenApply(is_auth_disabled -> {
+ // Is the bot accepting all incoming messages?
+ if (is_auth_disabled) {
+ return null;
+ }
- // Is the activity from Public Azure?
- if (channelProvider == null || channelProvider.isPublicAzure()) {
- return CallerIdConstants.PUBLIC_AZURE_CHANNEL;
- }
+ // Is the activity from Public Azure?
+ if (channelProvider == null || channelProvider.isPublicAzure()) {
+ return CallerIdConstants.PUBLIC_AZURE_CHANNEL;
+ }
- // Is the activity from Azure Gov?
- if (channelProvider != null && channelProvider.isGovernment()) {
- return CallerIdConstants.US_GOV_CHANNEL;
- }
+ // Is the activity from Azure Gov?
+ if (channelProvider != null && channelProvider.isGovernment()) {
+ return CallerIdConstants.US_GOV_CHANNEL;
+ }
- // Return null so that the callerId is cleared.
- return null;
- }
- );
+ // Return null so that the callerId is cleared.
+ return null;
+ });
}
/**
@@ -562,10 +522,7 @@ private CompletableFuture generateCallerId(ClaimsIdentity claimsIdentity
*/
@SuppressWarnings("checkstyle:EmptyBlock, checkstyle:linelength")
@Override
- public CompletableFuture sendActivities(
- TurnContext context,
- List activities
- ) {
+ public CompletableFuture sendActivities(TurnContext context, List activities) {
if (context == null) {
return Async.completeExceptionally(new IllegalArgumentException("context"));
}
@@ -575,9 +532,8 @@ public CompletableFuture sendActivities(
}
if (activities.size() == 0) {
- return Async.completeExceptionally(new IllegalArgumentException(
- "Expecting one or more activities, but the array was empty."
- ));
+ return Async.completeExceptionally(
+ new IllegalArgumentException("Expecting one or more activities, but the array was empty."));
}
return CompletableFuture.supplyAsync(() -> {
@@ -611,21 +567,16 @@ public CompletableFuture sendActivities(
context.getTurnState().add(INVOKE_RESPONSE_KEY, activity);
// No need to create a response. One will be created below.
response = null;
- } else if (
- activity.isType(ActivityTypes.TRACE)
- && !StringUtils.equals(activity.getChannelId(), Channels.EMULATOR)
- ) {
+ } else if (activity.isType(ActivityTypes.TRACE)
+ && !StringUtils.equals(activity.getChannelId(), Channels.EMULATOR)) {
// if it is a Trace activity we only send to the channel if it's the emulator.
response = null;
} else if (!StringUtils.isEmpty(activity.getReplyToId())) {
- ConnectorClient connectorClient =
- context.getTurnState().get(CONNECTOR_CLIENT_KEY);
+ ConnectorClient connectorClient = context.getTurnState().get(CONNECTOR_CLIENT_KEY);
response = connectorClient.getConversations().replyToActivity(activity).join();
} else {
- ConnectorClient connectorClient =
- context.getTurnState().get(CONNECTOR_CLIENT_KEY);
- response =
- connectorClient.getConversations().sendToConversation(activity).join();
+ ConnectorClient connectorClient = context.getTurnState().get(CONNECTOR_CLIENT_KEY);
+ response = connectorClient.getConversations().sendToConversation(activity).join();
}
// If No response is set, then default to a "simple" response. This can't really
@@ -640,8 +591,7 @@ public CompletableFuture sendActivities(
// https://github.com/Microsoft/botbuilder-dotnet/issues/460
// bug report : https://github.com/Microsoft/botbuilder-dotnet/issues/465
if (response == null) {
- response =
- new ResourceResponse((activity.getId() == null) ? "" : activity.getId());
+ response = new ResourceResponse((activity.getId() == null) ? "" : activity.getId());
}
responses[index] = response;
@@ -667,10 +617,7 @@ public CompletableFuture sendActivities(
* {@link TurnContext#onUpdateActivity(UpdateActivityHandler)}
*/
@Override
- public CompletableFuture updateActivity(
- TurnContext context,
- Activity activity
- ) {
+ public CompletableFuture updateActivity(TurnContext context, Activity activity) {
ConnectorClient connectorClient = context.getTurnState().get(CONNECTOR_CLIENT_KEY);
return connectorClient.getConversations().updateActivity(activity);
}
@@ -684,13 +631,10 @@ public CompletableFuture updateActivity(
* {@link TurnContext#onDeleteActivity(DeleteActivityHandler)}
*/
@Override
- public CompletableFuture deleteActivity(
- TurnContext context,
- ConversationReference reference
- ) {
+ public CompletableFuture deleteActivity(TurnContext context, ConversationReference reference) {
ConnectorClient connectorClient = context.getTurnState().get(CONNECTOR_CLIENT_KEY);
- return connectorClient.getConversations()
- .deleteActivity(reference.getConversation().getId(), reference.getActivityId());
+ return connectorClient.getConversations().deleteActivity(reference.getConversation().getId(),
+ reference.getActivityId());
}
/**
@@ -700,26 +644,20 @@ public CompletableFuture deleteActivity(
* @param memberId ID of the member to delete from the conversation
* @return A task that represents the work queued to execute.
*/
- public CompletableFuture deleteConversationMember(
- TurnContextImpl context,
- String memberId
- ) {
+ public CompletableFuture deleteConversationMember(TurnContextImpl context, String memberId) {
if (context.getActivity().getConversation() == null) {
return Async.completeExceptionally(new IllegalArgumentException(
- "BotFrameworkAdapter.deleteConversationMember(): missing conversation"
- ));
+ "BotFrameworkAdapter.deleteConversationMember(): missing conversation"));
}
if (StringUtils.isEmpty(context.getActivity().getConversation().getId())) {
return Async.completeExceptionally(new IllegalArgumentException(
- "BotFrameworkAdapter.deleteConversationMember(): missing conversation.id"
- ));
+ "BotFrameworkAdapter.deleteConversationMember(): missing conversation.id"));
}
ConnectorClient connectorClient = context.getTurnState().get(CONNECTOR_CLIENT_KEY);
String conversationId = context.getActivity().getConversation().getId();
- return connectorClient.getConversations()
- .deleteConversationMember(conversationId, memberId);
+ return connectorClient.getConversations().deleteConversationMember(conversationId, memberId);
}
/**
@@ -740,25 +678,20 @@ public CompletableFuture> getActivityMembers(TurnContextImp
* current activities ID will be used.
* @return List of Members of the activity
*/
- public CompletableFuture> getActivityMembers(
- TurnContextImpl context,
- String activityId
- ) {
+ public CompletableFuture> getActivityMembers(TurnContextImpl context, String activityId) {
// If no activity was passed in, use the current activity.
if (activityId == null) {
activityId = context.getActivity().getId();
}
if (context.getActivity().getConversation() == null) {
- return Async.completeExceptionally(new IllegalArgumentException(
- "BotFrameworkAdapter.GetActivityMembers(): missing conversation"
- ));
+ return Async.completeExceptionally(
+ new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation"));
}
if (StringUtils.isEmpty(context.getActivity().getConversation().getId())) {
- return Async.completeExceptionally(new IllegalArgumentException(
- "BotFrameworkAdapter.GetActivityMembers(): missing conversation.id"
- ));
+ return Async.completeExceptionally(
+ new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation.id"));
}
ConnectorClient connectorClient = context.getTurnState().get(CONNECTOR_CLIENT_KEY);
@@ -775,15 +708,13 @@ public CompletableFuture> getActivityMembers(
*/
public CompletableFuture> getConversationMembers(TurnContextImpl context) {
if (context.getActivity().getConversation() == null) {
- return Async.completeExceptionally(new IllegalArgumentException(
- "BotFrameworkAdapter.GetActivityMembers(): missing conversation"
- ));
+ return Async.completeExceptionally(
+ new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation"));
}
if (StringUtils.isEmpty(context.getActivity().getConversation().getId())) {
- return Async.completeExceptionally(new IllegalArgumentException(
- "BotFrameworkAdapter.GetActivityMembers(): missing conversation.id"
- ));
+ return Async.completeExceptionally(
+ new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation.id"));
}
ConnectorClient connectorClient = context.getTurnState().get(CONNECTOR_CLIENT_KEY);
@@ -808,10 +739,8 @@ public CompletableFuture> getConversationMembers(TurnContex
* conversation, as only the Bot's ServiceUrl and credentials are
* required.
*/
- public CompletableFuture getConversations(
- String serviceUrl,
- MicrosoftAppCredentials credentials
- ) {
+ public CompletableFuture getConversations(String serviceUrl,
+ MicrosoftAppCredentials credentials) {
return getConversations(serviceUrl, credentials, null);
}
@@ -832,11 +761,8 @@ public CompletableFuture getConversations(
* results.
* @return List of Members of the current conversation
*/
- public CompletableFuture getConversations(
- String serviceUrl,
- MicrosoftAppCredentials credentials,
- String continuationToken
- ) {
+ public CompletableFuture getConversations(String serviceUrl,
+ MicrosoftAppCredentials credentials, String continuationToken) {
if (StringUtils.isEmpty(serviceUrl)) {
return Async.completeExceptionally(new IllegalArgumentException("serviceUrl"));
}
@@ -846,10 +772,7 @@ public CompletableFuture getConversations(
}
return getOrCreateConnectorClient(serviceUrl, credentials)
- .thenCompose(
- connectorClient -> connectorClient.getConversations()
- .getConversations(continuationToken)
- );
+ .thenCompose(connectorClient -> connectorClient.getConversations().getConversations(continuationToken));
}
/**
@@ -885,10 +808,7 @@ public CompletableFuture getConversations(TurnContextImpl c
* results.
* @return List of Members of the current conversation
*/
- public CompletableFuture getConversations(
- TurnContextImpl context,
- String continuationToken
- ) {
+ public CompletableFuture getConversations(TurnContextImpl context, String continuationToken) {
ConnectorClient connectorClient = context.getTurnState().get(CONNECTOR_CLIENT_KEY);
return connectorClient.getConversations().getConversations(continuationToken);
}
@@ -903,32 +823,22 @@ public CompletableFuture getConversations(
* @return Token Response
*/
@Override
- public CompletableFuture getUserToken(
- TurnContext context,
- String connectionName,
- String magicCode
- ) {
+ public CompletableFuture getUserToken(TurnContext context, String connectionName, String magicCode) {
if (context == null) {
return Async.completeExceptionally(new IllegalArgumentException("TurnContext"));
}
- if (
- context.getActivity().getFrom() == null
- || StringUtils.isEmpty(context.getActivity().getFrom().getId())
- ) {
- return Async.completeExceptionally(new IllegalArgumentException(
- "BotFrameworkAdapter.getUserToken(): missing from or from.id"
- ));
+ if (context.getActivity().getFrom() == null || StringUtils.isEmpty(context.getActivity().getFrom().getId())) {
+ return Async.completeExceptionally(
+ new IllegalArgumentException("BotFrameworkAdapter.getUserToken(): missing from or from.id"));
}
if (StringUtils.isEmpty(connectionName)) {
return Async.completeExceptionally(new IllegalArgumentException("connectionName"));
}
- return createOAuthClient(context, null).thenCompose(oAuthClient -> oAuthClient.getUserToken()
- .getToken(
- context.getActivity().getFrom().getId(), connectionName,
- context.getActivity().getChannelId(), magicCode
- ));
+ return createOAuthAPIClient(context, null)
+ .thenCompose(oAuthClient -> oAuthClient.getUserToken().getToken(context.getActivity().getFrom().getId(),
+ connectionName, context.getActivity().getChannelId(), magicCode));
}
/**
@@ -941,50 +851,8 @@ public CompletableFuture getUserToken(
* @return A task that represents the work queued to execute.
*/
@Override
- public CompletableFuture getOauthSignInLink(
- TurnContext context,
- String connectionName
- ) {
- if (context == null) {
- return Async.completeExceptionally(new IllegalArgumentException("TurnContext"));
- }
-
- if (StringUtils.isEmpty(connectionName)) {
- return Async.completeExceptionally(new IllegalArgumentException("connectionName"));
- }
-
- return createOAuthClient(context, null).thenCompose(oAuthClient -> {
- try {
- Activity activity = context.getActivity();
- String appId = getBotAppId(context);
-
- TokenExchangeState tokenExchangeState = new TokenExchangeState() {
- {
- setConnectionName(connectionName);
- setConversation(new ConversationReference() {
- {
- setActivityId(activity.getId());
- setBot(activity.getRecipient());
- setChannelId(activity.getChannelId());
- setConversation(activity.getConversation());
- setServiceUrl(activity.getServiceUrl());
- setUser(activity.getFrom());
- }
- });
- setMsAppId(appId);
- setRelatesTo(activity.getRelatesTo());
- }
- };
-
- String serializedState = Serialization.toString(tokenExchangeState);
- String state = Base64.getEncoder()
- .encodeToString(serializedState.getBytes(StandardCharsets.UTF_8));
-
- return oAuthClient.getBotSignIn().getSignInUrl(state);
- } catch (Throwable t) {
- throw new CompletionException(t);
- }
- });
+ public CompletableFuture getOAuthSignInLink(TurnContext context, String connectionName) {
+ return getOAuthSignInLink(context, null, connectionName);
}
/**
@@ -999,54 +867,9 @@ public CompletableFuture getOauthSignInLink(
* @return A task that represents the work queued to execute.
*/
@Override
- public CompletableFuture getOauthSignInLink(
- TurnContext context,
- String connectionName,
- String userId,
- String finalRedirect
- ) {
- if (context == null) {
- return Async.completeExceptionally(new IllegalArgumentException("TurnContext"));
- }
- if (StringUtils.isEmpty(connectionName)) {
- return Async.completeExceptionally(new IllegalArgumentException("connectionName"));
- }
- if (StringUtils.isEmpty(userId)) {
- return Async.completeExceptionally(new IllegalArgumentException("userId"));
- }
-
- return createOAuthClient(context, null).thenCompose(oAuthClient -> {
- try {
- Activity activity = context.getActivity();
- String appId = getBotAppId(context);
-
- TokenExchangeState tokenExchangeState = new TokenExchangeState() {
- {
- setConnectionName(connectionName);
- setConversation(new ConversationReference() {
- {
- setActivityId(activity.getId());
- setBot(activity.getRecipient());
- setChannelId(activity.getChannelId());
- setConversation(activity.getConversation());
- setServiceUrl(activity.getServiceUrl());
- setUser(activity.getFrom());
- }
- });
- setRelatesTo(activity.getRelatesTo());
- setMsAppId(appId);
- }
- };
-
- String serializedState = Serialization.toString(tokenExchangeState);
- String state = Base64.getEncoder()
- .encodeToString(serializedState.getBytes(StandardCharsets.UTF_8));
-
- return oAuthClient.getBotSignIn().getSignInUrl(state);
- } catch (Throwable t) {
- throw new CompletionException(t);
- }
- });
+ public CompletableFuture getOAuthSignInLink(TurnContext context, String connectionName, String userId,
+ String finalRedirect) {
+ return getOAuthSignInLink(context, null, connectionName, userId, finalRedirect);
}
/**
@@ -1058,25 +881,8 @@ public CompletableFuture getOauthSignInLink(
* @return A task that represents the work queued to execute.
*/
@Override
- public CompletableFuture signOutUser(
- TurnContext context,
- String connectionName,
- String userId
- ) {
- if (context == null) {
- return Async.completeExceptionally(new IllegalArgumentException("TurnContext"));
- }
- if (StringUtils.isEmpty(connectionName)) {
- return Async.completeExceptionally(new IllegalArgumentException("connectionName"));
- }
-
- return createOAuthClient(context, null).thenCompose(oAuthClient -> {
- return oAuthClient.getUserToken()
- .signOut(
- context.getActivity().getFrom().getId(), connectionName,
- context.getActivity().getChannelId()
- );
- }).thenApply(signOutResult -> null);
+ public CompletableFuture signOutUser(TurnContext context, String connectionName, String userId) {
+ return signOutUser(context, null, connectionName, userId);
}
/**
@@ -1091,22 +897,9 @@ public CompletableFuture signOutUser(
* @return Array of {@link TokenStatus}.
*/
@Override
- public CompletableFuture> getTokenStatus(
- TurnContext context,
- String userId,
- String includeFilter
- ) {
- if (context == null) {
- return Async.completeExceptionally(new IllegalArgumentException("TurnContext"));
- }
- if (StringUtils.isEmpty(userId)) {
- return Async.completeExceptionally(new IllegalArgumentException("userId"));
- }
-
- return createOAuthClient(context, null).thenCompose(oAuthClient -> {
- return oAuthClient.getUserToken()
- .getTokenStatus(userId, context.getActivity().getChannelId(), includeFilter);
- });
+ public CompletableFuture> getTokenStatus(TurnContext context, String userId,
+ String includeFilter) {
+ return getTokenStatus(context, null, userId, includeFilter);
}
/**
@@ -1124,34 +917,9 @@ public CompletableFuture> getTokenStatus(
* @return Map of resourceUrl to the corresponding {@link TokenResponse}.
*/
@Override
- public CompletableFuture