Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class TokenCommandParameters extends CommandParameters {

private final String loginHint;

private final String domainHint;

private final List<Map.Entry<String, String>> extraOptions;

public Set<String> getScopes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ private void setBuilderProperties(@SuppressWarnings(WarningType.rawtype_warning)
final MicrosoftStsAuthorizationRequest.Builder msBuilder = (MicrosoftStsAuthorizationRequest.Builder) builder;
msBuilder
.setLoginHint(interactiveTokenCommandParameters.getLoginHint())
.setDomainHint(interactiveTokenCommandParameters.getDomainHint())
.setPrompt(interactiveTokenCommandParameters.getPrompt().toString())
.setPreferredAuthMethod(interactiveTokenCommandParameters.getPreferredAuthMethod());
final String installedCompanyPortalVersion =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ public abstract class MicrosoftAuthorizationRequest<T extends MicrosoftAuthoriza
@SerializedName("login_hint")
private final String mLoginHint;

/**
* Provides a hint about the tenant or domain that the user should use to sign in.
*/
@Getter
@Accessors(prefix = "m")
@SerializedName("domain_hint")
private final String mDomainHint;

/**
* Correlation ID.
*/
Expand Down Expand Up @@ -168,6 +176,7 @@ protected MicrosoftAuthorizationRequest(@SuppressWarnings(WarningType.rawtype_wa
super(builder);
mAuthority = builder.mAuthority;
mLoginHint = builder.mLoginHint;
mDomainHint = builder.mDomainHint;
mCorrelationId = builder.mCorrelationId;

final PkceChallenge challenge = builder.mPkceChallenge == null ?
Expand Down Expand Up @@ -217,6 +226,7 @@ public abstract static class Builder<B extends MicrosoftAuthorizationRequest.Bui
private Boolean mMultipleCloudAware;
private UUID mCorrelationId;
private String mLoginHint;
private String mDomainHint;
private PkceChallenge mPkceChallenge;
private PreferredAuthMethod mPreferredAuthMethod;

Expand Down Expand Up @@ -254,6 +264,11 @@ public B setLoginHint(String loginHint) {
return self();
}

public B setDomainHint(String domainHint) {
mDomainHint = domainHint;
return self();
}

public B setPreferredAuthMethod(@Nullable final PreferredAuthMethod preferredAuthMethod) {
mPreferredAuthMethod = preferredAuthMethod;
return self();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void tearDown() {
public static final boolean MOCK_MULTIPLE_CLOUD_AWARE = true;
public static final UUID MOCK_CORRELATION_ID = UUID.randomUUID();
public static final String MOCK_LOGIN_HINT = "MOCK_LOGIN_HINT";
public static final String MOCK_DOMAIN_HINT = "MOCK_DOMAIN_HINT";

// Check that we're not sending anything unexpected to the server side
// by comparing the resulted URL by-character.
Expand All @@ -74,13 +75,15 @@ public void testCreateUriFromAuthorizationRequest() throws MalformedURLException
.setMultipleCloudAware(MOCK_MULTIPLE_CLOUD_AWARE)
.setCorrelationId(MOCK_CORRELATION_ID)
.setLoginHint(MOCK_LOGIN_HINT)
.setDomainHint(MOCK_DOMAIN_HINT)
.setPkceChallenge(MOCK_PKCE_CHALLENGE)
.setState(MOCK_STATE)
.build();

if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_AM_API_WORKPROFILE_EXTRA_QUERY_PARAMETERS)) {
Assert.assertEquals(MockAuthorizationRequest.MOCK_AUTH_ENDPOINT +
"?login_hint=" + MOCK_LOGIN_HINT +
"&domain_hint=" + MOCK_DOMAIN_HINT +
"&client-request-id=" + MOCK_CORRELATION_ID +
"&code_challenge=" + MOCK_PKCE_CHALLENGE.getCodeChallenge() +
"&code_challenge_method=" + MOCK_PKCE_CHALLENGE.getCodeChallengeMethod() +
Expand All @@ -100,6 +103,7 @@ public void testCreateUriFromAuthorizationRequest() throws MalformedURLException
} else {
Assert.assertEquals(MockAuthorizationRequest.MOCK_AUTH_ENDPOINT +
"?login_hint=" + MOCK_LOGIN_HINT +
"&domain_hint=" + MOCK_DOMAIN_HINT +
"&client-request-id=" + MOCK_CORRELATION_ID +
"&code_challenge=" + MOCK_PKCE_CHALLENGE.getCodeChallenge() +
"&code_challenge_method=" + MOCK_PKCE_CHALLENGE.getCodeChallengeMethod() +
Expand Down Expand Up @@ -129,13 +133,15 @@ public void testCreateUriFromAuthorizationRequestWithWPAvailable() throws Malfor
.setMultipleCloudAware(MOCK_MULTIPLE_CLOUD_AWARE)
.setCorrelationId(MOCK_CORRELATION_ID)
.setLoginHint(MOCK_LOGIN_HINT)
.setDomainHint(MOCK_DOMAIN_HINT)
.setPkceChallenge(MOCK_PKCE_CHALLENGE)
.setState(MOCK_STATE)
.build();

if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_AM_API_WORKPROFILE_EXTRA_QUERY_PARAMETERS)) {
Assert.assertEquals(MockAuthorizationRequest.MOCK_AUTH_ENDPOINT +
"?login_hint=" + MOCK_LOGIN_HINT +
"&domain_hint=" + MOCK_DOMAIN_HINT +
"&client-request-id=" + MOCK_CORRELATION_ID +
"&code_challenge=" + MOCK_PKCE_CHALLENGE.getCodeChallenge() +
"&code_challenge_method=" + MOCK_PKCE_CHALLENGE.getCodeChallengeMethod() +
Expand All @@ -155,6 +161,7 @@ public void testCreateUriFromAuthorizationRequestWithWPAvailable() throws Malfor
} else {
Assert.assertEquals(MockAuthorizationRequest.MOCK_AUTH_ENDPOINT +
"?login_hint=" + MOCK_LOGIN_HINT +
"&domain_hint=" + MOCK_DOMAIN_HINT +
"&client-request-id=" + MOCK_CORRELATION_ID +
"&code_challenge=" + MOCK_PKCE_CHALLENGE.getCodeChallenge() +
"&code_challenge_method=" + MOCK_PKCE_CHALLENGE.getCodeChallengeMethod() +
Expand Down
Loading