// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. package com.microsoft.aad.msal4j; import java.net.URI; import java.util.Map; import java.util.Set; import static com.microsoft.aad.msal4j.ParameterValidationUtils.validateNotNull; /** * Object containing parameters for interactive requests. Can be used as parameter to * {@link PublicClientApplication#acquireToken(InteractiveRequestParameters)}. *
* For more details, see https://aka.ms/msal4j-interactive-request.
*/
public class InteractiveRequestParameters implements IAcquireTokenParameters {
private URI redirectUri;
private ClaimsRequest claims;
private Set
* For more information, see {@link PopParameters} and https://aka.ms/msal4j-pop
*
* @param httpMethod a valid HTTP method, such as "GET" or "POST"
* @param uri the URI on the downstream protected API which the application is trying to access, e.g. https://graph.microsoft.com/beta/me/profile
* @param nonce a string obtained by calling the resource (e.g. Microsoft Graph) un-authenticated and parsing the WWW-Authenticate header associated with pop authentication scheme and extracting the nonce parameter, or, on subsequent calls, by parsing the Autheticate-Info header and extracting the nextnonce parameter.
*/
public InteractiveRequestParametersBuilder proofOfPossession(HttpMethod httpMethod, URI uri, String nonce) {
this.proofOfPossession = new PopParameters(httpMethod, uri, nonce);
return this;
}
/**
* Redirect URI where MSAL will listen to for the authorization code returned by Azure AD.
* Should be a loopback address with a port specified (for example, http://localhost:3671). If no
* port is specified, MSAL will find an open port. For more information, see
* https://aka.ms/msal4j-interactive-request.
*
* Cannot be null.
*/
public InteractiveRequestParametersBuilder redirectUri(URI redirectUri) {
validateNotNull("redirectUri", redirectUri);
this.redirectUri = redirectUri;
return this;
}
/**
* Claims to be requested through the OIDC claims request parameter, allowing requests for standard and custom claims
*/
public InteractiveRequestParametersBuilder claims(ClaimsRequest claims) {
this.claims = claims;
return this;
}
/**
* Scopes that the application is requesting access to and the user will consent to.
*/
public InteractiveRequestParametersBuilder scopes(Set
* If this timeout is set to 0 or less it will be ignored, and the library will use a 1-second timeout instead
*/
public InteractiveRequestParametersBuilder httpPollingTimeoutInSeconds(int httpPollingTimeoutInSeconds) {
this.httpPollingTimeoutInSeconds = httpPollingTimeoutInSeconds;
return this;
}
/**
* If set to true, the authorization result will contain the authority for the user's home cloud, and this authority
* will be used for the token request instead of the authority set in the application.
*/
public InteractiveRequestParametersBuilder instanceAware(boolean instanceAware) {
this.instanceAware = instanceAware;
return this;
}
/**
* The parent window handle used to open UI elements with the correct parent
*
* For browser scenarios and Windows console applications, this value should not need to be set
*
* For Windows console applications, MSAL Java will attempt to discover the console's window handle if this parameter is not set
*
* For scenarios where MSAL Java is responsible for opening UI elements (such as when using MSALRuntime), this parameter is required and an exception will be thrown if not set
*/
public InteractiveRequestParametersBuilder windowHandle(long windowHandle) {
this.windowHandle = windowHandle;
return this;
}
public InteractiveRequestParameters build() {
return new InteractiveRequestParameters(this.redirectUri, this.claims, this.scopes, this.prompt, this.loginHint, this.domainHint, this.systemBrowserOptions, this.claimsChallenge, this.extraHttpHeaders, this.extraQueryParameters, this.tenant, this.httpPollingTimeoutInSeconds, this.instanceAware, this.windowHandle, this.proofOfPossession);
}
public String toString() {
return "InteractiveRequestParameters.InteractiveRequestParametersBuilder(redirectUri=" + this.redirectUri + ", claims=" + this.claims + ", scopes=" + this.scopes + ", prompt=" + this.prompt + ", loginHint=" + this.loginHint + ", domainHint=" + this.domainHint + ", systemBrowserOptions=" + this.systemBrowserOptions + ", claimsChallenge=" + this.claimsChallenge + ", extraHttpHeaders=" + this.extraHttpHeaders + ", extraQueryParameters=" + this.extraQueryParameters + ", tenant=" + this.tenant + ", httpPollingTimeoutInSeconds=" + this.httpPollingTimeoutInSeconds + ", instanceAware=" + this.instanceAware + ", windowHandle=" + this.windowHandle + ", proofOfPossession=" + this.proofOfPossession + ")";
}
}
}