Class MicrosoftOAuth2DeviceCodeFlow
java.lang.Object
io.jmix.email.authentication.impl.AbstractOAuth2Flow
io.jmix.email.authentication.impl.MicrosoftOAuth2DeviceCodeFlow
- All Implemented Interfaces:
OAuth2DeviceCodeFlow
@NullMarked
public class MicrosoftOAuth2DeviceCodeFlow
extends AbstractOAuth2Flow
implements OAuth2DeviceCodeFlow
Device code flow for Microsoft accounts. Runs on a public client application with the same
client id, so the app registration must have "Allow public client flows" enabled.
-
Field Summary
FieldsFields inherited from class io.jmix.email.authentication.impl.AbstractOAuth2Flow
emailerProperties, refreshTokenManager -
Constructor Summary
ConstructorsConstructorDescriptionMicrosoftOAuth2DeviceCodeFlow(EmailerProperties emailerProperties, EmailRefreshTokenManager refreshTokenManager, SystemAuthenticator systemAuthenticator) -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletableFuture<com.microsoft.aad.msal4j.IAuthenticationResult> acquireDeviceCodeToken(RefreshTokenCapturingCacheAspect cacheAspect, Consumer<com.microsoft.aad.msal4j.DeviceCode> deviceCodeConsumer) protected voidawaitInitialization(CountDownLatch initLatch, OAuth2DeviceCodeSession session) protected Stringprotected voidcompleteSession(OAuth2DeviceCodeSession session, RefreshTokenCapturingCacheAspect cacheAspect) Stores the obtained refresh token.protected Stringprotected @Nullable StringgetCapturedRefreshToken(RefreshTokenCapturingCacheAspect cacheAspect) protected Stringprotected StringrootMessage(Throwable throwable) start()Starts the device code flow and returns a session carrying the user instructions (verification URI and user code).Methods inherited from class io.jmix.email.authentication.impl.AbstractOAuth2Flow
encodeForm, getClientId, getRequiredProperty, getSecret
-
Field Details
-
DEVICE_CODE_INIT_TIMEOUT_SEC
protected static final long DEVICE_CODE_INIT_TIMEOUT_SEC- See Also:
-
systemAuthenticator
-
-
Constructor Details
-
MicrosoftOAuth2DeviceCodeFlow
public MicrosoftOAuth2DeviceCodeFlow(EmailerProperties emailerProperties, EmailRefreshTokenManager refreshTokenManager, SystemAuthenticator systemAuthenticator)
-
-
Method Details
-
start
Description copied from interface:OAuth2DeviceCodeFlowStarts the device code flow and returns a session carrying the user instructions (verification URI and user code).The flow completes asynchronously — track it via
OAuth2DeviceCodeSession.getStatus(). On successful completion the obtained refresh token is stored viaEmailRefreshTokenManager.- Specified by:
startin interfaceOAuth2DeviceCodeFlow- Returns:
- started session
-
completeSession
protected void completeSession(OAuth2DeviceCodeSession session, RefreshTokenCapturingCacheAspect cacheAspect) Stores the obtained refresh token. Runs on an MSAL callback thread without a security context, so the token is stored under system authentication. -
acquireDeviceCodeToken
protected CompletableFuture<com.microsoft.aad.msal4j.IAuthenticationResult> acquireDeviceCodeToken(RefreshTokenCapturingCacheAspect cacheAspect, Consumer<com.microsoft.aad.msal4j.DeviceCode> deviceCodeConsumer) throws Exception - Throws:
Exception
-
awaitInitialization
-
rootMessage
-
getCapturedRefreshToken
-
getScopes
-
buildAuthorityUrl
-
getBaseAuthorityUrl
-
getTenant
-