33
44package com .microsoft .bot .builder ;
55
6+ import com .microsoft .bot .connector .authentication .AppCredentials ;
7+ import com .microsoft .bot .schema .SignInResource ;
8+ import com .microsoft .bot .schema .TokenExchangeRequest ;
69import com .microsoft .bot .schema .TokenResponse ;
710import com .microsoft .bot .schema .TokenStatus ;
811
@@ -39,7 +42,7 @@ CompletableFuture<TokenResponse> getUserToken(
3942 * @return A task that represents the work queued to execute. If the task
4043 * completes successfully, the result contains the raw signin link.
4144 */
42- CompletableFuture <String > getOauthSignInLink (TurnContext turnContext , String connectionName );
45+ CompletableFuture <String > getOAuthSignInLink (TurnContext turnContext , String connectionName );
4346
4447 /**
4548 * Get the raw signin link to be sent to the user for signin for a connection
@@ -53,7 +56,7 @@ CompletableFuture<TokenResponse> getUserToken(
5356 * @return A task that represents the work queued to execute. If the task
5457 * completes successfully, the result contains the raw signin link.
5558 */
56- CompletableFuture <String > getOauthSignInLink (
59+ CompletableFuture <String > getOAuthSignInLink (
5760 TurnContext turnContext ,
5861 String connectionName ,
5962 String userId ,
@@ -156,4 +159,237 @@ CompletableFuture<Map<String, TokenResponse>> getAadTokens(
156159 String [] resourceUrls ,
157160 String userId
158161 );
162+
163+
164+ /**
165+ * Attempts to retrieve the token for a user that's in a login flow, using
166+ * customized AppCredentials.
167+ *
168+ * @param turnContext Context for the current turn of
169+ * conversation with the user.
170+ * @param oAuthAppCredentials AppCredentials for OAuth.
171+ * @param connectionName Name of the auth connection to use.
172+ * @param magicCode (Optional) Optional user entered code
173+ * to validate.
174+ *
175+ * @return Token Response.
176+ */
177+ CompletableFuture <TokenResponse > getUserToken (
178+ TurnContext turnContext ,
179+ AppCredentials oAuthAppCredentials ,
180+ String connectionName ,
181+ String magicCode );
182+
183+ /**
184+ * Get the raw signin link to be sent to the user for signin for a
185+ * connection name, using customized AppCredentials.
186+ *
187+ * @param turnContext Context for the current turn of
188+ * conversation with the user.
189+ * @param oAuthAppCredentials AppCredentials for OAuth.
190+ * @param connectionName Name of the auth connection to use.
191+ *
192+ * @return A CompletableFuture that represents the work queued to execute.
193+ *
194+ * If the CompletableFuture completes successfully, the result contains the raw signin
195+ * link.
196+ */
197+ CompletableFuture <String > getOAuthSignInLink (
198+ TurnContext turnContext ,
199+ AppCredentials oAuthAppCredentials ,
200+ String connectionName );
201+
202+ /**
203+ * Get the raw signin link to be sent to the user for signin for a
204+ * connection name, using customized AppCredentials.
205+ *
206+ * @param turnContext Context for the current turn of
207+ * conversation with the user.
208+ * @param oAuthAppCredentials AppCredentials for OAuth.
209+ * @param connectionName Name of the auth connection to use.
210+ * @param userId The user id that will be associated
211+ * with the token.
212+ * @param finalRedirect The final URL that the OAuth flow
213+ * will redirect to.
214+ *
215+ * @return A CompletableFuture that represents the work queued to execute.
216+ *
217+ * If the CompletableFuture completes successfully, the result contains the raw signin
218+ * link.
219+ */
220+ CompletableFuture <String > getOAuthSignInLink (
221+ TurnContext turnContext ,
222+ AppCredentials oAuthAppCredentials ,
223+ String connectionName ,
224+ String userId ,
225+ String finalRedirect );
226+
227+ /**
228+ * Signs the user out with the token server, using customized
229+ * AppCredentials.
230+ *
231+ * @param turnContext Context for the current turn of
232+ * conversation with the user.
233+ * @param oAuthAppCredentials AppCredentials for OAuth.
234+ * @param connectionName Name of the auth connection to use.
235+ * @param userId User id of user to sign out.
236+ *
237+ * @return A CompletableFuture that represents the work queued to execute.
238+ */
239+ CompletableFuture <Void > signOutUser (
240+ TurnContext turnContext ,
241+ AppCredentials oAuthAppCredentials ,
242+ String connectionName ,
243+ String userId );
244+
245+ /**
246+ * Retrieves the token status for each configured connection for the given
247+ * user, using customized AppCredentials.
248+ *
249+ * @param context Context for the current turn of
250+ * conversation with the user.
251+ * @param oAuthAppCredentials AppCredentials for OAuth.
252+ * @param userId The user Id for which token status is
253+ * retrieved.
254+ * @param includeFilter Optional comma separated list of
255+ * connection's to include. Blank will return token status for all
256+ * configured connections.
257+ *
258+ * @return Array of TokenStatus.
259+ */
260+ CompletableFuture <List <TokenStatus >> getTokenStatus (
261+ TurnContext context ,
262+ AppCredentials oAuthAppCredentials ,
263+ String userId ,
264+ String includeFilter );
265+
266+ /**
267+ * Retrieves Azure Active Directory tokens for particular resources on a
268+ * configured connection, using customized AppCredentials.
269+ *
270+ * @param context Context for the current turn of
271+ * conversation with the user.
272+ * @param oAuthAppCredentials AppCredentials for OAuth.
273+ * @param connectionName The name of the Azure Active
274+ * Directory connection configured with this bot.
275+ * @param resourceUrls The list of resource URLs to retrieve
276+ * tokens for.
277+ * @param userId The user Id for which tokens are
278+ * retrieved. If passing in null the userId is taken from the Activity in
279+ * the TurnContext.
280+ *
281+ * @return Dictionary of resourceUrl to the corresponding
282+ * TokenResponse.
283+ */
284+ CompletableFuture <Map <String , TokenResponse >> getAadTokens (
285+ TurnContext context ,
286+ AppCredentials oAuthAppCredentials ,
287+ String connectionName ,
288+ String [] resourceUrls ,
289+ String userId );
290+
291+ /**
292+ * Get the raw signin link to be sent to the user for signin for a
293+ * connection name.
294+ *
295+ * @param turnContext Context for the current turn of
296+ * conversation with the user.
297+ * @param connectionName Name of the auth connection to use.
298+ *
299+ * @return A CompletableFuture that represents the work queued to execute.
300+ *
301+ * If the CompletableFuture completes successfully, the result contains the raw signin
302+ * link.
303+ */
304+ CompletableFuture <SignInResource > getSignInResource (
305+ TurnContext turnContext ,
306+ String connectionName );
307+
308+ /**
309+ * Get the raw signin link to be sent to the user for signin for a
310+ * connection name.
311+ *
312+ * @param turnContext Context for the current turn of
313+ * conversation with the user.
314+ * @param connectionName Name of the auth connection to use.
315+ * @param userId The user id that will be associated with
316+ * the token.
317+ * @param finalRedirect The final URL that the OAuth flow will
318+ * redirect to.
319+ *
320+ * @return A CompletableFuture that represents the work queued to execute.
321+ *
322+ * If the CompletableFuture completes successfully, the result contains the raw signin
323+ * link.
324+ */
325+ CompletableFuture <SignInResource > getSignInResource (
326+ TurnContext turnContext ,
327+ String connectionName ,
328+ String userId ,
329+ String finalRedirect );
330+
331+ /**
332+ * Get the raw signin link to be sent to the user for signin for a
333+ * connection name.
334+ *
335+ * @param turnContext Context for the current turn of
336+ * conversation with the user.
337+ * @param oAuthAppCredentials Credentials for OAuth.
338+ * @param connectionName Name of the auth connection to use.
339+ * @param userId The user id that will be associated
340+ * with the token.
341+ * @param finalRedirect The final URL that the OAuth flow
342+ * will redirect to.
343+ *
344+ * @return A CompletableFuture that represents the work queued to execute.
345+ *
346+ * If the CompletableFuture completes successfully, the result contains the raw signin
347+ * link.
348+ */
349+ CompletableFuture <SignInResource > getSignInResource (
350+ TurnContext turnContext ,
351+ AppCredentials oAuthAppCredentials ,
352+ String connectionName ,
353+ String userId ,
354+ String finalRedirect );
355+
356+ /**
357+ * Performs a token exchange operation such as for single sign-on.
358+ *
359+ * @param turnContext Context for the current turn of
360+ * conversation with the user.
361+ * @param connectionName Name of the auth connection to use.
362+ * @param userId The user id associated with the token..
363+ * @param exchangeRequest The exchange request details, either a
364+ * token to exchange or a uri to exchange.
365+ *
366+ * @return If the CompletableFuture completes, the exchanged token is returned.
367+ */
368+ CompletableFuture <TokenResponse > exchangeToken (
369+ TurnContext turnContext ,
370+ String connectionName ,
371+ String userId ,
372+ TokenExchangeRequest exchangeRequest );
373+
374+ /**
375+ * Performs a token exchange operation such as for single sign-on.
376+ *
377+ * @param turnContext Context for the current turn of
378+ * conversation with the user.
379+ * @param oAuthAppCredentials AppCredentials for OAuth.
380+ * @param connectionName Name of the auth connection to use.
381+ * @param userId The user id associated with the
382+ * token..
383+ * @param exchangeRequest The exchange request details, either
384+ * a token to exchange or a uri to exchange.
385+ *
386+ * @return If the CompletableFuture completes, the exchanged token is returned.
387+ */
388+ CompletableFuture <TokenResponse > exchangeToken (
389+ TurnContext turnContext ,
390+ AppCredentials oAuthAppCredentials ,
391+ String connectionName ,
392+ String userId ,
393+ TokenExchangeRequest exchangeRequest );
394+
159395}
0 commit comments