Skip to content

Remove Lombok #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -5,12 +5,6 @@

import java.net.URL;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.Accessors;

@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
class AADAuthority extends Authority {

private final static String TENANTLESS_TENANT_NAME = "common";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.Accessors;

import java.io.IOException;
import java.util.List;

@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
class AadInstanceDiscoveryResponse implements JsonSerializable<AadInstanceDiscoveryResponse> {

private String tenantDiscoveryEndpoint;
Expand Down Expand Up @@ -70,4 +65,28 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeEndObject();
return jsonWriter;
}

String tenantDiscoveryEndpoint() {
return this.tenantDiscoveryEndpoint;
}

List<InstanceDiscoveryMetadataEntry> metadata() {
return this.metadata;
}

String errorDescription() {
return this.errorDescription;
}

List<Long> errorCodes() {
return this.errorCodes;
}

String error() {
return this.error;
}

String correlationId() {
return this.correlationId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@

package com.microsoft.aad.msal4j;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.Accessors;
import org.slf4j.Logger;

import javax.net.ssl.SSLSocketFactory;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.function.Consumer;
Expand All @@ -30,63 +25,22 @@ public abstract class AbstractApplicationBase implements IApplicationBase {

protected Logger log;
protected Authority authenticationAuthority;

@Accessors(fluent = true)
@Getter
private String correlationId;

@Accessors(fluent = true)
@Getter
private boolean logPii;

@Accessors(fluent = true)
@Getter
private Proxy proxy;

@Accessors(fluent = true)
@Getter
private SSLSocketFactory sslSocketFactory;

@Accessors(fluent = true)
@Getter
private IHttpClient httpClient;

@Accessors(fluent = true)
@Getter
private Integer connectTimeoutForDefaultHttpClient;

@Accessors(fluent = true)
@Getter
private Integer readTimeoutForDefaultHttpClient;

@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
String tenant;

//The following fields are set in only some applications and/or set internally by the library. To avoid excessive
// type casting throughout the library they are defined here as package-private, but will not be part of this class's Builder
@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
private boolean validateAuthority;

@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
private String clientId;

@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
private String authority;

@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
ServiceBundle serviceBundle;

@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
Consumer<List<HashMap<String, String>>> telemetryConsumer;

@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
protected TokenCache tokenCache;

CompletableFuture<IAuthenticationResult> executeRequest(
Expand Down Expand Up @@ -168,6 +122,62 @@ private AuthenticationResultSupplier getAuthenticationResultSupplier(MsalRequest
return supplier;
}

public String correlationId() {
return this.correlationId;
}

public boolean logPii() {
return this.logPii;
}

public Proxy proxy() {
return this.proxy;
}

public SSLSocketFactory sslSocketFactory() {
return this.sslSocketFactory;
}

public IHttpClient httpClient() {
return this.httpClient;
}

public Integer connectTimeoutForDefaultHttpClient() {
return this.connectTimeoutForDefaultHttpClient;
}

public Integer readTimeoutForDefaultHttpClient() {
return this.readTimeoutForDefaultHttpClient;
}

String tenant() {
return this.tenant;
}

boolean validateAuthority() {
return this.validateAuthority;
}

String clientId() {
return this.clientId;
}

String authority() {
return this.authority;
}

ServiceBundle serviceBundle() {
return this.serviceBundle;
}

Consumer<List<HashMap<String, String>>> telemetryConsumer() {
return this.telemetryConsumer;
}

TokenCache tokenCache() {
return this.tokenCache;
}

public abstract static class Builder<T extends Builder<T>> {
// Optional parameters - initialized to default values
private String correlationId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package com.microsoft.aad.msal4j;

import com.nimbusds.oauth2.sdk.auth.ClientAuthentication;
import lombok.Getter;
import lombok.experimental.Accessors;

import javax.net.ssl.SSLSocketFactory;
import java.net.MalformedURLException;
Expand All @@ -25,46 +23,16 @@
*/
public abstract class AbstractClientApplicationBase extends AbstractApplicationBase implements IClientApplicationBase {

@Accessors(fluent = true)
@Getter
private String clientId;

@Accessors(fluent = true)
@Getter
private String authority;

@Accessors(fluent = true)
@Getter
private boolean validateAuthority;

@Accessors(fluent = true)
@Getter
private String applicationName;

@Accessors(fluent = true)
@Getter
private String applicationVersion;

@Accessors(fluent = true)
@Getter
private AadInstanceDiscoveryResponse aadAadInstanceDiscoveryResponse;

protected abstract ClientAuthentication clientAuthentication();

@Accessors(fluent = true)
@Getter
private String clientCapabilities;

@Accessors(fluent = true)
@Getter
private boolean autoDetectRegion;

@Accessors(fluent = true)
@Getter
protected String azureRegion;

@Accessors(fluent = true)
@Getter
private boolean instanceDiscovery;

@Override
Expand Down Expand Up @@ -187,6 +155,49 @@ public URL getAuthorizationRequestUrl(AuthorizationRequestUrlParameters paramete
parameters.requestParameters());
}

@Override
public String clientId() {
return this.clientId;
}

@Override
public String authority() {
return this.authority;
}

@Override
public boolean validateAuthority() {
return this.validateAuthority;
}

public String applicationName() {
return this.applicationName;
}

public String applicationVersion() {
return this.applicationVersion;
}

public AadInstanceDiscoveryResponse aadAadInstanceDiscoveryResponse() {
return this.aadAadInstanceDiscoveryResponse;
}

public String clientCapabilities() {
return this.clientCapabilities;
}

public boolean autoDetectRegion() {
return this.autoDetectRegion;
}

public String azureRegion() {
return this.azureRegion;
}

public boolean instanceDiscovery() {
return this.instanceDiscovery;
}

public abstract static class Builder<T extends Builder<T>> extends AbstractApplicationBase.Builder<T> {
// Required parameters
private String clientId;
Expand Down Expand Up @@ -253,11 +264,11 @@ public T authority(String val) throws MalformedURLException {

/**
* Set URL of the authenticating B2C authority from which MSAL will acquire tokens
*
* <p>
* Valid B2C authorities should look like: https://&lt;something.b2clogin.com/&lt;tenant&gt;/&lt;policy&gt;
*
* <p>
* MSAL Java also supports a legacy B2C authority format, which looks like: https://&lt;host&gt;/tfp/&lt;tenant&gt;/&lt;policy&gt;
*
* <p>
* However, MSAL Java will eventually stop supporting the legacy format. See here for information on how to migrate to the new format: https://aka.ms/msal4j-b2c
*
* @param val a boolean value for validateAuthority
Expand Down Expand Up @@ -393,10 +404,10 @@ public T clientCapabilities(Set<String> capabilities) {
* Indicates that the library should attempt to discover the Azure region the application is running in when
* fetching the instance discovery metadata. Regions can only be detected when running in an Azure environment,
* such as an Azure VM or other service, or if the environment has environment variable named REGION_NAME configured.
*
* <p>
* Although you can enable both autodetection here and a specific region with {@link AbstractClientApplicationBase#azureRegion} at the same time,
* the region set with {@link AbstractClientApplicationBase#azureRegion} will take priority if there is a mismatch.
*
* <p>
* See here for more information about supported scenarios: https://aka.ms/msal4j-azure-regions
*
* @param val boolean (default is false)
Expand All @@ -410,13 +421,13 @@ public T autoDetectRegion(boolean val) {
/**
* Set the region that the library will use to format authorities in token requests. If given a valid Azure region,
* the library will attempt to make token requests at a regional ESTS-R endpoint rather than the global ESTS endpoint.
*
* <p>
* Regions must be valid Azure regions and their short names should be used, such as 'westus' for the West US Azure region,
* 'centralus' for the Central US Azure region, etc.
*
* <p>
* Although you can set a specific region here and enable autodetection with {@link AbstractClientApplicationBase#autoDetectRegion} at the same time
* the specific region set here will take priority over the autodetected region if there is a mismatch.
*
* <p>
* See here for more information about supported scenarios: https://aka.ms/msal4j-azure-regions
*
* @param val String region name
Expand All @@ -427,13 +438,15 @@ public T azureRegion(String val) {
return self();
}

/** Historically, MSAL would connect to a central endpoint located at
``https://login.microsoftonline.com`` to acquire some metadata, especially when using an unfamiliar authority.
This behavior is known as Instance Discovery.
This parameter defaults to true, which enables the Instance Discovery.
If you do not know some authorities beforehand,
yet still want MSAL to accept any authority that you will provide,
you can use a ``False`` to unconditionally disable Instance Discovery. */
/**
* Historically, MSAL would connect to a central endpoint located at
* ``https://login.microsoftonline.com`` to acquire some metadata, especially when using an unfamiliar authority.
* This behavior is known as Instance Discovery.
* This parameter defaults to true, which enables the Instance Discovery.
* If you do not know some authorities beforehand,
* yet still want MSAL to accept any authority that you will provide,
* you can use a ``False`` to unconditionally disable Instance Discovery.
*/
public T instanceDiscovery(boolean val) {
isInstanceDiscoveryEnabled = val;
return self();
Expand Down
Loading