Skip to content

Commit

Permalink
Merge pull request #151 from AzureAD/dev
Browse files Browse the repository at this point in the history
1.2.0 release
  • Loading branch information
sangonzal authored Dec 14, 2019
2 parents c6d9599 + e871707 commit 29bd90b
Show file tree
Hide file tree
Showing 62 changed files with 1,026 additions and 1,215 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Quick links:
| --- | --- | --- | --- |

## Install
Current version - 1.1.0
Current version - 1.2.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).

Expand All @@ -24,13 +24,13 @@ You can get the msal4j package through Maven or Gradle.
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
```
### Gradle

```
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.1.0'
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.2.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.2.0
=============
- Added support for ADFS 2019
- Added option to add application name and version for telemetry
- Bug fix: support for ClientCredential on Windows for JDK12+ #128

Version 1.1.0
=============
- Added support for configuring HTTP client
Expand Down
2 changes: 1 addition & 1 deletion 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.1.0</version>
<version>1.2.0</version>
<packaging>jar</packaging>
<name>msal4j</name>
<description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

package com.microsoft.aad.msal4j;

import labapi.AppIdentityProvider;
import labapi.FederationProvider;
import labapi.LabResponse;
import labapi.LabUserProvider;
import labapi.NationalCloud;
import labapi.*;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -50,21 +46,19 @@ public void acquireTokenSilent_OrganizationAuthority_TokenRefreshed() throws Exc
public void acquireTokenSilent_LabAuthority_TokenNotRefreshed() throws Exception {
// Access token should be returned from cache, and not using refresh token

LabResponse labResponse = labUserProvider.getDefaultUser(
NationalCloud.AZURE_CLOUD,
false);
String password = labUserProvider.getUserPassword(labResponse.getUser());
String labAuthority = TestConstants.MICROSOFT_AUTHORITY_HOST + labResponse.getUser().getTenantId();
User user = labUserProvider.getDefaultUser();

String labAuthority = TestConstants.ORGANIZATIONS_AUTHORITY;

PublicClientApplication pca = PublicClientApplication.builder(
labResponse.getAppId()).
user.getAppId()).
authority(labAuthority).
build();

IAuthenticationResult result = pca.acquireToken(UserNamePasswordParameters.
builder(Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
labResponse.getUser().getUpn(),
password.toCharArray())
user.getUpn(),
user.getPassword().toCharArray())
.build())
.get();

Expand All @@ -85,20 +79,17 @@ public void acquireTokenSilent_LabAuthority_TokenNotRefreshed() throws Exception
@Test
public void acquireTokenSilent_ForceRefresh() throws Exception {

LabResponse labResponse = labUserProvider.getDefaultUser(
NationalCloud.AZURE_CLOUD,
false);
String password = labUserProvider.getUserPassword(labResponse.getUser());
User user = labUserProvider.getDefaultUser();

PublicClientApplication pca = PublicClientApplication.builder(
labResponse.getAppId()).
user.getAppId()).
authority(TestConstants.ORGANIZATIONS_AUTHORITY).
build();

IAuthenticationResult result = pca.acquireToken(UserNamePasswordParameters.
builder(Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
labResponse.getUser().getUpn(),
password.toCharArray())
user.getUpn(),
user.getPassword().toCharArray())
.build())
.get();

Expand All @@ -124,24 +115,20 @@ public void acquireTokenSilent_MultipleAccountsInCache_UseCorrectAccount() throw
IPublicClientApplication pca = getPublicClientApplicationWithTokensInCache();

// get lab user for different account
LabResponse labResponse = labUserProvider.getAdfsUser(
FederationProvider.ADFSV4,
true,
false);
String password = labUserProvider.getUserPassword(labResponse.getUser());
User user = labUserProvider.getFederatedAdfsUser(FederationProvider.ADFS_4);

// acquire token for different account
pca.acquireToken(UserNamePasswordParameters.
builder(Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
labResponse.getUser().getUpn(),
password.toCharArray())
user.getUpn(),
user.getPassword().toCharArray())
.build())
.get();

Set<IAccount> accounts = pca.getAccounts().join();
IAccount account = accounts.stream().filter(
x -> x.username().equalsIgnoreCase(
labResponse.getUser().getUpn())).findFirst().orElse(null);
user.getUpn())).findFirst().orElse(null);

SilentParameters parameters = SilentParameters.builder(
Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE), account).
Expand All @@ -153,7 +140,7 @@ public void acquireTokenSilent_MultipleAccountsInCache_UseCorrectAccount() throw
Assert.assertNotNull(result);
Assert.assertNotNull(result.accessToken());
Assert.assertNotNull(result.idToken());
Assert.assertEquals(result.account().username(), labResponse.getUser().getUpn());
Assert.assertEquals(result.account().username(), user.getUpn());
}

@Test
Expand All @@ -163,10 +150,8 @@ public void acquireTokenSilent_usingCommonAuthority_returnCachedAt() throws Exce

@Test
public void acquireTokenSilent_usingTenantSpecificAuthority_returnCachedAt() throws Exception {
LabResponse labResponse = labUserProvider.getDefaultUser(
NationalCloud.AZURE_CLOUD,
false);
String tenantSpecificAuthority = TestConstants.MICROSOFT_AUTHORITY_HOST + labResponse.getUser().getTenantId();
String tenantSpecificAuthority = TestConstants.ORGANIZATIONS_AUTHORITY;

acquireTokenSilent_returnCachedTokens(tenantSpecificAuthority);
}

Expand Down Expand Up @@ -229,20 +214,17 @@ private IConfidentialClientApplication getConfidentialClientApplications() throw

private void acquireTokenSilent_returnCachedTokens(String authority) throws Exception {

LabResponse labResponse = labUserProvider.getDefaultUser(
NationalCloud.AZURE_CLOUD,
false);
String password = labUserProvider.getUserPassword(labResponse.getUser());
User user = labUserProvider.getDefaultUser();

PublicClientApplication pca = PublicClientApplication.builder(
labResponse.getAppId()).
user.getAppId()).
authority(authority).
build();

IAuthenticationResult interactiveAuthResult = pca.acquireToken(UserNamePasswordParameters.
builder(Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
labResponse.getUser().getUpn(),
password.toCharArray())
user.getUpn(),
user.getPassword().toCharArray())
.build())
.get();

Expand All @@ -260,21 +242,18 @@ private void acquireTokenSilent_returnCachedTokens(String authority) throws Exce

private IPublicClientApplication getPublicClientApplicationWithTokensInCache()
throws Exception {
LabResponse labResponse = labUserProvider.getDefaultUser(
NationalCloud.AZURE_CLOUD,
false);
String password = labUserProvider.getUserPassword(labResponse.getUser());
User user = labUserProvider.getDefaultUser();

PublicClientApplication pca = PublicClientApplication.builder(
labResponse.getAppId()).
user.getAppId()).
authority(TestConstants.ORGANIZATIONS_AUTHORITY).
build();

pca.acquireToken(
UserNamePasswordParameters.builder(
Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
labResponse.getUser().getUpn(),
password.toCharArray())
user.getUpn(),
user.getPassword().toCharArray())
.build()).get();
return pca;
}
Expand Down
Loading

0 comments on commit 29bd90b

Please sign in to comment.