Skip to content

Commit ed54407

Browse files
committed
Add/improve javadocs for interface classes
1 parent 3a4ed35 commit ed54407

15 files changed

+347
-61
lines changed

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/IAcquireTokenParameters.java

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,61 @@
77
import java.util.Set;
88

99
/**
10-
* Parameters shared by all acquireToken methods
10+
* Interface representing common parameters shared across all token acquisition methods in MSAL.
11+
* <p>
12+
* This interface defines the core parameters that are common to all token acquisition operations,
13+
* regardless of the specific authentication flow being used (interactive, silent, username/password, etc.).
14+
* Various parameter classes in the library implement this interface to provide a consistent way to
15+
* configure token requests.
1116
*/
1217
interface IAcquireTokenParameters {
18+
19+
/**
20+
* Gets the set of scopes (permissions) requested for the access token.
21+
* <p>
22+
* Scopes represent the permissions that the application is requesting access to.
23+
*
24+
* @return A set of scope strings being requested for the access token.
25+
*/
1326
Set<String> scopes();
1427

28+
/**
29+
* Gets the claims request parameter that will be sent with the authentication request.
30+
* <p>
31+
* The claims request parameter can be used to request specific claims to be returned in the token,
32+
* to request MFA authentication, or to control other aspects of token issuance.
33+
*
34+
* @return A {@link ClaimsRequest} object containing the requested claims, or null if no claims are specified.
35+
*/
1536
ClaimsRequest claims();
1637

38+
/**
39+
* Gets additional HTTP headers to be included in the token request.
40+
* <p>
41+
* These headers will be added to the HTTP requests sent to the token endpoint.
42+
* This can be useful for scenarios requiring custom headers for proxies or for diagnostic purposes.
43+
*
44+
* @return A map of additional HTTP headers to include with the token request, or null if no extra headers are needed.
45+
*/
1746
Map<String, String> extraHttpHeaders();
1847

48+
/**
49+
* Gets the tenant identifier for the token request.
50+
* <p>
51+
* When specified, this value overrides the tenant specified in the application's authority URL.
52+
* It can be a tenant ID (GUID), domain name, or one of the special values like "common" or "organizations".
53+
*
54+
* @return The tenant identifier to use for the token request, or null to use the tenant from the authority URL.
55+
*/
1956
String tenant();
2057

58+
/**
59+
* Gets additional query parameters to be included in the token request.
60+
* <p>
61+
* These parameters will be added to the query string in requests to the authorization and token endpoints.
62+
* This can be useful for scenarios requiring custom parameters that aren't explicitly supported in the library.
63+
*
64+
* @return A map of additional query parameters to include with the token request, or null if no extra parameters are needed.
65+
*/
2166
Map<String, String> extraQueryParameters();
2267
}

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/IApplicationBase.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,48 @@
99
import java.util.concurrent.CompletableFuture;
1010

1111
/**
12-
* Interface representing an application for which tokens can be acquired.
12+
* Base interface representing a client application that can acquire tokens from the Microsoft identity platform.
13+
* Defines common functionality across different application types (public client, confidential client,
14+
* and managed identity applications).
1315
*/
1416
interface IApplicationBase {
1517

1618
String DEFAULT_AUTHORITY = "https://login.microsoftonline.com/common/";
1719

1820
/**
19-
* @return a boolean value which determines whether Pii (personally identifiable information) will be logged in
21+
* Gets whether personally identifiable information (PII) is included in log messages.
22+
*
23+
* @return A boolean value which determines whether PII (personally identifiable information) will be included in log messages.
24+
* When true, PII will be logged; when false, PII will be masked or omitted from logs.
2025
*/
2126
boolean logPii();
2227

2328
/**
24-
* @return Correlation ID which is used for diagnostics purposes, is attached to token service requests
25-
* Default value is random UUID
29+
* Gets the correlation ID used for tracing requests through the authentication system.
30+
*
31+
* @return Correlation ID which is used for diagnostics purposes and is attached to token service requests.
32+
* The default value is a random UUID.
2633
*/
2734
String correlationId();
2835

2936
/**
30-
* Sets HTTP client to be used by the client application for all HTTP requests. Allows for fine-grained
31-
* configuration of HTTP client.
32-
33-
* @return instance of IHttpClient used by the application
37+
* Gets the HTTP client used by the application for all HTTP requests.
38+
*
39+
* @return Instance of IHttpClient used by the application for network communication with the Microsoft identity platform.
3440
*/
3541
IHttpClient httpClient();
3642

3743
/**
38-
* @return proxy used by the application for all network communication.
44+
* Gets the proxy configuration used by the application for network communication.
45+
*
46+
* @return Proxy used by the application for all network communication. Returns null if no proxy is configured.
3947
*/
4048
Proxy proxy();
4149

4250
/**
43-
* @return SSLSocketFactory used by the application for all network communication.
51+
* Gets the SSL socket factory used by the application for secure network communication.
52+
*
53+
* @return SSLSocketFactory used by the application for all secure network communication. Returns null if no custom SSL socket factory is configured.
4454
*/
4555
SSLSocketFactory sslSocketFactory();
4656
}

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/IBroker.java

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,84 @@
99
import java.util.concurrent.CompletableFuture;
1010

1111
/**
12-
* Used to define the basic set of methods that all Brokers must implement
12+
* Interface defining the core functionality required for authentication brokers.
13+
* <p>
14+
* Authentication brokers provide a centralized way to handle authentication across multiple applications
15+
* on a device or platform. They can offer benefits such as single sign-on (SSO) between applications,
16+
* consistent authentication experiences, and leveraging platform security features.
1317
* <p>
1418
* All methods are marked as default so they can be referenced by MSAL Java without an implementation,
15-
* and most will simply throw an exception if not overridden by an IBroker implementation
19+
* and most will simply throw an exception if not overridden by an IBroker implementation.
1620
*/
1721
public interface IBroker {
1822

1923
/**
20-
* Acquire a token silently, i.e. without direct user interaction
24+
* Acquires a token silently without user interaction.
2125
* <p>
2226
* This may be accomplished by returning tokens from a token cache, using cached refresh tokens to get new tokens,
23-
* or via any authentication flow where a user is not prompted to enter credentials
27+
* or via any authentication flow where a user is not prompted to enter credentials.
28+
*
29+
* @param application The public client application requesting the token
30+
* @param requestParameters Parameters for the silent token request
31+
* @return A CompletableFuture containing the authentication result with tokens and account information
32+
* @throws MsalClientException If no broker implementation is available
2433
*/
2534
default CompletableFuture<IAuthenticationResult> acquireToken(PublicClientApplication application, SilentParameters requestParameters) {
2635
throw new MsalClientException("Broker implementation missing", AuthenticationErrorCode.MISSING_BROKER);
2736
}
2837

2938
/**
30-
* Acquire a token interactively, by prompting users to enter their credentials in some way
39+
* Acquires a token interactively by prompting the user to enter credentials.
40+
* <p>
41+
* This method presents a user interface requesting credentials from the user and handles the
42+
* interactive authentication flow.
43+
*
44+
* @param application The public client application requesting the token
45+
* @param parameters Parameters for the interactive token request
46+
* @return A CompletableFuture containing the authentication result with tokens and account information
47+
* @throws MsalClientException If no broker implementation is available
3148
*/
3249
default CompletableFuture<IAuthenticationResult> acquireToken(PublicClientApplication application, InteractiveRequestParameters parameters) {
3350
throw new MsalClientException("Broker implementation missing", AuthenticationErrorCode.MISSING_BROKER);
3451
}
3552

3653
/**
37-
* Acquire a token silently, i.e. without direct user interaction, using username/password authentication
54+
* Acquires a token silently using username and password authentication.
55+
* <p>
56+
* This method enables resource owner password credentials (ROPC) flow through a broker.
57+
* Note that this flow is not recommended for production applications as it requires handling
58+
* user credentials directly.
59+
*
60+
* @param application The public client application requesting the token
61+
* @param parameters Parameters containing username, password and other request details
62+
* @return A CompletableFuture containing the authentication result with tokens and account information
63+
* @throws MsalClientException If no broker implementation is available
3864
*/
3965
default CompletableFuture<IAuthenticationResult> acquireToken(PublicClientApplication application, UserNamePasswordParameters parameters) {
4066
throw new MsalClientException("Broker implementation missing", AuthenticationErrorCode.MISSING_BROKER);
4167
}
4268

69+
/**
70+
* Removes an account from the broker's token cache.
71+
* <p>
72+
* This method allows applications to sign out users and remove their tokens from the broker cache.
73+
*
74+
* @param application The public client application requesting the account removal
75+
* @param account The account to be removed from the token cache
76+
* @throws MsalClientException If no broker implementation is available
77+
*/
4378
default void removeAccount(PublicClientApplication application, IAccount account) throws MsalClientException {
4479
throw new MsalClientException("Broker implementation missing", AuthenticationErrorCode.MISSING_BROKER);
4580
}
4681

4782
/**
48-
* Returns whether a broker is available and ready to use on this machine, allowing the use of the methods
49-
* in this interface and other broker-only features in MSAL Java
83+
* Checks whether a broker is available and ready to use on this machine.
84+
* <p>
85+
* Applications should call this method before attempting to use broker-specific features
86+
* to determine if a broker is installed and accessible.
87+
*
88+
* @return true if a broker is available for authentication, false otherwise
89+
* @throws MsalClientException If no broker implementation is available
5090
*/
5191
default boolean isBrokerAvailable() {
5292
throw new MsalClientException("Broker implementation missing", AuthenticationErrorCode.MISSING_BROKER);

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/IClientApplicationBase.java

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,65 @@
1111
import java.util.concurrent.CompletableFuture;
1212

1313
/**
14-
* Interface representing an application for which tokens can be acquired.
14+
* Interface representing a client application that can acquire tokens from the Microsoft identity platform.
15+
* This interface serves as the base for both public client applications (desktop/mobile apps) and
16+
* confidential client applications (web apps/APIs), defining common functionality for token acquisition.
17+
* <p>
18+
* Client applications are registered in the Microsoft identity platform and have their own identity,
19+
* represented by an application ID (client ID).
1520
*/
1621
interface IClientApplicationBase extends IApplicationBase {
1722

1823
/**
24+
* Gets the client ID (application ID) for this application.
25+
*
1926
* @return Client ID (Application ID) of the application as registered in the application registration portal
2027
* (portal.azure.com) and as passed in the constructor of the application
2128
*/
2229
String clientId();
2330

2431
/**
32+
* Gets the authority URL for this application.
33+
*
2534
* @return URL of the authority, or security token service (STS) from which MSAL will acquire security tokens.
2635
* Default value is {@link IClientApplicationBase#DEFAULT_AUTHORITY}
2736
*/
2837
String authority();
2938

3039
/**
31-
* @return a boolean value which determines whether the authority needs to be verified against a list of known authorities.
40+
* Gets whether the authority URL should be validated against a list of known authorities.
41+
*
42+
* @return A boolean value which determines whether the authority needs to be verified against a list of known authorities.
43+
* When true, MSAL will validate the authority against a list of well-known authorities. Set to false only for
44+
* development/testing with custom authority URLs.
3245
*/
3346
boolean validateAuthority();
3447

35-
// /**
36-
// * @return Telemetry consumer that will receive telemetry events emitted by the library.
37-
// */
38-
// java.util.function.Consumer<java.util.List<java.util.HashMap<String, String>>> telemetryConsumer();
39-
4048
/**
4149
* Computes the URL of the authorization request letting the user sign-in and consent to the
4250
* application. The URL target the /authorize endpoint of the authority configured in the
4351
* application object.
4452
* <p>
4553
* Once the user successfully authenticates, the response should contain an authorization code,
46-
* which can then be passed in to{@link AbstractClientApplicationBase#acquireToken(AuthorizationCodeParameters)}
47-
* to be exchanged for a token
54+
* which can then be passed in to {@link AbstractClientApplicationBase#acquireToken(AuthorizationCodeParameters)}
55+
* to be exchanged for a token.
4856
*
49-
* @param parameters {@link AuthorizationRequestUrlParameters}
50-
* @return url of the authorization endpoint where the user can sign-in and consent to the application.
57+
* @param parameters {@link AuthorizationRequestUrlParameters} containing the details needed to create the authorization URL,
58+
* such as scopes, response type, and redirect URI
59+
* @return URL of the authorization endpoint where the user can sign-in and consent to the application
5160
*/
5261
URL getAuthorizationRequestUrl(AuthorizationRequestUrlParameters parameters);
5362

5463
/**
5564
* Acquires security token from the authority using an authorization code previously received.
65+
* <p>
66+
* This is typically used as the second step in an authorization code flow, after the user has
67+
* authenticated and provided consent at the authorization endpoint, resulting in an authorization code.
5668
*
57-
* @param parameters {@link AuthorizationCodeParameters}
58-
* @return A {@link CompletableFuture} object representing the {@link IAuthenticationResult} of the call.
69+
* @param parameters {@link AuthorizationCodeParameters} containing the authorization code and other information
70+
* required to exchange the code for tokens
71+
* @return A {@link CompletableFuture} object representing the {@link IAuthenticationResult} of the call,
72+
* which contains the requested tokens and account information
5973
*/
6074
CompletableFuture<IAuthenticationResult> acquireToken(AuthorizationCodeParameters parameters);
6175

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/IClientAssertion.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77
* Credential type containing an assertion of type
88
* "urn:ietf:params:oauth:token-type:jwt".
99
* <p>
10+
* Client assertions provide a way for confidential client applications to authenticate themselves
11+
* to the Microsoft identity platform without sending a client secret. Instead, the application
12+
* uses a JWT token as a credential.
13+
* <p>
1014
* For more details, see https://aka.ms/msal4j-client-credentials
1115
*/
1216
public interface IClientAssertion extends IClientCredential {
1317

1418
/**
19+
* Gets the JWT token used for client authentication.
20+
*
1521
* @return Jwt token encoded as a base64 URL encoded string
1622
*/
1723
String assertion();

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/IClientCredential.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
package com.microsoft.aad.msal4j;
55

66
/**
7-
* Interface representing an application credential
7+
* Interface representing an application credential used for client authentication.
8+
* <p>
9+
* Client credentials are used by confidential client applications to authenticate themselves
10+
* to the Microsoft identity platform when requesting tokens. This is used in scenarios where the
11+
* application is acting on its own behalf (client credentials flow) or on behalf of a user
12+
* (authorization code flow with client authentication).
13+
* <p>
14+
* MSAL supports several types of client credentials:
15+
* <ul>
16+
* <li>Client secrets - A string secret configured for the application in the Azure portal</li>
17+
* <li>Client certificates - An X.509 certificate that can be used to authenticate the application</li>
18+
* <li>Client assertions - A JWT token signed with a private key that proves the client's identity</li>
19+
* </ul>
820
* <p>
921
* For more details, see https://aka.ms/msal4j-client-credentials
1022
*/

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/IEnvironmentVariables.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,24 @@
33

44
package com.microsoft.aad.msal4j;
55

6+
/**
7+
* Interface for accessing environment variables within the library.
8+
* <p>
9+
* This interface abstracts the mechanism for retrieving environment variables,
10+
* which allows for better testability and flexibility in different hosting environments.
11+
* It's primarily used within the library for accessing configuration settings and
12+
* credentials that may be stored in environment variables.
13+
*/
614
interface IEnvironmentVariables {
715

8-
16+
/**
17+
* Retrieves the value of the specified environment variable.
18+
* <p>
19+
* This method provides access to system environment variables that may contain
20+
* configuration settings or credentials needed for authentication.
21+
*
22+
* @param envVariable The name of the environment variable to retrieve.
23+
* @return The string value of the environment variable, or null if the variable is not defined.
24+
*/
925
String getEnvironmentVariable(String envVariable);
1026
}

0 commit comments

Comments
 (0)