Skip to content

Commit

Permalink
compatibility with jackson 2.6.7 and json-smart 1.3.1 (#242)
Browse files Browse the repository at this point in the history
compatibility with jackson 2.6.7 and json-smart 1.3.1
  • Loading branch information
SomkaPe authored Jun 3, 2020
1 parent df4e339 commit 6deb186
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
1 change: 0 additions & 1 deletion lombok.config

This file was deleted.

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

package labapi;

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.io.IOException;
import java.net.MalformedURLException;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -24,8 +24,8 @@ public class LabService {
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);
} catch (IOException e) {
throw new RuntimeException("JSON processing error: " + e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class AuthenticationErrorCode {
public final static String THROTTLED_REQUEST = "throttled_request";

/**
* A JsonProcessingException was thrown, indicating the JSON provided to MSAL is of invalid format.
* A JSON processing failure, indicating the JSON provided to MSAL is of invalid format.
*/
public final static String INVALID_JSON = "invalid_json";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
package com.microsoft.aad.msal4j;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.*;
import lombok.experimental.Accessors;

import java.util.*;

@Accessors(fluent = true)
@Getter(AccessLevel.PACKAGE)
@Builder
@NoArgsConstructor
@AllArgsConstructor
class InstanceDiscoveryMetadataEntry {

@JsonProperty("preferred_network")
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/microsoft/aad/msal4j/JsonHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.JsonNode;

import java.io.IOException;
import java.util.Iterator;
import java.util.Set;

Expand All @@ -27,7 +27,7 @@ class JsonHelper {
static <T> T convertJsonToObject(final String json, final Class<T> clazz) {
try {
return mapper.readValue(json, clazz);
} catch (JsonProcessingException e) {
} catch (IOException e) {
throw new MsalClientException(e);
}
}
Expand All @@ -38,7 +38,7 @@ static <T> T convertJsonToObject(final String json, final Class<T> clazz) {
static void validateJsonFormat(String jsonString) {
try {
mapper.readTree(jsonString);
} catch (JsonProcessingException e) {
} catch (IOException e) {
throw new MsalClientException(e.getMessage(), AuthenticationErrorCode.INVALID_JSON);
}
}
Expand Down Expand Up @@ -72,7 +72,7 @@ static String mergeJSONString(String mainJsonString, String addJsonString) {
try {
mainJson = mapper.readTree(mainJsonString);
addJson = mapper.readTree(addJsonString);
} catch (JsonProcessingException e) {
} catch (IOException e) {
throw new MsalClientException(e.getMessage(), AuthenticationErrorCode.INVALID_JSON);
}

Expand All @@ -95,14 +95,14 @@ static String mergeJSONString(Set<String> jsonStrings) {
} else {
return "";
}
} catch (JsonProcessingException e) {
} catch (IOException e) {
throw new MsalClientException(e.getMessage(), AuthenticationErrorCode.INVALID_JSON);
}

while (jsons.hasNext()) {
try {
addJson = mapper.readTree(jsons.next());
} catch (JsonProcessingException e) {
} catch (IOException e) {
throw new MsalClientException(e.getMessage(), AuthenticationErrorCode.INVALID_JSON);
}
mergeJSONNode(mainJson, addJson);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/microsoft/aad/msal4j/TokenCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
package com.microsoft.aad.msal4j;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import java.io.IOException;
import java.util.*;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
Expand Down Expand Up @@ -147,7 +147,7 @@ public String serialize() {
}
return JsonHelper.mapper.writeValueAsString(this);
}
catch (JsonProcessingException e) {
catch (IOException e) {
throw new MsalClientException(e);
}finally {
lock.readLock().unlock();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/microsoft/aad/msal4j/TokenResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,28 @@ static TokenResponse parseJsonObject(final JSONObject jsonObject)
// use an empty string in order to avoid an IllegalArgumentException from OIDCTokens.
String idTokenValue = "";
if (jsonObject.containsKey("id_token")) {
idTokenValue = jsonObject.getAsString("id_token");
idTokenValue = JSONObjectUtils.getString(jsonObject, "id_token");
}

// Parse value
String scopeValue = null;
if (jsonObject.containsKey("scope")) {
scopeValue = jsonObject.getAsString("scope");
scopeValue = JSONObjectUtils.getString(jsonObject, "scope");
}

String clientInfo = null;
if (jsonObject.containsKey("client_info")) {
clientInfo = jsonObject.getAsString("client_info");
clientInfo = JSONObjectUtils.getString(jsonObject, "client_info");
}

long expiresIn = 0;
if (jsonObject.containsKey("expires_in")) {
expiresIn = jsonObject.getAsNumber("expires_in").longValue();
expiresIn = Long.parseLong(jsonObject.getAsString("expires_in"));
}

long ext_expires_in = 0;
if (jsonObject.containsKey("ext_expires_in")) {
ext_expires_in = jsonObject.getAsNumber("ext_expires_in").longValue();
ext_expires_in = Long.parseLong(jsonObject.getAsString("ext_expires_in"));
}

String foci = null;
Expand Down

0 comments on commit 6deb186

Please sign in to comment.