Skip to content

Commit 8815e05

Browse files
committed
# Conflicts: # README.md # changelog.txt # msal4j-brokers/pom.xml # msal4j-sdk/README.md # msal4j-sdk/bnd.bnd # msal4j-sdk/pom.xml # src/integrationtest/java/com.microsoft.aad.msal4j/InstanceDiscoveryTest.java # src/integrationtest/java/com.microsoft.aad.msal4j/InvalidAuthorityIT.java # src/main/java/com/microsoft/aad/msal4j/CIAMAuthority.java # src/samples/msal-b2c-web-sample/pom.xml # src/samples/msal-obo-sample/pom.xml # src/samples/msal-web-sample/pom.xml
2 parents 41018ef + 37662cd commit 8815e05

File tree

332 files changed

+51
-218
lines changed

Some content is hidden

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

332 files changed

+51
-218
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121

2222
# Initializes the CodeQL tools for scanning.
2323
- name: Initialize CodeQL
24-
uses: github/codeql-action/init@v2
24+
uses: github/codeql-action/init@v1
2525
# Override language selection by uncommenting this and choosing your languages
2626
# with:
2727
# languages: go, javascript, csharp, python, cpp, java
2828

2929
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
3030
# If this step fails, then you should remove it and run the build manually (see below).
3131
- name: Autobuild
32-
uses: github/codeql-action/autobuild@v2
32+
uses: github/codeql-action/autobuild@v1
3333

3434
# ℹ️ Command-line programs to run using the OS shell.
3535
# 📚 https://git.io/JvXDl
@@ -43,4 +43,4 @@ jobs:
4343
# make release
4444

4545
- name: Perform CodeQL Analysis
46-
uses: github/codeql-action/analyze@v2
46+
uses: github/codeql-action/analyze@v1

msal4j-sdk/.gitignore renamed to .gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*.rar
2121

2222
# Intellij
23-
../.idea/
23+
.idea/
2424

2525
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2626
hs_err_pid*
File renamed without changes.

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/IBroker.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/MsalAzureSDKException.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

msal4j-sdk/src/test/java/com/microsoft/aad/msal4j/ClientCertificatePkcs12Test.java

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ private void assertAcquireTokenInstanceAware(User user) {
206206
Assert.assertEquals(result.account().environment(), cachedResult.environment());
207207
}
208208

209-
//@Test
209+
@Test
210210
public void acquireTokensInHomeAndGuestClouds_ArlingtonAccount() throws MalformedURLException, ExecutionException, InterruptedException {
211211
acquireTokensInHomeAndGuestClouds(AzureEnvironment.AZURE_US_GOVERNMENT);
212212
}
213213

214-
//@Test
214+
@Test
215215
public void acquireTokensInHomeAndGuestClouds_MooncakeAccount() throws MalformedURLException, ExecutionException, InterruptedException {
216216
acquireTokensInHomeAndGuestClouds(AzureEnvironment.AZURE_CHINA);
217217
}

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AcquireTokenByAppProviderSupplier.java renamed to src/main/java/com/microsoft/aad/msal4j/AcquireTokenByAppProviderSupplier.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import java.util.concurrent.CompletableFuture;
77
import java.util.concurrent.ExecutionException;
88

9-
/** Disclaimer - This class is meant to be used by the Azure SDK team only.
10-
* Any other teams are discouraged from using this class to prevent any side effects.
11-
*/
129
class AcquireTokenByAppProviderSupplier extends AuthenticationResultSupplier {
1310

1411
private static final int TWO_HOURS = 2*3600;
@@ -68,16 +65,9 @@ AuthenticationResult execute() throws Exception {
6865

6966
public AuthenticationResult fetchTokenUsingAppTokenProvider(AppTokenProviderParameters appTokenProviderParameters) throws ExecutionException, InterruptedException {
7067

71-
TokenProviderResult tokenProviderResult;
68+
CompletableFuture<TokenProviderResult> completableFuture = this.clientCredentialRequest.appTokenProvider.apply(appTokenProviderParameters);
7269

73-
try{
74-
75-
CompletableFuture<TokenProviderResult> completableFuture = this.clientCredentialRequest.appTokenProvider.apply(appTokenProviderParameters);
76-
tokenProviderResult = completableFuture.get();
77-
78-
} catch (Exception ex){
79-
throw new MsalAzureSDKException(ex);
80-
}
70+
TokenProviderResult tokenProviderResult = completableFuture.get();
8171

8272
validateAndUpdateTokenProviderResult(tokenProviderResult);
8373

@@ -88,5 +78,6 @@ public AuthenticationResult fetchTokenUsingAppTokenProvider(AppTokenProviderPara
8878
.expiresOn(tokenProviderResult.getExpiresInSeconds())
8979
.refreshOn(tokenProviderResult.getRefreshInSeconds())
9080
.build();
81+
9182
}
9283
}

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationErrorCode.java renamed to src/main/java/com/microsoft/aad/msal4j/AuthenticationErrorCode.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,4 @@ public class AuthenticationErrorCode {
115115
* A JWT parsing failure, indicating the JWT provided to MSAL is of invalid format.
116116
*/
117117
public final static String INVALID_JWT = "invalid_jwt";
118-
/**
119-
* Indicates that a Broker implementation is missing from the device, such as when an app developer
120-
* does not include one of our broker packages as a dependency in their project, or otherwise cannot
121-
* be accessed by MSAL Java*/
122-
public final static String MISSING_BROKER = "missing_broker";
123118
}

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationResultSupplier.java renamed to src/main/java/com/microsoft/aad/msal4j/AuthenticationResultSupplier.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
package com.microsoft.aad.msal4j;
55

66

7+
import java.nio.charset.StandardCharsets;
78
import java.net.MalformedURLException;
9+
import java.util.Base64;
10+
11+
import java.io.UnsupportedEncodingException;
812
import java.net.URI;
913
import java.net.URISyntaxException;
1014
import java.net.URL;
11-
import java.nio.charset.StandardCharsets;
1215
import java.security.MessageDigest;
1316
import java.security.NoSuchAlgorithmException;
14-
import java.util.Base64;
1517
import java.util.concurrent.CompletionException;
1618
import java.util.function.Supplier;
1719

@@ -112,8 +114,8 @@ private void logResult(AuthenticationResult result, HttpHeaders headers) {
112114
.refreshToken());
113115
if (clientApplication.logPii()) {
114116
clientApplication.log.debug(LogHelper.createMessage(String.format(
115-
"Access Token with hash '%s' and Refresh Token with hash '%s' returned",
116-
accessTokenHash, refreshTokenHash),
117+
"Access Token with hash '%s' and Refresh Token with hash '%s' returned",
118+
accessTokenHash, refreshTokenHash),
117119
headers.getHeaderCorrelationIdValue()));
118120
} else {
119121
clientApplication.log.debug(
@@ -124,7 +126,7 @@ private void logResult(AuthenticationResult result, HttpHeaders headers) {
124126
} else {
125127
if (clientApplication.logPii()) {
126128
clientApplication.log.debug(LogHelper.createMessage(String.format(
127-
"Access Token with hash '%s' returned", accessTokenHash),
129+
"Access Token with hash '%s' returned", accessTokenHash),
128130
headers.getHeaderCorrelationIdValue()));
129131
} else {
130132
clientApplication.log.debug(LogHelper.createMessage(
@@ -147,9 +149,6 @@ private void logException(Exception ex) {
147149
clientApplication.log.debug(logMessage, ex);
148150
return;
149151
}
150-
} else if (ex instanceof MsalAzureSDKException) {
151-
clientApplication.log.debug(ex.getMessage(), ex);
152-
return;
153152
}
154153

155154
clientApplication.log.error(logMessage, ex);
@@ -164,7 +163,11 @@ private ApiEvent initializeApiEvent(MsalRequest msalRequest) {
164163
apiEvent.setRequestId(msalRequest.requestContext().telemetryRequestId());
165164
apiEvent.setWasSuccessful(false);
166165

167-
apiEvent.setIsConfidentialClient(clientApplication instanceof ConfidentialClientApplication);
166+
if (clientApplication instanceof ConfidentialClientApplication) {
167+
apiEvent.setIsConfidentialClient(true);
168+
} else {
169+
apiEvent.setIsConfidentialClient(false);
170+
}
168171

169172
try {
170173
Authority authenticationAuthority = clientApplication.authenticationAuthority;

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/ClientCertificate.java renamed to src/main/java/com/microsoft/aad/msal4j/ClientCertificate.java

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
package com.microsoft.aad.msal4j;
55

6-
import lombok.Getter;
7-
import lombok.experimental.Accessors;
8-
96
import java.io.IOException;
107
import java.io.InputStream;
118
import java.lang.reflect.InvocationTargetException;
@@ -22,11 +19,10 @@
2219
import java.security.cert.CertificateException;
2320
import java.security.cert.X509Certificate;
2421
import java.security.interfaces.RSAPrivateKey;
25-
import java.util.ArrayList;
26-
import java.util.Arrays;
27-
import java.util.Base64;
28-
import java.util.Enumeration;
29-
import java.util.List;
22+
import java.util.*;
23+
24+
import lombok.Getter;
25+
import lombok.experimental.Accessors;
3026

3127
final class ClientCertificate implements IClientCertificate {
3228

@@ -101,7 +97,14 @@ static ClientCertificate create(InputStream pkcs12Certificate, String password)
10197
final KeyStore keystore = KeyStore.getInstance("PKCS12");
10298
keystore.load(pkcs12Certificate, password.toCharArray());
10399

104-
String alias = getPrivateKeyAlias(keystore);
100+
final Enumeration<String> aliases = keystore.aliases();
101+
if (!aliases.hasMoreElements()) {
102+
throw new IllegalArgumentException("certificate not loaded from input stream");
103+
}
104+
String alias = aliases.nextElement();
105+
if (aliases.hasMoreElements()) {
106+
throw new IllegalArgumentException("more than one certificate alias found in input stream");
107+
}
105108

106109
ArrayList<X509Certificate> publicKeyCertificateChain = new ArrayList<>();
107110
PrivateKey privateKey = (PrivateKey) keystore.getKey(alias, password.toCharArray());
@@ -120,26 +123,6 @@ static ClientCertificate create(InputStream pkcs12Certificate, String password)
120123
return new ClientCertificate(privateKey, publicKeyCertificateChain);
121124
}
122125

123-
static String getPrivateKeyAlias(KeyStore keystore) throws KeyStoreException {
124-
String alias = null;
125-
final Enumeration<String> aliases = keystore.aliases();
126-
while (aliases.hasMoreElements()) {
127-
String currentAlias = aliases.nextElement();
128-
if (keystore.entryInstanceOf(currentAlias, KeyStore.PrivateKeyEntry.class)) {
129-
if (alias != null) {
130-
throw new IllegalArgumentException("more than one certificate alias found in input stream");
131-
}
132-
alias = currentAlias;
133-
}
134-
}
135-
136-
if (alias == null) {
137-
throw new IllegalArgumentException("certificate not loaded from input stream");
138-
}
139-
140-
return alias;
141-
}
142-
143126
static ClientCertificate create(final PrivateKey key, final X509Certificate publicKeyCertificate) {
144127
return new ClientCertificate(key, Arrays.asList(publicKeyCertificate));
145128
}

msal4j-sdk/src/test/java/com/microsoft/aad/msal4j/CacheFormatTests.java renamed to src/test/java/com/microsoft/aad/msal4j/CacheFormatTests.java

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

44
package com.microsoft.aad.msal4j;
55

6+
import com.fasterxml.jackson.databind.DeserializationFeature;
7+
import com.fasterxml.jackson.databind.ObjectMapper;
68
import com.nimbusds.oauth2.sdk.ParseException;
79
import com.nimbusds.oauth2.sdk.http.HTTPResponse;
810
import com.nimbusds.oauth2.sdk.util.JSONObjectUtils;
@@ -24,6 +26,9 @@
2426
import java.nio.charset.StandardCharsets;
2527
import java.nio.file.Files;
2628
import java.nio.file.Paths;
29+
import java.sql.Time;
30+
import java.time.Duration;
31+
import java.time.Instant;
2732
import java.util.*;
2833

2934
import static com.microsoft.aad.msal4j.Constants.POINT_DELIMITER;

0 commit comments

Comments
 (0)