try {
redirectURIs.add(new URI(uriString));
} catch (URISyntaxException e) {
throw new ParseException("Invalid \"redirect_uris\" parameter: " +
e.getMessage());
}
}
metadata.setRedirectionURIs(redirectURIs);
jsonObject.remove("redirect_uris");
}
if (jsonObject.containsKey("scope")) {
metadata.setScope(Scope.parse(JSONObjectUtils.getString(jsonObject, "scope")));
jsonObject.remove("scope");
}
if (jsonObject.containsKey("response_types")) {
Set<ResponseType> responseTypes = new LinkedHashSet<>();
for (String rt: JSONObjectUtils.getStringArray(jsonObject, "response_types")) {
responseTypes.add(ResponseType.parse(rt));
}
metadata.setResponseTypes(responseTypes);
jsonObject.remove("response_types");
}
if (jsonObject.containsKey("grant_types")) {
Set<GrantType> grantTypes = new LinkedHashSet<>();
for (String grant: JSONObjectUtils.getStringArray(jsonObject, "grant_types")) {
grantTypes.add(GrantType.parse(grant));
}
metadata.setGrantTypes(grantTypes);
jsonObject.remove("grant_types");
}
if (jsonObject.containsKey("contacts")) {
List<InternetAddress> emailList = new LinkedList<>();
for (String emailString: JSONObjectUtils.getStringArray(jsonObject, "contacts")) {
try {
emailList.add(new InternetAddress(emailString));
} catch (AddressException e) {
throw new ParseException("Invalid \"contacts\" parameter: " +
e.getMessage());
}
}
metadata.setContacts(emailList);
jsonObject.remove("contacts");
}
// Find lang-tagged client_name params
Map<LangTag,Object> matches = LangTagUtils.find("client_name", jsonObject);
for (Map.Entry<LangTag,Object> entry: matches.entrySet()) {
try {
metadata.setName((String)entry.getValue(), entry.getKey());
} catch (ClassCastException e) {
throw new ParseException("Invalid \"client_name\" (language tag) parameter");
}
removeMember(jsonObject, "client_name", entry.getKey());
}
matches = LangTagUtils.find("logo_uri", jsonObject);
for (Map.Entry<LangTag,Object> entry: matches.entrySet()) {
try {
metadata.setLogoURI(new URI((String)entry.getValue()), entry.getKey());
} catch (Exception e) {
throw new ParseException("Invalid \"logo_uri\" (language tag) parameter");
}
removeMember(jsonObject, "logo_uri", entry.getKey());
}
matches = LangTagUtils.find("client_uri", jsonObject);
for (Map.Entry<LangTag,Object> entry: matches.entrySet()) {
try {
metadata.setURI(new URI((String)entry.getValue()), entry.getKey());
} catch (Exception e) {
throw new ParseException("Invalid \"client_uri\" (language tag) parameter");
}
removeMember(jsonObject, "client_uri", entry.getKey());
}
matches = LangTagUtils.find("policy_uri", jsonObject);
for (Map.Entry<LangTag,Object> entry: matches.entrySet()) {
try {
metadata.setPolicyURI(new URI((String)entry.getValue()), entry.getKey());
} catch (Exception e) {
throw new ParseException("Invalid \"policy_uri\" (language tag) parameter");
}
removeMember(jsonObject, "policy_uri", entry.getKey());
}
matches = LangTagUtils.find("tos_uri", jsonObject);
for (Map.Entry<LangTag,Object> entry: matches.entrySet()) {
try {
metadata.setTermsOfServiceURI(new URI((String)entry.getValue()), entry.getKey());
} catch (Exception e) {
throw new ParseException("Invalid \"tos_uri\" (language tag) parameter");
}
removeMember(jsonObject, "tos_uri", entry.getKey());
}
if (jsonObject.containsKey("token_endpoint_auth_method")) {
metadata.setTokenEndpointAuthMethod(new ClientAuthenticationMethod(
JSONObjectUtils.getString(jsonObject, "token_endpoint_auth_method")));
jsonObject.remove("token_endpoint_auth_method");
}
if (jsonObject.containsKey("jwks_uri")) {
metadata.setJWKSetURI(JSONObjectUtils.getURI(jsonObject, "jwks_uri"));
jsonObject.remove("jwks_uri");
}
if (jsonObject.containsKey("jwks")) {
try {
metadata.setJWKSet(JWKSet.parse(JSONObjectUtils.getJSONObject(jsonObject, "jwks")));
} catch (java.text.ParseException e) {
throw new ParseException(e.getMessage(), e);
}
jsonObject.remove("jwks");
}