wrap errors in saving the client in an HTTP 400 (instead of HTTP 500) error
parent
9b72c6b1f3
commit
9f13dc8f77
|
@ -166,6 +166,7 @@ public class ClientDynamicRegistrationEndpoint {
|
||||||
// TODO: check and enforce the sector URI if it's not null (#504)
|
// TODO: check and enforce the sector URI if it's not null (#504)
|
||||||
|
|
||||||
// now save it
|
// now save it
|
||||||
|
try {
|
||||||
ClientDetailsEntity savedClient = clientService.saveNewClient(newClient);
|
ClientDetailsEntity savedClient = clientService.saveNewClient(newClient);
|
||||||
|
|
||||||
// generate the registration access token
|
// generate the registration access token
|
||||||
|
@ -180,6 +181,12 @@ public class ClientDynamicRegistrationEndpoint {
|
||||||
m.addAttribute("code", HttpStatus.CREATED); // http 201
|
m.addAttribute("code", HttpStatus.CREATED); // http 201
|
||||||
|
|
||||||
return "clientInformationResponseView";
|
return "clientInformationResponseView";
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
logger.error("Couldn't save client", e);
|
||||||
|
m.addAttribute("code", HttpStatus.BAD_REQUEST);
|
||||||
|
|
||||||
|
return "httpCodeView";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// didn't parse, this is a bad request
|
// didn't parse, this is a bad request
|
||||||
logger.error("registerNewClient failed; submitted JSON is malformed");
|
logger.error("registerNewClient failed; submitted JSON is malformed");
|
||||||
|
@ -275,6 +282,7 @@ public class ClientDynamicRegistrationEndpoint {
|
||||||
// make sure that the client doesn't ask for scopes it can't have
|
// make sure that the client doesn't ask for scopes it can't have
|
||||||
newClient.setScope(scopeService.toStrings(allowedScopes));
|
newClient.setScope(scopeService.toStrings(allowedScopes));
|
||||||
|
|
||||||
|
try {
|
||||||
// save the client
|
// save the client
|
||||||
ClientDetailsEntity savedClient = clientService.updateClient(oldClient, newClient);
|
ClientDetailsEntity savedClient = clientService.updateClient(oldClient, newClient);
|
||||||
|
|
||||||
|
@ -291,6 +299,12 @@ public class ClientDynamicRegistrationEndpoint {
|
||||||
m.addAttribute("code", HttpStatus.OK); // http 200
|
m.addAttribute("code", HttpStatus.OK); // http 200
|
||||||
|
|
||||||
return "clientInformationResponseView";
|
return "clientInformationResponseView";
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
logger.error("Couldn't save client", e);
|
||||||
|
m.addAttribute("code", HttpStatus.BAD_REQUEST);
|
||||||
|
|
||||||
|
return "httpCodeView";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// client mismatch
|
// client mismatch
|
||||||
logger.error("readClientConfiguration failed, client ID mismatch: "
|
logger.error("readClientConfiguration failed, client ID mismatch: "
|
||||||
|
|
Loading…
Reference in New Issue