wrap errors in saving the client in an HTTP 400 (instead of HTTP 500) error
Conflicts: openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientDynamicRegistrationEndpoint.javapull/650/head
parent
e11c0386d1
commit
122b0c4e8c
|
@ -164,6 +164,7 @@ public class ClientDynamicRegistrationEndpoint {
|
|||
newClient.setDynamicallyRegistered(true);
|
||||
|
||||
// now save it
|
||||
try {
|
||||
ClientDetailsEntity savedClient = clientService.saveNewClient(newClient);
|
||||
|
||||
// generate the registration access token
|
||||
|
@ -180,6 +181,12 @@ public class ClientDynamicRegistrationEndpoint {
|
|||
//m.addAttribute("uri", config.getIssuer() + "register/" + savedClient.getClientId());
|
||||
|
||||
return "clientInformationResponseView";
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("Couldn't save client", e);
|
||||
m.addAttribute("code", HttpStatus.BAD_REQUEST);
|
||||
|
||||
return "httpCodeView";
|
||||
}
|
||||
} else {
|
||||
// didn't parse, this is a bad request
|
||||
logger.error("registerNewClient failed; submitted JSON is malformed");
|
||||
|
@ -278,6 +285,7 @@ public class ClientDynamicRegistrationEndpoint {
|
|||
// make sure that the client doesn't ask for scopes it can't have
|
||||
newClient.setScope(scopeService.toStrings(allowedScopes));
|
||||
|
||||
try {
|
||||
// save the client
|
||||
ClientDetailsEntity savedClient = clientService.updateClient(oldClient, newClient);
|
||||
|
||||
|
@ -297,6 +305,12 @@ public class ClientDynamicRegistrationEndpoint {
|
|||
//m.addAttribute("uri", config.getIssuer() + "register/" + savedClient.getClientId());
|
||||
|
||||
return "clientInformationResponseView";
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("Couldn't save client", e);
|
||||
m.addAttribute("code", HttpStatus.BAD_REQUEST);
|
||||
|
||||
return "httpCodeView";
|
||||
}
|
||||
} else {
|
||||
// client mismatch
|
||||
logger.error("readClientConfiguration failed, client ID mismatch: "
|
||||
|
|
Loading…
Reference in New Issue