made binary encode/decode null safe
parent
a8377513a6
commit
1fbdd240f1
|
@ -328,8 +328,12 @@ public class MITREidDataService_1_0 extends MITREidDataService_1_X {
|
||||||
if (subName.equals("clientAuthorization")) {
|
if (subName.equals("clientAuthorization")) {
|
||||||
clientAuthorization = readAuthorizationRequest(reader);
|
clientAuthorization = readAuthorizationRequest(reader);
|
||||||
} else if (subName.equals("userAuthentication")) {
|
} else if (subName.equals("userAuthentication")) {
|
||||||
|
if (reader.peek() == JsonToken.NULL) {
|
||||||
|
reader.skipValue();
|
||||||
|
} else {
|
||||||
String authString = reader.nextString();
|
String authString = reader.nextString();
|
||||||
userAuthentication = base64UrlDecodeObject(authString, Authentication.class);
|
userAuthentication = base64UrlDecodeObject(authString, Authentication.class);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Found unexpected entry");
|
logger.debug("Found unexpected entry");
|
||||||
reader.skipValue();
|
reader.skipValue();
|
||||||
|
|
|
@ -667,8 +667,12 @@ public class MITREidDataService_1_1 extends MITREidDataService_1_X {
|
||||||
if (subName.equals("clientAuthorization")) {
|
if (subName.equals("clientAuthorization")) {
|
||||||
clientAuthorization = readAuthorizationRequest(reader);
|
clientAuthorization = readAuthorizationRequest(reader);
|
||||||
} else if (subName.equals("userAuthentication")) {
|
} else if (subName.equals("userAuthentication")) {
|
||||||
|
if (reader.peek() == JsonToken.NULL) {
|
||||||
|
reader.skipValue();
|
||||||
|
} else {
|
||||||
String authString = reader.nextString();
|
String authString = reader.nextString();
|
||||||
userAuthentication = base64UrlDecodeObject(authString, Authentication.class);
|
userAuthentication = base64UrlDecodeObject(authString, Authentication.class);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Found unexpected entry");
|
logger.debug("Found unexpected entry");
|
||||||
reader.skipValue();
|
reader.skipValue();
|
||||||
|
|
|
@ -71,6 +71,9 @@ public abstract class MITREidDataService_1_X implements MITREidDataService {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static <T> T base64UrlDecodeObject(String encoded, Class<T> type) {
|
protected static <T> T base64UrlDecodeObject(String encoded, Class<T> type) {
|
||||||
|
if (encoded == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
T deserialized = null;
|
T deserialized = null;
|
||||||
try {
|
try {
|
||||||
byte[] decoded = BaseEncoding.base64Url().decode(encoded);
|
byte[] decoded = BaseEncoding.base64Url().decode(encoded);
|
||||||
|
@ -84,8 +87,12 @@ public abstract class MITREidDataService_1_X implements MITREidDataService {
|
||||||
}
|
}
|
||||||
return deserialized;
|
return deserialized;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected static String base64UrlEncodeObject(Serializable obj) {
|
protected static String base64UrlEncodeObject(Serializable obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
String encoded = null;
|
String encoded = null;
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
@ -99,6 +106,7 @@ public abstract class MITREidDataService_1_X implements MITREidDataService {
|
||||||
}
|
}
|
||||||
return encoded;
|
return encoded;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
protected static Set readSet(JsonReader reader) throws IOException {
|
protected static Set readSet(JsonReader reader) throws IOException {
|
||||||
Set arraySet = null;
|
Set arraySet = null;
|
||||||
reader.beginArray();
|
reader.beginArray();
|
||||||
|
|
Loading…
Reference in New Issue