Skip to content

Commit 6deb186

Browse files
authored
compatibility with jackson 2.6.7 and json-smart 1.3.1 (#242)
compatibility with jackson 2.6.7 and json-smart 1.3.1
1 parent df4e339 commit 6deb186

File tree

7 files changed

+20
-21
lines changed

7 files changed

+20
-21
lines changed

lombok.config

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/integrationtest/java/labapi/LabService.java

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

44
package labapi;
55

6-
import com.fasterxml.jackson.core.JsonProcessingException;
76
import com.fasterxml.jackson.databind.DeserializationFeature;
87
import com.fasterxml.jackson.databind.ObjectMapper;
98
import com.microsoft.aad.msal4j.*;
109

10+
import java.io.IOException;
1111
import java.net.MalformedURLException;
1212
import java.util.Collections;
1313
import java.util.HashMap;
@@ -24,8 +24,8 @@ public class LabService {
2424
static <T> T convertJsonToObject(final String json, final Class<T> clazz) {
2525
try {
2626
return mapper.readValue(json, clazz);
27-
} catch (JsonProcessingException e) {
28-
throw new RuntimeException("JsonProcessingException: " + e.getMessage(), e);
27+
} catch (IOException e) {
28+
throw new RuntimeException("JSON processing error: " + e.getMessage(), e);
2929
}
3030
}
3131

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public class AuthenticationErrorCode {
9797
public final static String THROTTLED_REQUEST = "throttled_request";
9898

9999
/**
100-
* A JsonProcessingException was thrown, indicating the JSON provided to MSAL is of invalid format.
100+
* A JSON processing failure, indicating the JSON provided to MSAL is of invalid format.
101101
*/
102102
public final static String INVALID_JSON = "invalid_json";
103103
}

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

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

66
import com.fasterxml.jackson.annotation.JsonProperty;
7-
import lombok.AccessLevel;
8-
import lombok.Builder;
9-
import lombok.Getter;
7+
import lombok.*;
108
import lombok.experimental.Accessors;
119

1210
import java.util.*;
1311

1412
@Accessors(fluent = true)
1513
@Getter(AccessLevel.PACKAGE)
1614
@Builder
15+
@NoArgsConstructor
16+
@AllArgsConstructor
1717
class InstanceDiscoveryMetadataEntry {
1818

1919
@JsonProperty("preferred_network")

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
import com.fasterxml.jackson.annotation.JsonInclude;
77
import com.fasterxml.jackson.core.JsonParser;
8-
import com.fasterxml.jackson.core.JsonProcessingException;
98
import com.fasterxml.jackson.databind.DeserializationFeature;
109
import com.fasterxml.jackson.databind.ObjectMapper;
1110
import com.fasterxml.jackson.databind.node.ObjectNode;
1211
import com.fasterxml.jackson.databind.JsonNode;
1312

13+
import java.io.IOException;
1414
import java.util.Iterator;
1515
import java.util.Set;
1616

@@ -27,7 +27,7 @@ class JsonHelper {
2727
static <T> T convertJsonToObject(final String json, final Class<T> clazz) {
2828
try {
2929
return mapper.readValue(json, clazz);
30-
} catch (JsonProcessingException e) {
30+
} catch (IOException e) {
3131
throw new MsalClientException(e);
3232
}
3333
}
@@ -38,7 +38,7 @@ static <T> T convertJsonToObject(final String json, final Class<T> clazz) {
3838
static void validateJsonFormat(String jsonString) {
3939
try {
4040
mapper.readTree(jsonString);
41-
} catch (JsonProcessingException e) {
41+
} catch (IOException e) {
4242
throw new MsalClientException(e.getMessage(), AuthenticationErrorCode.INVALID_JSON);
4343
}
4444
}
@@ -72,7 +72,7 @@ static String mergeJSONString(String mainJsonString, String addJsonString) {
7272
try {
7373
mainJson = mapper.readTree(mainJsonString);
7474
addJson = mapper.readTree(addJsonString);
75-
} catch (JsonProcessingException e) {
75+
} catch (IOException e) {
7676
throw new MsalClientException(e.getMessage(), AuthenticationErrorCode.INVALID_JSON);
7777
}
7878

@@ -95,14 +95,14 @@ static String mergeJSONString(Set<String> jsonStrings) {
9595
} else {
9696
return "";
9797
}
98-
} catch (JsonProcessingException e) {
98+
} catch (IOException e) {
9999
throw new MsalClientException(e.getMessage(), AuthenticationErrorCode.INVALID_JSON);
100100
}
101101

102102
while (jsons.hasNext()) {
103103
try {
104104
addJson = mapper.readTree(jsons.next());
105-
} catch (JsonProcessingException e) {
105+
} catch (IOException e) {
106106
throw new MsalClientException(e.getMessage(), AuthenticationErrorCode.INVALID_JSON);
107107
}
108108
mergeJSONNode(mainJson, addJson);

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

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

66
import com.fasterxml.jackson.annotation.JsonProperty;
7-
import com.fasterxml.jackson.core.JsonProcessingException;
87
import com.fasterxml.jackson.databind.JsonNode;
98
import com.fasterxml.jackson.databind.node.ObjectNode;
109

10+
import java.io.IOException;
1111
import java.util.*;
1212
import java.util.concurrent.locks.ReadWriteLock;
1313
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -147,7 +147,7 @@ public String serialize() {
147147
}
148148
return JsonHelper.mapper.writeValueAsString(this);
149149
}
150-
catch (JsonProcessingException e) {
150+
catch (IOException e) {
151151
throw new MsalClientException(e);
152152
}finally {
153153
lock.readLock().unlock();

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,28 @@ static TokenResponse parseJsonObject(final JSONObject jsonObject)
5252
// use an empty string in order to avoid an IllegalArgumentException from OIDCTokens.
5353
String idTokenValue = "";
5454
if (jsonObject.containsKey("id_token")) {
55-
idTokenValue = jsonObject.getAsString("id_token");
55+
idTokenValue = JSONObjectUtils.getString(jsonObject, "id_token");
5656
}
5757

5858
// Parse value
5959
String scopeValue = null;
6060
if (jsonObject.containsKey("scope")) {
61-
scopeValue = jsonObject.getAsString("scope");
61+
scopeValue = JSONObjectUtils.getString(jsonObject, "scope");
6262
}
6363

6464
String clientInfo = null;
6565
if (jsonObject.containsKey("client_info")) {
66-
clientInfo = jsonObject.getAsString("client_info");
66+
clientInfo = JSONObjectUtils.getString(jsonObject, "client_info");
6767
}
6868

6969
long expiresIn = 0;
7070
if (jsonObject.containsKey("expires_in")) {
71-
expiresIn = jsonObject.getAsNumber("expires_in").longValue();
71+
expiresIn = Long.parseLong(jsonObject.getAsString("expires_in"));
7272
}
7373

7474
long ext_expires_in = 0;
7575
if (jsonObject.containsKey("ext_expires_in")) {
76-
ext_expires_in = jsonObject.getAsNumber("ext_expires_in").longValue();
76+
ext_expires_in = Long.parseLong(jsonObject.getAsString("ext_expires_in"));
7777
}
7878

7979
String foci = null;

0 commit comments

Comments
 (0)