diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientDynamicRegistrationEndpoint.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientDynamicRegistrationEndpoint.java index d40992bce..2d0b90e97 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientDynamicRegistrationEndpoint.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientDynamicRegistrationEndpoint.java @@ -175,9 +175,12 @@ public class ClientDynamicRegistrationEndpoint { return "httpCodeView"; } catch (IllegalArgumentException e) { logger.error("Couldn't save client", e); - m.addAttribute("code", HttpStatus.BAD_REQUEST); - - return "httpCodeView"; + + m.addAttribute("error", "invalid_client_metadata"); + m.addAttribute("errorMessage", "Unable to save client due to invalid or inconsistent metadata."); + m.addAttribute("code", HttpStatus.BAD_REQUEST); // http 400 + + return "jsonErrorView"; } } else { // didn't parse, this is a bad request @@ -301,15 +304,18 @@ public class ClientDynamicRegistrationEndpoint { m.addAttribute("code", HttpStatus.OK); // http 200 return "clientInformationResponseView"; - } catch (IllegalArgumentException e) { - logger.error("Couldn't save client", e); - m.addAttribute("code", HttpStatus.BAD_REQUEST); - - return "httpCodeView"; } catch (UnsupportedEncodingException e) { logger.error("Unsupported encoding", e); m.addAttribute("code", HttpStatus.INTERNAL_SERVER_ERROR); return "httpCodeView"; + } catch (IllegalArgumentException e) { + logger.error("Couldn't save client", e); + + m.addAttribute("error", "invalid_client_metadata"); + m.addAttribute("errorMessage", "Unable to save client due to invalid or inconsistent metadata."); + m.addAttribute("code", HttpStatus.BAD_REQUEST); // http 400 + + return "jsonErrorView"; } } else { // client mismatch diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ProtectedResourceRegistrationEndpoint.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ProtectedResourceRegistrationEndpoint.java index 58f5a6eeb..6e55d73ed 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ProtectedResourceRegistrationEndpoint.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ProtectedResourceRegistrationEndpoint.java @@ -181,9 +181,12 @@ public class ProtectedResourceRegistrationEndpoint { return "httpCodeView"; } catch (IllegalArgumentException e) { logger.error("Couldn't save client", e); - m.addAttribute("code", HttpStatus.BAD_REQUEST); - - return "httpCodeView"; + + m.addAttribute("error", "invalid_client_metadata"); + m.addAttribute("errorMessage", "Unable to save client due to invalid or inconsistent metadata."); + m.addAttribute("code", HttpStatus.BAD_REQUEST); // http 400 + + return "jsonErrorView"; } } else { // didn't parse, this is a bad request @@ -354,15 +357,18 @@ public class ProtectedResourceRegistrationEndpoint { m.addAttribute("code", HttpStatus.OK); // http 200 return "clientInformationResponseView"; - } catch (IllegalArgumentException e) { - logger.error("Couldn't save client", e); - m.addAttribute("code", HttpStatus.BAD_REQUEST); - - return "httpCodeView"; } catch (UnsupportedEncodingException e) { logger.error("Unsupported encoding", e); m.addAttribute("code", HttpStatus.INTERNAL_SERVER_ERROR); return "httpCodeView"; + } catch (IllegalArgumentException e) { + logger.error("Couldn't save client", e); + + m.addAttribute("error", "invalid_client_metadata"); + m.addAttribute("errorMessage", "Unable to save client due to invalid or inconsistent metadata."); + m.addAttribute("code", HttpStatus.BAD_REQUEST); // http 400 + + return "jsonErrorView"; } } else { // client mismatch