com.microsoft.aad.msal4j.UserNamePasswordParameters Maven / Gradle / Ivy
Show all versions of com.liferay.mail.outlook.auth.connector.provider
// Generated by delombok at Mon Apr 17 18:26:07 UTC 2023
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.microsoft.aad.msal4j;
import lombok.*;
import java.util.Map;
import java.util.Set;
import static com.microsoft.aad.msal4j.ParameterValidationUtils.validateNotBlank;
import static com.microsoft.aad.msal4j.ParameterValidationUtils.validateNotEmpty;
import static com.microsoft.aad.msal4j.ParameterValidationUtils.validateNotNull;
/**
* Object containing parameters for Username/Password flow. Can be used as parameter to
* {@link PublicClientApplication#acquireToken(UserNamePasswordParameters)}
*
* For more details, see https://aka.ms/msal4j-username-password
*/
public class UserNamePasswordParameters implements IAcquireTokenParameters {
/**
* Scopes application is requesting access to
*/
@NonNull
private Set scopes;
/**
* Username of the account
*/
@NonNull
private String username;
/**
* Char array containing credentials for the username
*/
@NonNull
private char[] password;
/**
* Claims to be requested through the OIDC claims request parameter, allowing requests for standard and custom claims
*/
private ClaimsRequest claims;
/**
* Adds additional headers to the token request
*/
private Map extraHttpHeaders;
/**
* Adds additional query parameters to the token request
*/
private Map extraQueryParameters;
/**
* Overrides the tenant value in the authority URL for this request
*/
private String tenant;
public char[] password() {
return password.clone();
}
private static UserNamePasswordParametersBuilder builder() {
return new UserNamePasswordParametersBuilder();
}
/**
* Builder for UserNameParameters
*
* @param scopes scopes application is requesting access to
* @param username username of the account
* @param password char array containing credentials for the username
* @return builder object that can be used to construct UserNameParameters
*/
public static UserNamePasswordParametersBuilder builder(Set scopes, String username, char[] password) {
validateNotNull("scopes", scopes);
validateNotBlank("username", username);
validateNotEmpty("password", password);
return builder().scopes(scopes).username(username).password(password);
}
public static class UserNamePasswordParametersBuilder {
@java.lang.SuppressWarnings("all")
private Set scopes;
@java.lang.SuppressWarnings("all")
private String username;
@java.lang.SuppressWarnings("all")
private char[] password;
@java.lang.SuppressWarnings("all")
private ClaimsRequest claims;
@java.lang.SuppressWarnings("all")
private Map extraHttpHeaders;
@java.lang.SuppressWarnings("all")
private Map extraQueryParameters;
@java.lang.SuppressWarnings("all")
private String tenant;
public UserNamePasswordParametersBuilder password(char[] password) {
this.password = password.clone();
return this;
}
@java.lang.SuppressWarnings("all")
UserNamePasswordParametersBuilder() {
}
@java.lang.SuppressWarnings("all")
public UserNamePasswordParametersBuilder scopes(final Set scopes) {
this.scopes = scopes;
return this;
}
@java.lang.SuppressWarnings("all")
public UserNamePasswordParametersBuilder username(final String username) {
this.username = username;
return this;
}
@java.lang.SuppressWarnings("all")
public UserNamePasswordParametersBuilder claims(final ClaimsRequest claims) {
this.claims = claims;
return this;
}
@java.lang.SuppressWarnings("all")
public UserNamePasswordParametersBuilder extraHttpHeaders(final Map extraHttpHeaders) {
this.extraHttpHeaders = extraHttpHeaders;
return this;
}
@java.lang.SuppressWarnings("all")
public UserNamePasswordParametersBuilder extraQueryParameters(final Map extraQueryParameters) {
this.extraQueryParameters = extraQueryParameters;
return this;
}
@java.lang.SuppressWarnings("all")
public UserNamePasswordParametersBuilder tenant(final String tenant) {
this.tenant = tenant;
return this;
}
@java.lang.SuppressWarnings("all")
public UserNamePasswordParameters build() {
return new UserNamePasswordParameters(scopes, username, password, claims, extraHttpHeaders, extraQueryParameters, tenant);
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public java.lang.String toString() {
return "UserNamePasswordParameters.UserNamePasswordParametersBuilder(scopes=" + this.scopes + ", username=" + this.username + ", password=" + java.util.Arrays.toString(this.password) + ", claims=" + this.claims + ", extraHttpHeaders=" + this.extraHttpHeaders + ", extraQueryParameters=" + this.extraQueryParameters + ", tenant=" + this.tenant + ")";
}
}
/**
* Scopes application is requesting access to
*/
@NonNull
@java.lang.SuppressWarnings("all")
public Set scopes() {
return this.scopes;
}
/**
* Username of the account
*/
@NonNull
@java.lang.SuppressWarnings("all")
public String username() {
return this.username;
}
/**
* Claims to be requested through the OIDC claims request parameter, allowing requests for standard and custom claims
*/
@java.lang.SuppressWarnings("all")
public ClaimsRequest claims() {
return this.claims;
}
/**
* Adds additional headers to the token request
*/
@java.lang.SuppressWarnings("all")
public Map extraHttpHeaders() {
return this.extraHttpHeaders;
}
/**
* Adds additional query parameters to the token request
*/
@java.lang.SuppressWarnings("all")
public Map extraQueryParameters() {
return this.extraQueryParameters;
}
/**
* Overrides the tenant value in the authority URL for this request
*/
@java.lang.SuppressWarnings("all")
public String tenant() {
return this.tenant;
}
@java.lang.SuppressWarnings("all")
private UserNamePasswordParameters(@NonNull final Set scopes, @NonNull final String username, @NonNull final char[] password, final ClaimsRequest claims, final Map extraHttpHeaders, final Map extraQueryParameters, final String tenant) {
if (scopes == null) {
throw new java.lang.NullPointerException("scopes is marked @NonNull but is null");
}
if (username == null) {
throw new java.lang.NullPointerException("username is marked @NonNull but is null");
}
if (password == null) {
throw new java.lang.NullPointerException("password is marked @NonNull but is null");
}
this.scopes = scopes;
this.username = username;
this.password = password;
this.claims = claims;
this.extraHttpHeaders = extraHttpHeaders;
this.extraQueryParameters = extraQueryParameters;
this.tenant = tenant;
}
}