Got read/ingest mostly working. clientId and authenticationHolderId still not being set properly on tokens.

pull/650/head
arielak 2014-07-29 13:43:08 -04:00
parent 6da73b0f39
commit 99c8e1c285
1 changed files with 272 additions and 205 deletions

View File

@ -534,6 +534,7 @@ public class MITREidDataService_1_0 implements MITREidDataService {
readRefreshTokens(reader);
} else if (name.equals(SYSTEMSCOPES)) {
readSystemScopes(reader);
//reader.skipValue();
} else {
// unknown token, skip it
reader.skipValue();
@ -566,7 +567,9 @@ public class MITREidDataService_1_0 implements MITREidDataService {
Long authHolderId = null;
while (reader.hasNext()) {
String name = reader.nextName();
if (name.equals("id")) {
if (reader.peek() == JsonToken.NULL) {
reader.skipValue();
} else if (name.equals("id")) {
currentId = reader.nextLong();
} else if (name.equals("expiration")) {
if (reader.peek() == JsonToken.NULL) {
@ -623,7 +626,9 @@ public class MITREidDataService_1_0 implements MITREidDataService {
Long idTokenId = null;
while (reader.hasNext()) {
String name = reader.nextName();
if (name.equals("id")) {
if (reader.peek() == JsonToken.NULL) {
reader.skipValue();
} else if (name.equals("id")) {
currentId = reader.nextLong();
} else if (name.equals("expiration")) {
if (reader.peek() == JsonToken.NULL) {
@ -689,8 +694,14 @@ public class MITREidDataService_1_0 implements MITREidDataService {
reader.beginObject();
Long currentId = null;
while (reader.hasNext()) {
switch (reader.peek()) {
case END_OBJECT:
continue;
case NAME:
String name = reader.nextName();
if(name.equals("id")) {
if (reader.peek() == JsonToken.NULL) {
reader.skipValue();
} else if (name.equals("id")) {
currentId = reader.nextLong();
} else if (name.equals("ownerId")) {
//not needed
@ -699,15 +710,27 @@ public class MITREidDataService_1_0 implements MITREidDataService {
AuthorizationRequest clientAuthorization = null;
Authentication userAuthentication = null;
reader.beginObject();
while(reader.hasNext()) {
if (name.equals("clientAuthorization")) {
while (reader.hasNext()) {
switch (reader.peek()) {
case END_OBJECT:
continue;
case NAME:
String subName = reader.nextName();
if (subName.equals("clientAuthorization")) {
clientAuthorization = readAuthorizationRequest(reader);
} else if (name.equals("userAuthentication")) {
userAuthentication = base64UrlDecodeObject(reader.nextString(), Authentication.class);
} else if (subName.equals("userAuthentication")) {
String authString = reader.nextString();
userAuthentication = base64UrlDecodeObject(authString, Authentication.class);
} else {
logger.debug("Found unexpected entry");
reader.skipValue();
}
break;
default:
logger.debug("Found unexpected entry");
reader.skipValue();
continue;
}
}
reader.endObject();
OAuth2Authentication auth = new OAuth2Authentication(clientAuthorization, userAuthentication);
@ -716,6 +739,12 @@ public class MITREidDataService_1_0 implements MITREidDataService {
logger.debug("Found unexpected entry");
reader.skipValue();
}
break;
default:
logger.debug("Found unexpected entry");
reader.skipValue();
continue;
}
}
reader.endObject();
Long newId = authHolderRepository.save(ahe).getId();
@ -738,8 +767,14 @@ public class MITREidDataService_1_0 implements MITREidDataService {
String clientId = null;
reader.beginObject();
while (reader.hasNext()) {
switch (reader.peek()) {
case END_OBJECT:
continue;
case NAME:
String name = reader.nextName();
if (name.equals("authorizationParameters")) {
if (reader.peek() == JsonToken.NULL) {
reader.skipValue();
} else if (name.equals("authorizationParameters")) {
authorizationParameters = readMap(reader);
} else if (name.equals("approvalParameters")) {
approvalParameters = readMap(reader);
@ -759,7 +794,7 @@ public class MITREidDataService_1_0 implements MITREidDataService {
} else if (name.equals("approved")) {
approved = reader.nextBoolean();
} else if (name.equals("denied")) {
if(approved == false) {
if (approved == false) {
approved = !reader.nextBoolean();
}
} else if (name.equals("redirectUri")) {
@ -767,6 +802,12 @@ public class MITREidDataService_1_0 implements MITREidDataService {
} else {
reader.skipValue();
}
break;
default:
logger.debug("Found unexpected entry");
reader.skipValue();
continue;
}
}
reader.endObject();
DefaultAuthorizationRequest dar = new DefaultAuthorizationRequest(authorizationParameters, approvalParameters, clientId, scope);
@ -792,8 +833,14 @@ public class MITREidDataService_1_0 implements MITREidDataService {
Long currentId = null;
reader.beginObject();
while (reader.hasNext()) {
switch (reader.peek()) {
case END_OBJECT:
continue;
case NAME:
String name = reader.nextName();
if (name.equals("id")) {
if (reader.peek() == JsonToken.NULL) {
reader.skipValue();
} else if (name.equals("id")) {
currentId = reader.nextLong();
} else if (name.equals("accessDate")) {
if (reader.peek() == JsonToken.NULL) {
@ -826,7 +873,7 @@ public class MITREidDataService_1_0 implements MITREidDataService {
} else if (name.equals("whitelistedSite")) {
WhitelistedSite wlSite = new WhitelistedSite();
reader.beginObject();
while(reader.hasNext()) {
while (reader.hasNext()) {
String wlName = reader.nextName();
if (wlName.equals("id")) {
//not needed
@ -850,6 +897,12 @@ public class MITREidDataService_1_0 implements MITREidDataService {
logger.debug("Found unexpected entry");
reader.skipValue();
}
break;
default:
logger.debug("Found unexpected entry");
reader.skipValue();
continue;
}
}
reader.endObject();
approvedSiteRepository.save(site).getId();
@ -872,8 +925,14 @@ public class MITREidDataService_1_0 implements MITREidDataService {
ClientDetailsEntity client = new ClientDetailsEntity();
reader.beginObject();
while (reader.hasNext()) {
switch (reader.peek()) {
case END_OBJECT:
continue;
case NAME:
String name = reader.nextName();
if (name.equals("clientId")) {
if (reader.peek() == JsonToken.NULL) {
reader.skipValue();
} else if (name.equals("clientId")) {
client.setClientId(reader.nextString());
} else if (name.equals("resourceIds")) {
Set<String> resourceIds = readSet(reader);
@ -917,7 +976,7 @@ public class MITREidDataService_1_0 implements MITREidDataService {
client.setGrantTypes(grantTypes);
} else if (name.equals("responseTypes")) {
Set<String> responseTypes = readSet(reader);
client.setGrantTypes(responseTypes);
client.setResponseTypes(responseTypes);
} else if (name.equals("policyUri")) {
client.setPolicyUri(reader.nextString());
} else if (name.equals("applicationType")) {
@ -958,14 +1017,20 @@ public class MITREidDataService_1_0 implements MITREidDataService {
client.setClientDescription(reader.nextString());
} else if (name.equals("allowIntrospection")) {
client.setAllowIntrospection(reader.nextBoolean());
} else if(name.equals("reuseRefreshToken")) {
} else if (name.equals("reuseRefreshToken")) {
client.setReuseRefreshToken(reader.nextBoolean());
} else if(name.equals("dynamicallyRegistered")) {
} else if (name.equals("dynamicallyRegistered")) {
client.setDynamicallyRegistered(reader.nextBoolean());
} else {
logger.debug("Found unexpected entry");
reader.skipValue();
}
break;
default:
logger.debug("Found unexpected entry");
reader.skipValue();
continue;
}
}
reader.endObject();
clientRepository.saveClient(client);
@ -991,7 +1056,9 @@ public class MITREidDataService_1_0 implements MITREidDataService {
continue;
case NAME:
String name = reader.nextName();
if (name.equals("value")) {
if (reader.peek() == JsonToken.NULL) {
reader.skipValue();
} else if (name.equals("value")) {
scope.setValue(reader.nextString());
} else if (name.equals("description")) {
scope.setDescription(reader.nextString());