Skip to content

Commit 4fbf681

Browse files
authored
Merge pull request #162 from AzureAD/dev
1.3.0 release
2 parents 29bd90b + d610659 commit 4fbf681

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+660
-308
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,29 @@ Quick links:
1212
| --- | --- | --- | --- |
1313

1414
## Install
15-
Current version - 1.2.0
15+
16+
The library supports the following Java environments:
17+
- Java 8 (or higher)
18+
19+
Current version - 1.3.0
1620

1721
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).
1822

1923
You can get the msal4j package through Maven or Gradle.
2024

2125
### Maven
22-
26+
Find [the latest package in the Maven repository](https://mvnrepository.com/artifact/com.microsoft.azure/msal4j).
2327
```
2428
<dependency>
2529
<groupId>com.microsoft.azure</groupId>
2630
<artifactId>msal4j</artifactId>
27-
<version>1.2.0</version>
31+
<version>1.3.0</version>
2832
</dependency>
2933
```
3034
### Gradle
3135

3236
```
33-
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.2.0'
37+
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.3.0'
3438
```
3539

3640
## Usage

changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 1.3.0
2+
=============
3+
- Added option to pass in AAD instance discovery data
4+
- Removed runtime dependency on commons-codec.commons-codec, org.apache.commons.commons-text, org.apache.httpcomponents.httpclient, com.google.code.gson
5+
- Added runtime dependency on com.fasterxml.jackson.databind
6+
17
Version 1.2.0
28
=============
39
- Added support for ADFS 2019

lombok.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lombok.anyConstructor.addConstructorProperties=true

pom.xml

Lines changed: 16 additions & 17 deletions
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.2.0</version>
6+
<version>1.3.0</version>
77
<packaging>jar</packaging>
88
<name>msal4j</name>
99
<description>
@@ -38,33 +38,31 @@
3838
<artifactId>oauth2-oidc-sdk</artifactId>
3939
<version>6.5</version>
4040
</dependency>
41-
<dependency>
42-
<groupId>com.google.code.gson</groupId>
43-
<artifactId>gson</artifactId>
44-
<version>2.8.5</version>
45-
</dependency>
4641
<dependency>
4742
<groupId>org.slf4j</groupId>
4843
<artifactId>slf4j-api</artifactId>
49-
<version>1.7.21</version>
50-
</dependency>
51-
<dependency>
52-
<groupId>commons-codec</groupId>
53-
<artifactId>commons-codec</artifactId>
54-
<version>1.11</version>
55-
</dependency>
56-
<dependency>
57-
<groupId>org.apache.commons</groupId>
58-
<artifactId>commons-text</artifactId>
59-
<version>1.7</version>
44+
<version>1.7.28</version>
6045
</dependency>
6146
<dependency>
6247
<groupId>org.projectlombok</groupId>
6348
<artifactId>lombok</artifactId>
6449
<version>1.18.6</version>
50+
<scope>provided</scope>
6551
</dependency>
52+
<dependency>
53+
<groupId>com.fasterxml.jackson.core</groupId>
54+
<artifactId>jackson-databind</artifactId>
55+
<version>2.10.1</version>
56+
</dependency>
57+
6658

6759
<!-- test dependencies -->
60+
<dependency>
61+
<groupId>org.apache.commons</groupId>
62+
<artifactId>commons-text</artifactId>
63+
<version>1.7</version>
64+
<scope>test</scope>
65+
</dependency>
6866
<dependency>
6967
<groupId>org.testng</groupId>
7068
<artifactId>testng</artifactId>
@@ -99,6 +97,7 @@
9997
<groupId>org.apache.httpcomponents</groupId>
10098
<artifactId>httpclient</artifactId>
10199
<version>4.5.9</version>
100+
<scope>test</scope>
102101
</dependency>
103102
<dependency>
104103
<groupId>com.microsoft.azure</groupId>

src/integrationtest/java/labapi/App.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33

44
package labapi;
55

6-
import com.google.gson.annotations.SerializedName;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
77
import lombok.Getter;
88

99
@Getter
1010
public class App {
1111

12-
@SerializedName("appType")
12+
@JsonProperty("appType")
1313
String appType;
1414

15-
@SerializedName("appName")
15+
@JsonProperty("appName")
1616
String appName;
1717

18-
@SerializedName("appId")
18+
@JsonProperty("appId")
1919
String appId;
2020

21-
@SerializedName("redirectUri")
21+
@JsonProperty("redirectUri")
2222
String redirectUri;
2323

24-
@SerializedName("authority")
24+
@JsonProperty("authority")
2525
String authority;
2626

27-
@SerializedName("labName")
27+
@JsonProperty("labName")
2828
String labName;
2929

3030
}

src/integrationtest/java/labapi/Lab.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33

44
package labapi;
55

6-
import com.google.gson.annotations.SerializedName;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
77
import lombok.Getter;
88

99
@Getter
1010
public class Lab {
11-
@SerializedName("labName")
11+
@JsonProperty("labName")
1212
String labName;
1313

14-
@SerializedName("domain")
14+
@JsonProperty("domain")
1515
String domain;
1616

17-
@SerializedName("tenantId")
17+
@JsonProperty("tenantId")
1818
String tenantId;
1919

20-
@SerializedName("federationProvider")
20+
@JsonProperty("federationProvider")
2121
String federationProvider;
2222

23-
@SerializedName("azureEnvironment")
23+
@JsonProperty("azureEnvironment")
2424
String azureEnvironment;
2525

26-
@SerializedName("authority")
26+
@JsonProperty("authority")
2727
String authority;
2828
}

src/integrationtest/java/labapi/LabService.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
package labapi;
55

6-
import com.google.gson.Gson;
6+
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.databind.DeserializationFeature;
8+
import com.fasterxml.jackson.databind.ObjectMapper;
79
import com.microsoft.aad.msal4j.*;
810

911
import java.net.MalformedURLException;
@@ -16,6 +18,17 @@ public class LabService {
1618

1719
static ConfidentialClientApplication labApp;
1820

21+
static ObjectMapper mapper = new ObjectMapper()
22+
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
23+
24+
static <T> T convertJsonToObject(final String json, final Class<T> clazz) {
25+
try {
26+
return mapper.readValue(json, clazz);
27+
} catch (JsonProcessingException e) {
28+
throw new RuntimeException("JsonProcessingException: " + e.getMessage(), e);
29+
}
30+
}
31+
1932
static void initLabApp() throws MalformedURLException {
2033
KeyVaultSecretsProvider keyVaultSecretsProvider = new KeyVaultSecretsProvider();
2134

@@ -44,7 +57,7 @@ User getUser(UserQueryParameters query){
4457
String result = HttpClientHelper.sendRequestToLab(
4558
LabConstants.LAB_USER_ENDPOINT, queryMap, getLabAccessToken());
4659

47-
User[] users = new Gson().fromJson(result, User[].class);
60+
User[] users = convertJsonToObject(result, User[].class);
4861
User user = users[0];
4962
user.setPassword(getUserSecret(user.getLabName()));
5063
if (query.parameters.containsKey(UserQueryParameters.FEDERATION_PROVIDER)) {
@@ -62,7 +75,7 @@ public static App getApp(String appId){
6275
try {
6376
String result = HttpClientHelper.sendRequestToLab(
6477
LabConstants.LAB_APP_ENDPOINT, appId, getLabAccessToken());
65-
App[] apps = new Gson().fromJson(result, App[].class);
78+
App[] apps = convertJsonToObject(result, App[].class);
6679
return apps[0];
6780
} catch (Exception ex) {
6881
throw new RuntimeException("Error getting app from lab: " + ex.getMessage());
@@ -74,7 +87,7 @@ public static Lab getLab(String labId) {
7487
try {
7588
result = HttpClientHelper.sendRequestToLab(
7689
LabConstants.LAB_LAB_ENDPOINT, labId, getLabAccessToken());
77-
Lab[] labs = new Gson().fromJson(result, Lab[].class);
90+
Lab[] labs = convertJsonToObject(result, Lab[].class);
7891
return labs[0];
7992
} catch (Exception ex) {
8093
throw new RuntimeException("Error getting lab from lab: " + ex.getMessage());
@@ -89,7 +102,7 @@ private String getUserSecret(String labName){
89102
result = HttpClientHelper.sendRequestToLab(
90103
LabConstants.LAB_USER_SECRET_ENDPOINT, queryMap, getLabAccessToken());
91104

92-
return new Gson().fromJson(result, UserSecret.class).value;
105+
return convertJsonToObject(result, UserSecret.class).value;
93106
} catch (Exception ex) {
94107
throw new RuntimeException("Error getting user secret from lab: " + ex.getMessage());
95108
}

src/integrationtest/java/labapi/User.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,53 @@
33

44
package labapi;
55

6-
import com.google.gson.annotations.SerializedName;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
77
import lombok.Getter;
88
import lombok.Setter;
99

1010
@Getter
1111
public class User
1212
{
13-
@SerializedName("appId")
13+
@JsonProperty("appId")
1414
private String appId;
1515

16-
@SerializedName("objectId")
16+
@JsonProperty("objectId")
1717
private String objectId;
1818

19-
@SerializedName("userType")
19+
@JsonProperty("userType")
2020
private String userType;
2121

22-
@SerializedName("displayName")
22+
@JsonProperty("displayName")
2323
private String displayName;
2424

25-
@SerializedName("licenses")
25+
@JsonProperty("licenses")
2626
private String licenses;
2727

28-
@SerializedName("upn")
28+
@JsonProperty("upn")
2929
private String upn;
3030

31-
@SerializedName("mfa")
31+
@JsonProperty("mfa")
3232
private String mfa;
3333

34-
@SerializedName("protectionPolicy")
34+
@JsonProperty("protectionPolicy")
3535
private String protectionPolicy;
3636

37-
@SerializedName("homeDomain")
37+
@JsonProperty("homeDomain")
3838
private String homeDomain;
3939

40-
@SerializedName("homeUPN")
40+
@JsonProperty("homeUPN")
4141
private String homeUPN;
4242

43-
@SerializedName("b2cProvider")
43+
@JsonProperty("b2cProvider")
4444
private String b2cProvider;
4545

46-
@SerializedName("labName")
46+
@JsonProperty("labName")
4747
private String labName;
4848

49-
@SerializedName("lastUpdatedBy")
49+
@JsonProperty("lastUpdatedBy")
5050
private String lastUpdatedBy;
5151

52-
@SerializedName("lastUpdatedDate")
52+
@JsonProperty("lastUpdatedDate")
5353
private String lastUpdatedDate;
5454

5555
@Setter

src/integrationtest/java/labapi/UserSecret.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
package labapi;
55

6-
import com.google.gson.annotations.SerializedName;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
77

88
public class UserSecret {
99

10-
@SerializedName("secret")
10+
@JsonProperty("secret")
1111
String secret;
1212

13-
@SerializedName("value")
13+
@JsonProperty("value")
1414
String value;
1515
}

src/integrationtest/java/labapi/UserType.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
package labapi;
55

6-
import com.google.gson.annotations.SerializedName;
7-
86
public class UserType {
97
public static final String CLOUD = "cloud";
108
public static final String FEDERATED = "federated";

0 commit comments

Comments
 (0)