File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
main/java/com/microsoft/aad/msal4j
test/java/com/microsoft/aad/msal4j Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,12 @@ public CompletableFuture<IAuthenticationResult> acquireToken(IntegratedWindowsAu
5555 @ Override
5656 public CompletableFuture <IAuthenticationResult > acquireToken (DeviceCodeFlowParameters parameters ) {
5757
58+ if (!(AuthorityType .AAD .equals (authenticationAuthority .authorityType ()) ||
59+ AuthorityType .ADFS .equals (authenticationAuthority .authorityType ()))) {
60+ throw new IllegalArgumentException (
61+ "Invalid authority type. Device Flow is only supported by AAD and ADFS authority" );
62+ }
63+
5864 validateNotNull ("parameters" , parameters );
5965
6066 AtomicReference <CompletableFuture <IAuthenticationResult >> futureReference =
Original file line number Diff line number Diff line change @@ -149,6 +149,21 @@ public void deviceCodeFlowTest() throws Exception {
149149 PowerMock .verify ();
150150 }
151151
152+ @ Test (expectedExceptions = IllegalArgumentException .class ,
153+ expectedExceptionsMessageRegExp = "Invalid authority type. Device Flow is only supported by AAD and ADFS authority" )
154+ public void executeAcquireDeviceCode_B2CAuthorityUsed_IllegalArgumentExceptionThrown ()
155+ throws Exception {
156+
157+ app = PublicClientApplication .builder ("client_id" )
158+ .b2cAuthority (TestConfiguration .B2C_AUTHORITY )
159+ .validateAuthority (false ).build ();
160+
161+ app .acquireToken
162+ (DeviceCodeFlowParameters
163+ .builder (Collections .singleton (AAD_RESOURCE_ID ), (DeviceCode deviceCode ) -> {})
164+ .build ());
165+ }
166+
152167 @ Test
153168 public void executeAcquireDeviceCode_AuthenticaionPendingErrorReturned_AuthenticationExceptionThrown ()
154169 throws Exception {
You can’t perform that action at this time.
0 commit comments