Skip to content

Commit de5f0ff

Browse files
authored
Merge pull request #43 from AzureAD/dev
Release v0.3.0-preview
2 parents 27eb113 + 9b0eb7d commit de5f0ff

File tree

77 files changed

+1352
-695
lines changed

Some content is hidden

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

77 files changed

+1352
-695
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
11
# Microsoft Authentication Library (MSAL) for Java
22

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/adal4j.svg)](http://javadoc.io/doc/com.microsoft.azure/adal4j)
6+
7+
|[Getting Started](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki)| [Docs](https://aka.ms/aaddev)| [Support](README.md#community-help-and-support)
8+
| --- | --- | --- |
9+
310
The MSAL library for Java gives your app the ability to begin using the Microsoft Cloud by supporting Microsoft Azure Active Directory and Microsoft Accounts in a converged experience using industry standard OAuth2 and OpenID Connect.
411

12+
13+
## Versions
14+
Current version - 0.3.0-preview
15+
16+
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).
17+
518
The library is currently in preview. During the preview we reserve the right to make changes to the API, cache format, and other mechanisms of this library without notice which you will be required to take along with bug fixes or feature improvements
619
## Contribution
20+
721
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.
822
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.
923
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.
24+
25+
26+
## Build and Run
27+
28+
Refer [this page](https://github.com/AzureAD/microsoft-authentication-library-for-java/wiki/Maven)
29+
30+
## Samples and Documentation
31+
32+
We provide a [full suite of sample applications](https://github.com/Azure-Samples) and [documentation](https://aka.ms/aaddev) to help you get started with learning the Azure Identity system. This includes tutorials for native clients such as Windows, Windows Phone, iOS, macOS, Android, and Linux. We also provide full walkthroughs for authentication flows such as OAuth2, OpenID Connect, Graph API, and other awesome features.
33+
34+
## Community Help and Support
35+
36+
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.
37+
38+
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)
39+
40+
## Security Reporting
41+
42+
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/en-us/security/dd252948) and subscribing to Security Advisory Alerts.
43+
44+
## We Value and Adhere to the Microsoft Open Source Code of Conduct
45+
46+
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 0.3.0-preview
2+
=============
3+
- Added support for FOCI
4+
- Updated public API to return interfaces
5+
- Updated cache to be compatible with MSAL Python and MSAL.NET caches
6+
17
Version 0.2.0-preview
28
=============
39
- Added support for B2C

pom.xml

Lines changed: 25 additions & 2 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>0.2.0-preview</version>
6+
<version>0.3.0-preview</version>
77
<packaging>jar</packaging>
88
<name>msal4j</name>
99
<description>
@@ -155,6 +155,24 @@
155155

156156
<build>
157157
<plugins>
158+
<plugin>
159+
<groupId>org.projectlombok</groupId>
160+
<artifactId>lombok-maven-plugin</artifactId>
161+
<version>1.18.2.0</version>
162+
<executions>
163+
<execution>
164+
<goals>
165+
<goal>delombok</goal>
166+
</goals>
167+
</execution>
168+
</executions>
169+
<configuration>
170+
<sourceDirectory>src/main/java</sourceDirectory>
171+
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
172+
<addOutputDirectory>false</addOutputDirectory>
173+
</configuration>
174+
</plugin>
175+
158176
<plugin>
159177
<groupId>org.apache.maven.plugins</groupId>
160178
<artifactId>maven-jar-plugin</artifactId>
@@ -176,10 +194,14 @@
176194
<argLine>-noverify</argLine>
177195
</configuration>
178196
</plugin>
197+
179198
<plugin>
180199
<groupId>org.apache.maven.plugins</groupId>
181200
<artifactId>maven-javadoc-plugin</artifactId>
182-
<version>2.9.1</version>
201+
<version>3.1.0</version>
202+
<configuration>
203+
<sourcepath>${project.build.directory}/delombok</sourcepath>
204+
</configuration>
183205
<executions>
184206
<execution>
185207
<id>attach-javadocs</id>
@@ -224,6 +246,7 @@
224246
<plugin>
225247
<groupId>org.apache.maven.plugins</groupId>
226248
<artifactId>maven-compiler-plugin</artifactId>
249+
<version>3.7.0</version>
227250
<configuration>
228251
<source>8</source>
229252
<target>8</target>

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,33 +220,31 @@ public void acquireTokenWithAuthorizationCode_B2C_Google(){
220220

221221
private void assertAcquireTokenAAD(LabResponse labResponse){
222222
String authCode = acquireAuthorizationCodeAutomated(labResponse, AuthorityType.AAD);
223-
AuthenticationResult result = acquireTokenInteractiveAAD(labResponse, authCode);
223+
IAuthenticationResult result = acquireTokenInteractiveAAD(labResponse, authCode);
224224

225225
Assert.assertNotNull(result);
226226
Assert.assertNotNull(result.accessToken());
227-
Assert.assertNotNull(result.refreshToken());
228227
Assert.assertNotNull(result.idToken());
229228
// TODO AuthenticationResult should have an getAccountInfo API
230229
// Assert.assertEquals(labResponse.getUser().getUpn(), result.getAccountInfo().getUsername());
231230
}
232231

233232
private void assertAcquireTokenB2C(LabResponse labResponse){
234233
String authCode = acquireAuthorizationCodeAutomated(labResponse, AuthorityType.B2C);
235-
AuthenticationResult result = acquireTokenInteractiveB2C(labResponse, authCode);
234+
IAuthenticationResult result = acquireTokenInteractiveB2C(labResponse, authCode);
236235

237236
Assert.assertNotNull(result);
238237
Assert.assertNotNull(result.accessToken());
239-
Assert.assertNotNull(result.refreshToken());
240238
Assert.assertNotNull(result.idToken());
241239
// TODO AuthenticationResult should have an getAccountInfo API
242240
// Assert.assertEquals(labResponse.getUser().getUpn(), result.getAccountInfo().getUsername());
243241
}
244242

245-
private AuthenticationResult acquireTokenInteractiveAAD(
243+
private IAuthenticationResult acquireTokenInteractiveAAD(
246244
LabResponse labResponse,
247245
String authCode){
248246

249-
AuthenticationResult result;
247+
IAuthenticationResult result;
250248
try {
251249
PublicClientApplication pca = PublicClientApplication.builder(
252250
labResponse.getAppId()).
@@ -267,9 +265,9 @@ private AuthenticationResult acquireTokenInteractiveAAD(
267265
return result;
268266
}
269267

270-
private AuthenticationResult acquireTokenInteractiveB2C(LabResponse labResponse,
268+
private IAuthenticationResult acquireTokenInteractiveB2C(LabResponse labResponse,
271269
String authCode) {
272-
AuthenticationResult result;
270+
IAuthenticationResult result;
273271
try{
274272
IClientCredential credential = ClientCredentialFactory.create("=]Y)_A7LX`]6\"]_PoD!)Lo24");
275273
ConfidentialClientApplication cca = ConfidentialClientApplication.builder(

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,13 @@ private void assertAcquireTokenCommon(String clientId, IClientCredential credent
6565
authority(TestConstants.AUTHORITY_MICROSOFT).
6666
build();
6767

68-
AuthenticationResult result = cca.acquireToken(ClientCredentialParameters
68+
IAuthenticationResult result = cca.acquireToken(ClientCredentialParameters
6969
.builder(Collections.singleton(KEYVAULT_DEFAULT_SCOPE))
7070
.build())
7171
.get();
7272

7373
Assert.assertNotNull(result);
7474
Assert.assertNotNull(result.accessToken());
75-
Assert.assertNull(result.refreshToken());
7675
// TODO AuthenticationResult should have an getAccountInfo API
7776
// Assert.assertEquals(labResponse.getUser().getUpn(), result.getAccountInfo().getUsername());
7877
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void DeviceCodeFlowTest() throws Exception {
7272
};
7373

7474

75-
AuthenticationResult result = pca.acquireToken(DeviceCodeFlowParameters
75+
IAuthenticationResult result = pca.acquireToken(DeviceCodeFlowParameters
7676
.builder(Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
7777
deviceCodeConsumer)
7878
.build())

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private void assertAcquireTokenCommon(NationalCloud cloud) throws Exception{
6666
authority(TestConstants.AUTHORITY_ORGANIZATIONS).
6767
build();
6868

69-
AuthenticationResult result = pca.acquireToken(UserNamePasswordParameters
69+
IAuthenticationResult result = pca.acquireToken(UserNamePasswordParameters
7070
.builder(Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
7171
labResponse.getUser().getUpn(),
7272
password.toCharArray())
@@ -75,7 +75,6 @@ private void assertAcquireTokenCommon(NationalCloud cloud) throws Exception{
7575

7676
Assert.assertNotNull(result);
7777
Assert.assertNotNull(result.accessToken());
78-
Assert.assertNotNull(result.refreshToken());
7978
Assert.assertNotNull(result.idToken());
8079
// TODO AuthenticationResult should have an getAccountInfo API
8180
// Assert.assertEquals(labResponse.getUser().getUpn(), result.getAccountInfo().getUsername());

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void setUp() throws Exception{
3232
authority(msidlab4Authority).
3333
build();
3434

35-
AuthenticationResult result = pca.acquireToken(
35+
IAuthenticationResult result = pca.acquireToken(
3636
UserNamePasswordParameters.builder(Collections.singleton(apiReadScope),
3737
labResponse.getUser().getUpn(),
3838
labResponse.getUser().getPassword().toCharArray()).build()).get();
@@ -51,15 +51,14 @@ public void acquireTokenWithOBO_Managed() throws Exception {
5151
authority(msidlab4Authority).
5252
build();
5353

54-
AuthenticationResult result =
54+
IAuthenticationResult result =
5555
cca.acquireToken(OnBehalfOfParameters.builder(
5656
Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
5757
new UserAssertion(accessToken)).build()).
5858
get();
5959

6060
Assert.assertNotNull(result);
6161
Assert.assertNotNull(result.accessToken());
62-
Assert.assertNotNull(result.refreshToken());
6362
Assert.assertNotNull(result.idToken());
6463
// TODO AuthenticationResult should have an getAccountInfo API
6564
// Assert.assertEquals(labResponse.getUser().getUpn(), result.getAccountInfo().getUsername());

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void setUp() throws Exception {
5050
authority(TestConstants.AUTHORITY_ORGANIZATIONS).
5151
build();
5252

53-
AuthenticationResult result = pca.acquireToken(UserNamePasswordParameters
53+
AuthenticationResult result = (AuthenticationResult)pca.acquireToken(UserNamePasswordParameters
5454
.builder(Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
5555
labResponse.getUser().getUpn(),
5656
password.toCharArray())
@@ -63,7 +63,7 @@ public void setUp() throws Exception {
6363
@Test
6464
public void acquireTokenWithRefreshToken() throws Exception{
6565

66-
AuthenticationResult result = pca.acquireToken(RefreshTokenParameters
66+
IAuthenticationResult result = pca.acquireToken(RefreshTokenParameters
6767
.builder(
6868
Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
6969
refreshToken)
@@ -72,13 +72,12 @@ public void acquireTokenWithRefreshToken() throws Exception{
7272

7373
Assert.assertNotNull(result);
7474
Assert.assertNotNull(result.accessToken());
75-
Assert.assertNotNull(result.refreshToken());
7675
Assert.assertNotNull(result.idToken());
7776
}
7877

7978
@Test(expectedExceptions = ExecutionException.class)
8079
public void acquireTokenWithRefreshToken_WrongScopes() throws Exception{
81-
AuthenticationResult result = pca.acquireToken(RefreshTokenParameters
80+
IAuthenticationResult result = pca.acquireToken(RefreshTokenParameters
8281
.builder(
8382
Collections.singleton(TestConstants.KEYVAULT_DEFAULT_SCOPE),
8483
refreshToken)

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void assertAcquireTokenCommon(LabResponse labResponse, String password)
100100
authority(TestConstants.AUTHORITY_ORGANIZATIONS).
101101
build();
102102

103-
AuthenticationResult result = pca.acquireToken(UserNamePasswordParameters.
103+
IAuthenticationResult result = pca.acquireToken(UserNamePasswordParameters.
104104
builder(Collections.singleton(TestConstants.GRAPH_DEFAULT_SCOPE),
105105
labResponse.getUser().getUpn(),
106106
password.toCharArray())
@@ -109,7 +109,6 @@ public void assertAcquireTokenCommon(LabResponse labResponse, String password)
109109

110110
Assert.assertNotNull(result);
111111
Assert.assertNotNull(result.accessToken());
112-
Assert.assertNotNull(result.refreshToken());
113112
Assert.assertNotNull(result.idToken());
114113
// TODO AuthenticationResult should have an getAccountInfo API
115114
// Assert.assertEquals(labResponse.getUser().getUpn(), result.getAccountInfo().getUsername());
@@ -129,7 +128,7 @@ public void acquireTokenWithUsernamePassword_B2C_CustomAuthority() throws Except
129128
b2cAuthority(TestConstants.B2C_AUTHORITY_ROPC).
130129
build();
131130

132-
AuthenticationResult result = pca.acquireToken(UserNamePasswordParameters.
131+
IAuthenticationResult result = pca.acquireToken(UserNamePasswordParameters.
133132
builder(Collections.singleton(TestConstants.B2C_READ_SCOPE),
134133
labResponse.getUser().getUpn(),
135134
password.toCharArray())
@@ -138,7 +137,6 @@ public void acquireTokenWithUsernamePassword_B2C_CustomAuthority() throws Except
138137

139138
Assert.assertNotNull(result);
140139
Assert.assertNotNull(result.accessToken());
141-
Assert.assertNotNull(result.refreshToken());
142140
// TODO uncomment once service fixes this for ROPC flow
143141
// Assert.assertNotNull(result.idToken());
144142
}
@@ -157,7 +155,7 @@ public void acquireTokenWithUsernamePassword_B2C_LoginMicrosoftOnline() throws E
157155
b2cAuthority(TestConstants.B2C_MICROSOFTLOGIN_ROPC).
158156
build();
159157

160-
AuthenticationResult result = pca.acquireToken(UserNamePasswordParameters.
158+
IAuthenticationResult result = pca.acquireToken(UserNamePasswordParameters.
161159
builder(Collections.singleton(TestConstants.B2C_READ_SCOPE),
162160
labResponse.getUser().getUpn(),
163161
password.toCharArray())
@@ -166,7 +164,6 @@ public void acquireTokenWithUsernamePassword_B2C_LoginMicrosoftOnline() throws E
166164

167165
Assert.assertNotNull(result);
168166
Assert.assertNotNull(result.accessToken());
169-
Assert.assertNotNull(result.refreshToken());
170167
// TODO uncomment once service fixes this for ROPC flow
171168
// Assert.assertNotNull(result.idToken());
172169
}

src/integrationtest/java/labapi/KeyVaultSecretsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public String doAuthenticate(String authorization, String resource, String scope
6363
}
6464

6565
private String requestAccessTokenForAutomation() {
66-
AuthenticationResult result;
66+
IAuthenticationResult result;
6767
try{
6868
ConfidentialClientApplication cca = ConfidentialClientApplication.builder(
6969
CLIENT_ID, getClientCredentialFromKeyStore()).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
class AccessTokenCacheEntity extends Credential {
3838

3939
@SerializedName("credential_type")
40-
private String credentialType = "AccessToken";
40+
private String credentialType;
4141

4242
@SerializedName("realm")
4343
protected String realm;

0 commit comments

Comments
 (0)