You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/10/08 13:22:11 UTC

[isis] 02/02: ISIS-2297: throw IllegalState if no WebApplicationContext (sonar)

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit e8452bd8cebeb4671d0aafe6a034569c2a488fd9
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Oct 8 15:21:57 2020 +0200

    ISIS-2297: throw IllegalState if no WebApplicationContext (sonar)
---
 .../viewer/webmodule/auth/AuthenticationSessionStrategyAbstract.java  | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/viewers/restfulobjects/viewer/src/main/java/org/apache/isis/viewer/restfulobjects/viewer/webmodule/auth/AuthenticationSessionStrategyAbstract.java b/viewers/restfulobjects/viewer/src/main/java/org/apache/isis/viewer/restfulobjects/viewer/webmodule/auth/AuthenticationSessionStrategyAbstract.java
index c6c8319..363a066 100644
--- a/viewers/restfulobjects/viewer/src/main/java/org/apache/isis/viewer/restfulobjects/viewer/webmodule/auth/AuthenticationSessionStrategyAbstract.java
+++ b/viewers/restfulobjects/viewer/src/main/java/org/apache/isis/viewer/restfulobjects/viewer/webmodule/auth/AuthenticationSessionStrategyAbstract.java
@@ -26,6 +26,7 @@ import javax.servlet.http.HttpSession;
 
 import org.springframework.web.context.support.WebApplicationContextUtils;
 
+import org.apache.isis.commons.internal.exceptions._Exceptions;
 import org.apache.isis.core.security.authentication.manager.AuthenticationManager;
 
 import lombok.val;
@@ -40,6 +41,9 @@ public abstract class AuthenticationSessionStrategyAbstract implements Authentic
         if(authenticationManager==null) {
             val servletContext = getServletContext(servletRequest);
             val webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
+            if(webApplicationContext==null) {
+                throw _Exceptions.illegalState("Requires a WebApplicationContext (Spring).");
+            }
             authenticationManager = webApplicationContext.getBean(AuthenticationManager.class);
         }
         return authenticationManager;