Skip to content

Commit d78951a

Browse files
authored
1.7.0 release (#278)
1.7.0 release
1 parent 53e6004 commit d78951a

29 files changed

+502
-145
lines changed

README.md

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
# Microsoft Authentication Library (MSAL) for Java
2-
3-
`master` branch | `dev` branch | Reference Docs
4-
--------------------|-----------------|---------------
5-
[![Build status](https://identitydivision.visualstudio.com/IDDP/_apis/build/status/CI/Java/MSAL%20Java%20CI%20Build?branchName=master)](https://identitydivision.visualstudio.com/IDDP/_build/latest?definitionId=762) | [![Build status](https://identitydivision.visualstudio.com/IDDP/_apis/build/status/CI/Java/MSAL%20Java%20CI%20Build?branchName=dev)](https://identitydivision.visualstudio.com/IDDP/_build/latest?definitionId=762)| [![Javadocs](http://javadoc.io/badge/com.microsoft.azure/msal4j.svg)](http://javadoc.io/doc/com.microsoft.azure/msal4j)
6-
7-
The Microsoft Authentication Library for Java (MSAL4J) enables applications to integrate with the [Microsoft identity platform](https://aka.ms/aaddevv2). It allows you to sign in users or apps with Microsoft identities (Azure AD, Microsoft accounts and Azure AD B2C accounts) and obtain tokens to call Microsoft APIs such as [Microsoft Graph](https://graph.microsoft.io/) or your own APIs registered with the Microsoft identity platform. It is built using industry standard OAuth2 and OpenID Connect protocols.
8-
9-
Quick links:
10-
11-
| [Getting Started](https://docs.microsoft.com/azure/active-directory/develop/quickstart-v2-java-webapp) | [Docs](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki) | [Samples](https://aka.ms/aaddevsamplesv2) | [Support](README.md#community-help-and-support)
12-
| --- | --- | --- | --- |
13-
14-
## Install
15-
16-
The library supports the following Java environments:
17-
- Java 8 (or higher)
18-
19-
Current version - 1.6.2
20-
21-
You can find the changes for each version in the [change log](https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/master/changelog.txt).
22-
23-
You can get the msal4j package through Maven or Gradle.
24-
25-
### Maven
26-
Find [the latest package in the Maven repository](https://mvnrepository.com/artifact/com.microsoft.azure/msal4j).
27-
```
28-
<dependency>
29-
<groupId>com.microsoft.azure</groupId>
30-
<artifactId>msal4j</artifactId>
31-
<version>1.6.2</version>
32-
</dependency>
33-
```
34-
### Gradle
35-
36-
```
37-
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.6.2'
38-
```
39-
40-
## Usage
41-
42-
MSAL4J supports multiple [application types and authentication scenarios](https://docs.microsoft.com/azure/active-directory/develop/authentication-flows-app-scenarios).
43-
44-
Refer the [Uncyclo](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki) pages for more details on the usage of MSAL Java and the supported scenarios.
45-
46-
## Migrating from ADAL
47-
If your application is using ADAL for Java (ADAL4J), we recommend you to update to use MSAL4J. No new feature work will be done in ADAL4J.
48-
49-
See the [ADAL to MSAL migration](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki/Migrate-to-MSAL-Java) guide.
50-
51-
## Roadmap
52-
53-
You can follow the latest updates and plans for MSAL Java in the [Roadmap](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki#roadmap) published on our Uncyclo.
54-
55-
## Contribution
56-
57-
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
58-
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
59-
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
60-
61-
## Samples and Documentation
62-
63-
We provide a [full suite of sample applications](https://aka.ms/aaddevsamplesv2) and [documentation](https://aka.ms/aaddevv2) to help you get started with learning the Microsoft identity platform.
64-
65-
## Community Help and Support
66-
67-
We leverage [Stack Overflow](http://stackoverflow.com/) to work with the community on supporting Azure Active Directory and its SDKs, including this one! We highly recommend you ask your questions on Stack Overflow (we're all on there!) Also browser existing issues to see if someone has had your question before.
68-
69-
We recommend you use the "msal" tag so we can see it! Here is the latest Q&A on Stack Overflow for MSAL: [http://stackoverflow.com/questions/tagged/msal](http://stackoverflow.com/questions/tagged/msal)
70-
71-
## Security Reporting
72-
73-
If you find a security issue with our libraries or services please report it to [[email protected]](mailto:[email protected]) with as much detail as possible. Your submission may be eligible for a bounty through the [Microsoft Bounty](http://aka.ms/bugbounty) program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting [this page](https://technet.microsoft.com/security/dd252948) and subscribing to Security Advisory Alerts.
74-
75-
## We Value and Adhere to the Microsoft Open Source Code of Conduct
76-
77-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
1+
# Microsoft Authentication Library (MSAL) for Java
2+
3+
`master` branch | `dev` branch | Reference Docs
4+
--------------------|-----------------|---------------
5+
[![Build status](https://identitydivision.visualstudio.com/IDDP/_apis/build/status/CI/Java/MSAL%20Java%20CI%20Build?branchName=master)](https://identitydivision.visualstudio.com/IDDP/_build/latest?definitionId=762) | [![Build status](https://identitydivision.visualstudio.com/IDDP/_apis/build/status/CI/Java/MSAL%20Java%20CI%20Build?branchName=dev)](https://identitydivision.visualstudio.com/IDDP/_build/latest?definitionId=762)| [![Javadocs](http://javadoc.io/badge/com.microsoft.azure/msal4j.svg)](http://javadoc.io/doc/com.microsoft.azure/msal4j)
6+
7+
The Microsoft Authentication Library for Java (MSAL4J) enables applications to integrate with the [Microsoft identity platform](https://aka.ms/aaddevv2). It allows you to sign in users or apps with Microsoft identities (Azure AD, Microsoft accounts and Azure AD B2C accounts) and obtain tokens to call Microsoft APIs such as [Microsoft Graph](https://graph.microsoft.io/) or your own APIs registered with the Microsoft identity platform. It is built using industry standard OAuth2 and OpenID Connect protocols.
8+
9+
Quick links:
10+
11+
| [Getting Started](https://docs.microsoft.com/azure/active-directory/develop/quickstart-v2-java-webapp) | [Docs](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki) | [Samples](https://aka.ms/aaddevsamplesv2) | [Support](README.md#community-help-and-support)
12+
| --- | --- | --- | --- |
13+
14+
## Install
15+
16+
The library supports the following Java environments:
17+
- Java 8 (or higher)
18+
19+
Current version - 1.7.0
20+
21+
You can find the changes for each version in the [change log](https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/master/changelog.txt).
22+
23+
You can get the msal4j package through Maven or Gradle.
24+
25+
### Maven
26+
Find [the latest package in the Maven repository](https://mvnrepository.com/artifact/com.microsoft.azure/msal4j).
27+
```
28+
<dependency>
29+
<groupId>com.microsoft.azure</groupId>
30+
<artifactId>msal4j</artifactId>
31+
<version>1.7.0</version>
32+
</dependency>
33+
```
34+
### Gradle
35+
36+
```
37+
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.7.0'
38+
```
39+
40+
## Usage
41+
42+
MSAL4J supports multiple [application types and authentication scenarios](https://docs.microsoft.com/azure/active-directory/develop/authentication-flows-app-scenarios).
43+
44+
Refer the [Uncyclo](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki) pages for more details on the usage of MSAL Java and the supported scenarios.
45+
46+
## Migrating from ADAL
47+
If your application is using ADAL for Java (ADAL4J), we recommend you to update to use MSAL4J. No new feature work will be done in ADAL4J.
48+
49+
See the [ADAL to MSAL migration](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki/Migrate-to-MSAL-Java) guide.
50+
51+
## Roadmap
52+
53+
You can follow the latest updates and plans for MSAL Java in the [Roadmap](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki#roadmap) published on our Uncyclo.
54+
55+
## Contribution
56+
57+
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
58+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
59+
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
60+
61+
## Samples and Documentation
62+
63+
We provide a [full suite of sample applications](https://aka.ms/aaddevsamplesv2) and [documentation](https://aka.ms/aaddevv2) to help you get started with learning the Microsoft identity platform.
64+
65+
## Community Help and Support
66+
67+
We leverage [Stack Overflow](http://stackoverflow.com/) to work with the community on supporting Azure Active Directory and its SDKs, including this one! We highly recommend you ask your questions on Stack Overflow (we're all on there!) Also browser existing issues to see if someone has had your question before.
68+
69+
We recommend you use the "msal" tag so we can see it! Here is the latest Q&A on Stack Overflow for MSAL: [http://stackoverflow.com/questions/tagged/msal](http://stackoverflow.com/questions/tagged/msal)
70+
71+
## Security Reporting
72+
73+
If you find a security issue with our libraries or services please report it to [[email protected]](mailto:[email protected]) with as much detail as possible. Your submission may be eligible for a bounty through the [Microsoft Bounty](http://aka.ms/bugbounty) program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting [this page](https://technet.microsoft.com/security/dd252948) and subscribing to Security Advisory Alerts.
74+
75+
## We Value and Adhere to the Microsoft Open Source Code of Conduct
76+
77+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 1.7.0
2+
=============
3+
- Tenant profiles added to IAccount
4+
- Support of certificate chain
5+
- Api to set connect and read timeouts for default http client
6+
17
Version 1.6.2
28
=============
39
- Fix for "NullPointerException during accessing B2C authority aliases"

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.microsoft.azure</groupId>
55
<artifactId>msal4j</artifactId>
6-
<version>1.6.2</version>
6+
<version>1.7.0</version>
77
<packaging>jar</packaging>
88
<name>msal4j</name>
99
<description>

src/integrationtest/java/com.microsoft.aad.msal4j/AcquireTokenSilentIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void acquireTokenSilent_LabAuthority_TokenNotRefreshed(String environment
8383
public void acquireTokenSilent_ForceRefresh(String environment) throws Exception {
8484
cfg = new Config(environment);
8585

86-
User user = labUserProvider.getDefaultUser();
86+
User user = labUserProvider.getDefaultUser(environment);
8787

8888
PublicClientApplication pca = PublicClientApplication.builder(
8989
user.getAppId()).

src/integrationtest/java/com.microsoft.aad.msal4j/ConfidentialClientApplicationUnitT.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.nimbusds.jwt.JWTClaimsSet;
1212
import com.nimbusds.jwt.SignedJWT;
1313
import com.nimbusds.oauth2.sdk.auth.PrivateKeyJWT;
14-
import org.apache.commons.lang3.StringUtils;
1514
import org.easymock.EasyMock;
1615
import org.powermock.api.easymock.PowerMock;
1716
import org.powermock.core.classloader.annotations.PowerMockIgnore;
@@ -186,12 +185,14 @@ private ClientAssertion buildShortJwt(String clientId,
186185
SignedJWT jwt;
187186
try {
188187
List<Base64> certs = new ArrayList<>();
189-
certs.add(new Base64(credential.publicCertificate()));
188+
for (String cert: credential.getEncodedPublicKeyCertificateOrCertificateChain()) {
189+
certs.add(new Base64(cert));
190+
}
190191
JWSHeader.Builder builder = new JWSHeader.Builder(JWSAlgorithm.RS256);
191192
builder.x509CertChain(certs);
192193
builder.x509CertThumbprint(new Base64URL(credential.publicCertificateHash()));
193194
jwt = new SignedJWT(builder.build(), claimsSet);
194-
final RSASSASigner signer = new RSASSASigner(credential.key());
195+
final RSASSASigner signer = new RSASSASigner(credential.privateKey());
195196
jwt.sign(signer);
196197
} catch (final Exception e) {
197198
throw new MsalClientException(e);

src/integrationtest/java/com.microsoft.aad.msal4j/DeviceCodeIT.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ private void runAutomatedDeviceCodeFlow(DeviceCode deviceCode, User user, String
123123
} else {
124124
SeleniumExtensions.performADLogin(seleniumDriver, user);
125125
}
126-
127-
if (environment.equals(AzureEnvironment.AZURE) && !isADFS2019) {
128-
//Login flow for azurecloud environment has an extra "Stay signed in?" page after authentication
129-
continueBtn = SeleniumExtensions.waitForElementToBeVisibleAndEnable(
130-
seleniumDriver,
131-
new By.ById(continueButtonId));
132-
continueBtn.click();
133-
}
134-
135126
} catch(Exception e){
136127
if(!isRunningLocally){
137128
SeleniumExtensions.takeScreenShot(seleniumDriver);

src/integrationtest/java/com.microsoft.aad.msal4j/RefreshTokenIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public class RefreshTokenIT {
2121

2222
private Config cfg;
2323

24-
private void setUp() throws Exception {
24+
private void setUp(String environment) throws Exception {
2525
LabUserProvider labUserProvider = LabUserProvider.getInstance();
26-
User user = labUserProvider.getDefaultUser();
26+
User user = labUserProvider.getDefaultUser(environment);
2727

2828
pca = PublicClientApplication.builder(
2929
user.getAppId()).
@@ -44,7 +44,7 @@ private void setUp() throws Exception {
4444
public void acquireTokenWithRefreshToken(String environment) throws Exception{
4545
cfg = new Config(environment);
4646

47-
setUp();
47+
setUp(environment);
4848

4949
IAuthenticationResult result = pca.acquireToken(RefreshTokenParameters
5050
.builder(

src/integrationtest/java/com.microsoft.aad.msal4j/TokenCacheIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void twoAccountsInCache_SameUserDifferentTenants_RemoveAccountTest() thro
146146
.get();
147147

148148
// There should be two tokens in cache, with same accounts except for tenant
149-
Assert.assertEquals(pca2.getAccounts().join().size() , 2);
149+
Assert.assertEquals(pca2.getAccounts().join().iterator().next().getTenantProfiles().size() , 2);
150150

151151
IAccount account = pca2.getAccounts().get().iterator().next();
152152

src/main/java/com/microsoft/aad/msal4j/AbstractClientApplicationBase.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ abstract class AbstractClientApplicationBase implements IClientApplicationBase {
6666
@Getter
6767
private SSLSocketFactory sslSocketFactory;
6868

69+
@Accessors(fluent = true)
70+
@Getter
71+
private Integer connectTimeoutForDefaultHttpClient;
72+
73+
@Accessors(fluent = true)
74+
@Getter
75+
private Integer readTimeoutForDefaultHttpClient;
76+
6977
@Accessors(fluent = true)
7078
@Getter
7179
protected TokenCache tokenCache;
@@ -284,6 +292,8 @@ abstract static class Builder<T extends Builder<T>> {
284292
private ITokenCacheAccessAspect tokenCacheAccessAspect;
285293
private AadInstanceDiscoveryResponse aadInstanceDiscoveryResponse;
286294
private String clientCapabilities;
295+
private Integer connectTimeoutForDefaultHttpClient;
296+
private Integer readTimeoutForDefaultHttpClient;
287297

288298
/**
289299
* Constructor to create instance of Builder of client application
@@ -446,6 +456,34 @@ public T sslSocketFactory(SSLSocketFactory val) {
446456
return self();
447457
}
448458

459+
/**
460+
* Sets the connect timeout value used in HttpsURLConnection connections made by {@link DefaultHttpClient},
461+
* and is not needed if using a custom HTTP client
462+
*
463+
* @param val timeout value in milliseconds
464+
* @return instance of the Builder on which method was called
465+
*/
466+
public T connectTimeoutForDefaultHttpClient(Integer val) {
467+
validateNotNull("connectTimeoutForDefaultHttpClient", val);
468+
469+
connectTimeoutForDefaultHttpClient = val;
470+
return self();
471+
}
472+
473+
/**
474+
* Sets the read timeout value used in HttpsURLConnection connections made by {@link DefaultHttpClient},
475+
* and is not needed if using a custom HTTP client
476+
*
477+
* @param val timeout value in milliseconds
478+
* @return instance of the Builder on which method was called
479+
*/
480+
public T readTimeoutForDefaultHttpClient(Integer val) {
481+
validateNotNull("readTimeoutForDefaultHttpClient", val);
482+
483+
readTimeoutForDefaultHttpClient = val;
484+
return self();
485+
}
486+
449487
T telemetryConsumer(Consumer<List<HashMap<String, String>>> val) {
450488
validateNotNull("telemetryConsumer", val);
451489

@@ -549,10 +587,12 @@ public T clientCapabilities(Set<String> capabilities) {
549587
telemetryConsumer = builder.telemetryConsumer;
550588
proxy = builder.proxy;
551589
sslSocketFactory = builder.sslSocketFactory;
590+
connectTimeoutForDefaultHttpClient = builder.connectTimeoutForDefaultHttpClient;
591+
readTimeoutForDefaultHttpClient = builder.readTimeoutForDefaultHttpClient;
552592
serviceBundle = new ServiceBundle(
553593
builder.executorService,
554594
builder.httpClient == null ?
555-
new DefaultHttpClient(builder.proxy, builder.sslSocketFactory) :
595+
new DefaultHttpClient(builder.proxy, builder.sslSocketFactory, builder.connectTimeoutForDefaultHttpClient, builder.readTimeoutForDefaultHttpClient) :
556596
builder.httpClient,
557597
new TelemetryManager(telemetryConsumer, builder.onlySendFailureTelemetry));
558598
authenticationAuthority = builder.authenticationAuthority;

src/main/java/com/microsoft/aad/msal4j/Account.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import lombok.Getter;
88
import lombok.Setter;
99
import lombok.experimental.Accessors;
10+
import java.util.Map;
1011

1112
/**
1213
* Representation of a single user account. If modifying this object, ensure it is compliant with
@@ -23,4 +24,10 @@ class Account implements IAccount {
2324
String environment;
2425

2526
String username;
27+
28+
Map<String, ITenantProfile> tenantProfiles;
29+
30+
public Map<String, ITenantProfile> getTenantProfiles() {
31+
return tenantProfiles;
32+
}
2633
}

src/main/java/com/microsoft/aad/msal4j/AccountCacheEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.io.Serializable;
1111
import java.util.ArrayList;
1212
import java.util.List;
13+
import java.util.Map;
1314

1415
@Accessors(fluent = true)
1516
@Getter
@@ -26,7 +27,6 @@ class AccountCacheEntity implements Serializable {
2627
@JsonProperty("environment")
2728
protected String environment;
2829

29-
@EqualsAndHashCode.Exclude
3030
@JsonProperty("realm")
3131
protected String realm;
3232

@@ -101,6 +101,6 @@ static AccountCacheEntity create(String clientInfoStr, Authority requestAuthorit
101101
}
102102

103103
IAccount toAccount(){
104-
return new Account(homeAccountId, environment, username);
104+
return new Account(homeAccountId, environment, username, null);
105105
}
106106
}

0 commit comments

Comments
 (0)