Skip to content

Commit

Permalink
Merge pull request #162 from AzureAD/dev
Browse files Browse the repository at this point in the history
1.3.0 release
  • Loading branch information
sangonzal authored Jan 10, 2020
2 parents 29bd90b + d610659 commit 4fbf681
Show file tree
Hide file tree
Showing 46 changed files with 660 additions and 308 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@ Quick links:
| --- | --- | --- | --- |

## Install
Current version - 1.2.0

The library supports the following Java environments:
- Java 8 (or higher)

Current version - 1.3.0

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

You can get the msal4j package through Maven or Gradle.

### Maven

Find [the latest package in the Maven repository](https://mvnrepository.com/artifact/com.microsoft.azure/msal4j).
```
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
</dependency>
```
### Gradle

```
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.2.0'
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.3.0'
```

## Usage
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 1.3.0
=============
- Added option to pass in AAD instance discovery data
- Removed runtime dependency on commons-codec.commons-codec, org.apache.commons.commons-text, org.apache.httpcomponents.httpclient, com.google.code.gson
- Added runtime dependency on com.fasterxml.jackson.databind

Version 1.2.0
=============
- Added support for ADFS 2019
Expand Down
1 change: 1 addition & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.anyConstructor.addConstructorProperties=true
33 changes: 16 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
<packaging>jar</packaging>
<name>msal4j</name>
<description>
Expand Down Expand Up @@ -38,33 +38,31 @@
<artifactId>oauth2-oidc-sdk</artifactId>
<version>6.5</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.7</version>
<version>1.7.28</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.1</version>
</dependency>


<!-- test dependencies -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down Expand Up @@ -99,6 +97,7 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
Expand Down
14 changes: 7 additions & 7 deletions src/integrationtest/java/labapi/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@

package labapi;

import com.google.gson.annotations.SerializedName;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;

@Getter
public class App {

@SerializedName("appType")
@JsonProperty("appType")
String appType;

@SerializedName("appName")
@JsonProperty("appName")
String appName;

@SerializedName("appId")
@JsonProperty("appId")
String appId;

@SerializedName("redirectUri")
@JsonProperty("redirectUri")
String redirectUri;

@SerializedName("authority")
@JsonProperty("authority")
String authority;

@SerializedName("labName")
@JsonProperty("labName")
String labName;

}
14 changes: 7 additions & 7 deletions src/integrationtest/java/labapi/Lab.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@

package labapi;

import com.google.gson.annotations.SerializedName;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;

@Getter
public class Lab {
@SerializedName("labName")
@JsonProperty("labName")
String labName;

@SerializedName("domain")
@JsonProperty("domain")
String domain;

@SerializedName("tenantId")
@JsonProperty("tenantId")
String tenantId;

@SerializedName("federationProvider")
@JsonProperty("federationProvider")
String federationProvider;

@SerializedName("azureEnvironment")
@JsonProperty("azureEnvironment")
String azureEnvironment;

@SerializedName("authority")
@JsonProperty("authority")
String authority;
}
23 changes: 18 additions & 5 deletions src/integrationtest/java/labapi/LabService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

package labapi;

import com.google.gson.Gson;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.aad.msal4j.*;

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

static ConfidentialClientApplication labApp;

static ObjectMapper mapper = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

static <T> T convertJsonToObject(final String json, final Class<T> clazz) {
try {
return mapper.readValue(json, clazz);
} catch (JsonProcessingException e) {
throw new RuntimeException("JsonProcessingException: " + e.getMessage(), e);
}
}

static void initLabApp() throws MalformedURLException {
KeyVaultSecretsProvider keyVaultSecretsProvider = new KeyVaultSecretsProvider();

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

User[] users = new Gson().fromJson(result, User[].class);
User[] users = convertJsonToObject(result, User[].class);
User user = users[0];
user.setPassword(getUserSecret(user.getLabName()));
if (query.parameters.containsKey(UserQueryParameters.FEDERATION_PROVIDER)) {
Expand All @@ -62,7 +75,7 @@ public static App getApp(String appId){
try {
String result = HttpClientHelper.sendRequestToLab(
LabConstants.LAB_APP_ENDPOINT, appId, getLabAccessToken());
App[] apps = new Gson().fromJson(result, App[].class);
App[] apps = convertJsonToObject(result, App[].class);
return apps[0];
} catch (Exception ex) {
throw new RuntimeException("Error getting app from lab: " + ex.getMessage());
Expand All @@ -74,7 +87,7 @@ public static Lab getLab(String labId) {
try {
result = HttpClientHelper.sendRequestToLab(
LabConstants.LAB_LAB_ENDPOINT, labId, getLabAccessToken());
Lab[] labs = new Gson().fromJson(result, Lab[].class);
Lab[] labs = convertJsonToObject(result, Lab[].class);
return labs[0];
} catch (Exception ex) {
throw new RuntimeException("Error getting lab from lab: " + ex.getMessage());
Expand All @@ -89,7 +102,7 @@ private String getUserSecret(String labName){
result = HttpClientHelper.sendRequestToLab(
LabConstants.LAB_USER_SECRET_ENDPOINT, queryMap, getLabAccessToken());

return new Gson().fromJson(result, UserSecret.class).value;
return convertJsonToObject(result, UserSecret.class).value;
} catch (Exception ex) {
throw new RuntimeException("Error getting user secret from lab: " + ex.getMessage());
}
Expand Down
30 changes: 15 additions & 15 deletions src/integrationtest/java/labapi/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,53 @@

package labapi;

import com.google.gson.annotations.SerializedName;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;

@Getter
public class User
{
@SerializedName("appId")
@JsonProperty("appId")
private String appId;

@SerializedName("objectId")
@JsonProperty("objectId")
private String objectId;

@SerializedName("userType")
@JsonProperty("userType")
private String userType;

@SerializedName("displayName")
@JsonProperty("displayName")
private String displayName;

@SerializedName("licenses")
@JsonProperty("licenses")
private String licenses;

@SerializedName("upn")
@JsonProperty("upn")
private String upn;

@SerializedName("mfa")
@JsonProperty("mfa")
private String mfa;

@SerializedName("protectionPolicy")
@JsonProperty("protectionPolicy")
private String protectionPolicy;

@SerializedName("homeDomain")
@JsonProperty("homeDomain")
private String homeDomain;

@SerializedName("homeUPN")
@JsonProperty("homeUPN")
private String homeUPN;

@SerializedName("b2cProvider")
@JsonProperty("b2cProvider")
private String b2cProvider;

@SerializedName("labName")
@JsonProperty("labName")
private String labName;

@SerializedName("lastUpdatedBy")
@JsonProperty("lastUpdatedBy")
private String lastUpdatedBy;

@SerializedName("lastUpdatedDate")
@JsonProperty("lastUpdatedDate")
private String lastUpdatedDate;

@Setter
Expand Down
6 changes: 3 additions & 3 deletions src/integrationtest/java/labapi/UserSecret.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

package labapi;

import com.google.gson.annotations.SerializedName;
import com.fasterxml.jackson.annotation.JsonProperty;

public class UserSecret {

@SerializedName("secret")
@JsonProperty("secret")
String secret;

@SerializedName("value")
@JsonProperty("value")
String value;
}
2 changes: 0 additions & 2 deletions src/integrationtest/java/labapi/UserType.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

package labapi;

import com.google.gson.annotations.SerializedName;

public class UserType {
public static final String CLOUD = "cloud";
public static final String FEDERATED = "federated";
Expand Down
Loading

0 comments on commit 4fbf681

Please sign in to comment.