+ There was an error processing your request. The server's message was:
+
+
+
+
+
+
+
+
+
diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/web/OAuth2ExceptionHandler.java b/openid-connect-server/src/main/java/org/mitre/oauth2/web/OAuth2ExceptionHandler.java
new file mode 100644
index 000000000..35efd5c7c
--- /dev/null
+++ b/openid-connect-server/src/main/java/org/mitre/oauth2/web/OAuth2ExceptionHandler.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright 2015 The MITRE Corporation
+ * and the MIT Kerberos and Internet Trust Consortium
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+
+package org.mitre.oauth2.web;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
+import org.springframework.security.oauth2.provider.error.WebResponseExceptionTranslator;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
+/**
+ * Controller helper that handles OAuth2 exceptions and propagates them as JSON errors.
+ *
+ * @author jricher
+ *
+ */
+@ControllerAdvice
+public class OAuth2ExceptionHandler {
+ private static final Logger logger = LoggerFactory.getLogger(OAuth2ExceptionHandler.class);
+
+ @Autowired
+ private WebResponseExceptionTranslator providerExceptionHandler;
+
+ @ExceptionHandler(OAuth2Exception.class)
+ public ResponseEntity handleException(Exception e) throws Exception {
+ logger.info("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
+ return providerExceptionHandler.translate(e);
+ }
+
+}
diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/filter/PromptFilter.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/filter/PromptFilter.java
index 4843caba6..eb2e949ff 100644
--- a/openid-connect-server/src/main/java/org/mitre/openid/connect/filter/PromptFilter.java
+++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/filter/PromptFilter.java
@@ -90,11 +90,12 @@ public class PromptFilter extends GenericFilterBean {
}
// we have to create our own auth request in order to get at all the parmeters appropriately
- AuthorizationRequest authRequest = authRequestFactory.createAuthorizationRequest(createRequestMap(request.getParameterMap()));
+ AuthorizationRequest authRequest = null;
ClientDetailsEntity client = null;
try {
+ authRequest = authRequestFactory.createAuthorizationRequest(createRequestMap(request.getParameterMap()));
client = clientService.loadClientByClientId(authRequest.getClientId());
} catch (InvalidClientException e) {
// no need to worry about this here, it would be caught elsewhere