+ return processReturnCode(returnCode);
+ }
+
+ /** Recursively look for {@link BadCredentialsException} in the root causes. */
+ private BadCredentialsException wasCausedByBadCredentials(Throwable t) {
+ if (t instanceof BadCredentialsException)
+ return (BadCredentialsException) t;
+
+ if (t.getCause() != null)
+ return wasCausedByBadCredentials(t.getCause());
+ else
+ return null;
+ }
+
+ /**
+ * If there is a {@link ThreadDeath} in the root causes, rethrow it
+ * (important for RAP cleaning mechanism)
+ */
+ protected ThreadDeath wasCausedByThreadDeath(Throwable t) {
+ if (t instanceof ThreadDeath)
+ return (ThreadDeath) t;
+
+ if (t.getCause() != null)
+ return wasCausedByThreadDeath(t.getCause());
+ else
+ return null;
+ }
+
+ protected void logout(ILoginContext secureContext, String username) {
+ try {
+ secureContext.logout();
+ log.info("Logged out " + (username != null ? username : "")
+ + " (THREAD=" + Thread.currentThread().getId() + ")");
+ } catch (LoginException e) {
+ log.error("Erorr when logging out", e);
+ }