[spring-extensions] branch master updated: IDP-889 - Handle 500 errors inside IDP
Scott Cantor
cantor.2 at osu.edu
Fri Jan 8 17:44:40 EST 2016
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository spring-extensions.
The following commit(s) were added to refs/heads/master by this push:
new 0ebb464 IDP-889 - Handle 500 errors inside IDP
0ebb464 is described below
commit 0ebb4647446ffd8506bda594524f833399b50c72
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Jan 8 17:46:10 2016 -0500
IDP-889 - Handle 500 errors inside IDP
https://issues.shibboleth.net/jira/browse/IDP-889
Add an MVC controller that just raises errors propagated by a servlet
container.
---
.../ext/spring/error/ErrorRaisingController.java | 62 ++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/src/main/java/net/shibboleth/ext/spring/error/ErrorRaisingController.java b/src/main/java/net/shibboleth/ext/spring/error/ErrorRaisingController.java
new file mode 100644
index 0000000..f5d3c2b
--- /dev/null
+++ b/src/main/java/net/shibboleth/ext/spring/error/ErrorRaisingController.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.ext.spring.error;
+
+import javax.annotation.Nonnull;
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * MVC controller for responding to errors by dispatching them to the MVC error handling umbrella.
+ */
+public class ErrorRaisingController {
+
+ /** Class logger. */
+ @Nonnull private final Logger log = LoggerFactory.getLogger(ErrorRaisingController.class);
+
+ /**
+ * Handle an error dispatched by the container by re-raising it.
+ *
+ * @param httpRequest the HTTP request
+ *
+ * @throws Throwable
+ */
+ @RequestMapping
+ public void raiseError(@Nonnull final HttpServletRequest httpRequest) throws Throwable {
+
+ final Object uri = httpRequest.getAttribute("javax.servlet.error.request_uri");
+
+ final Object exception = httpRequest.getAttribute("javax.servlet.error.exception");
+ if (exception == null || !(exception instanceof Exception)) {
+ log.error("No exception found in request attribute, raising a generic error");
+ throw new IllegalArgumentException("No exception found in request attribute");
+ }
+
+ final Exception e = (Exception) exception;
+ log.error("Propagating exception thrown by request to {}", uri);
+ if (e.getCause() != null) {
+ throw e.getCause();
+ } else {
+ throw e;
+ }
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list