From dbc68e407449e2e7b9e8b3e4e70842f619369513 Mon Sep 17 00:00:00 2001 From: Amanda Anganes Date: Fri, 1 Mar 2013 16:30:06 -0500 Subject: [PATCH] Working on error handling --- .../openid/connect/web/BlacklistAPI.java | 21 ++++++++++++------- .../mitre/openid/connect/web/ClientAPI.java | 20 ++++++++++++------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/BlacklistAPI.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/BlacklistAPI.java index f85f38b61..78fbfa603 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/BlacklistAPI.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/BlacklistAPI.java @@ -75,12 +75,15 @@ public class BlacklistAPI { BlacklistedSite newBlacklist = blacklistService.saveNew(blacklist); m.put("entity", newBlacklist); - } catch (JsonSyntaxException e) { - //TODO: Error Handling + } + //TODO: Java 7 combine catch statements + catch (JsonSyntaxException e) { + m.put("code", HttpStatus.BAD_REQUEST); + return "httpCodeView"; } catch (IllegalStateException e) { - + m.put("code", HttpStatus.BAD_REQUEST); + return "httpCodeView"; } - return "jsonEntityView"; @@ -101,10 +104,14 @@ public class BlacklistAPI { json = parser.parse(jsonString).getAsJsonObject(); blacklist = gson.fromJson(json, BlacklistedSite.class); - } catch (JsonSyntaxException e) { - //TODO: Error Handling + } + //TODO: Java 7 combine catch statements + catch (JsonSyntaxException e) { + m.put("code", HttpStatus.BAD_REQUEST); + return "httpCodeView"; } catch (IllegalStateException e) { - + m.put("code", HttpStatus.BAD_REQUEST); + return "httpCodeView"; } diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientAPI.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientAPI.java index 109c5cdc9..a42588f25 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientAPI.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ClientAPI.java @@ -131,10 +131,14 @@ public class ClientAPI { try { json = parser.parse(jsonString).getAsJsonObject(); client = gson.fromJson(json, ClientDetailsEntity.class); - } catch (JsonSyntaxException e) { - //TODO: Error Handling + } + //TODO: Java 7 combine catch statements + catch (JsonSyntaxException e) { + m.addAttribute("code", HttpStatus.BAD_REQUEST); + return "httpCodeView"; } catch (IllegalStateException e) { - + m.addAttribute("code", HttpStatus.BAD_REQUEST); + return "httpCodeView"; } // if they leave the client secret empty, force it to be generated @@ -181,10 +185,14 @@ public class ClientAPI { // parse the client passed in (from JSON) and fetch the old client from the store json = parser.parse(jsonString).getAsJsonObject(); client = gson.fromJson(json, ClientDetailsEntity.class); - } catch (JsonSyntaxException e) { - //TODO: Error Handling + } + //TODO: Java 7 combine catch statements + catch (JsonSyntaxException e) { + m.addAttribute("code", HttpStatus.BAD_REQUEST); + return "httpCodeView"; } catch (IllegalStateException e) { - + m.addAttribute("code", HttpStatus.BAD_REQUEST); + return "httpCodeView"; } ClientDetailsEntity oldClient = clientService.getClientById(id);