IBroker Interface

public interface IBroker

Used to define the basic set of methods that all Brokers must implement

All methods are marked as default so they can be referenced by MSAL Java without an implementation, and most will simply throw an exception if not overridden by an IBroker implementation

Method Summary

Modifier and Type Method and Description
default java.util.concurrent.CompletableFuture<IAuthenticationResult> acquireToken(PublicClientApplication application, InteractiveRequestParameters parameters)

Acquire a token interactively, by prompting users to enter their credentials in some way

default java.util.concurrent.CompletableFuture<IAuthenticationResult> acquireToken(PublicClientApplication application, SilentParameters requestParameters)

Acquire a token silently, i.e.

default java.util.concurrent.CompletableFuture<IAuthenticationResult> acquireToken(PublicClientApplication application, UserNamePasswordParameters parameters)

Acquire a token silently, i.e.

default boolean isBrokerAvailable()

Returns whether a broker is available and ready to use on this machine, allowing the use of the methods in this interface and other broker-only features in MSAL Java

default IAuthenticationResult parseBrokerAuthResult(String authority, String idToken, String accessToken, String accountId, String clientInfo, long accessTokenExpirationTime, boolean isPopAuthorization)

MSAL Java's AuthenticationResult requires several package-private classes that a broker implementation can't access, so this helper method can be used to create AuthenticationResults from within the MSAL Java package

default void removeAccount(PublicClientApplication application, IAccount account)

Method Details

acquireToken

public default CompletableFuture acquireToken(PublicClientApplication application, InteractiveRequestParameters parameters)

Acquire a token interactively, by prompting users to enter their credentials in some way

Parameters:

application
parameters

acquireToken

public default CompletableFuture acquireToken(PublicClientApplication application, SilentParameters requestParameters)

Acquire a token silently, i.e. without direct user interaction

This may be accomplished by returning tokens from a token cache, using cached refresh tokens to get new tokens, or via any authentication flow where a user is not prompted to enter credentials

Parameters:

application
requestParameters

acquireToken

public default CompletableFuture acquireToken(PublicClientApplication application, UserNamePasswordParameters parameters)

Acquire a token silently, i.e. without direct user interaction, using username/password authentication

Parameters:

application
parameters

isBrokerAvailable

public default boolean isBrokerAvailable()

Returns whether a broker is available and ready to use on this machine, allowing the use of the methods in this interface and other broker-only features in MSAL Java

parseBrokerAuthResult

public default IAuthenticationResult parseBrokerAuthResult(String authority, String idToken, String accessToken, String accountId, String clientInfo, long accessTokenExpirationTime, boolean isPopAuthorization)

MSAL Java's AuthenticationResult requires several package-private classes that a broker implementation can't access, so this helper method can be used to create AuthenticationResults from within the MSAL Java package

Parameters:

authority
idToken
accessToken
accountId
clientInfo
accessTokenExpirationTime
isPopAuthorization

removeAccount

public default void removeAccount(PublicClientApplication application, IAccount account)

Parameters:

application
account

Throws:

Applies to