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

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new 3fd2344b96 FELIX-6574 : Avoid class cast exceptions
3fd2344b96 is described below

commit 3fd2344b964a4309fcbd87e6a6f63aacc9af2515
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Fri Oct 28 12:57:30 2022 +0200

    FELIX-6574 : Avoid class cast exceptions
---
 .../http/base/internal/dispatch/ServletRequestWrapper.java   | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
index 493ce08ff9..034b6e150b 100644
--- 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
+++ 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
@@ -51,7 +51,7 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.felix.http.base.internal.context.ExtServletContext;
 import org.apache.felix.http.base.internal.handler.HttpSessionWrapper;
 import org.osgi.framework.Bundle;
-import org.osgi.service.http.HttpContext;
+import org.osgi.service.servlet.context.ServletContextHelper;
 import org.osgi.service.useradmin.Authorization;
 
 import jakarta.servlet.AsyncContext;
@@ -178,7 +178,7 @@ final class ServletRequestWrapper extends 
HttpServletRequestWrapper
     @Override
     public String getAuthType()
     {
-        String authType = (String) 
getAttribute(HttpContext.AUTHENTICATION_TYPE);
+        String authType = (String) 
getAttribute(ServletContextHelper.AUTHENTICATION_TYPE);
         if (authType == null)
         {
             authType = super.getAuthType();
@@ -219,7 +219,7 @@ final class ServletRequestWrapper extends 
HttpServletRequestWrapper
     @Override
     public String getRemoteUser()
     {
-        String remoteUser = (String) getAttribute(HttpContext.REMOTE_USER);
+        String remoteUser = (String) 
getAttribute(ServletContextHelper.REMOTE_USER);
         if (remoteUser != null)
         {
             return remoteUser;
@@ -296,10 +296,10 @@ final class ServletRequestWrapper extends 
HttpServletRequestWrapper
     @Override
     public boolean isUserInRole(String role)
     {
-        Authorization authorization = (Authorization) 
getAttribute(HttpContext.AUTHORIZATION);
-        if (authorization != null)
+        final Object authorization = 
getAttribute(ServletContextHelper.AUTHORIZATION);
+        if (authorization instanceof Authorization )
         {
-            return authorization.hasRole(role);
+            return ((Authorization)authorization).hasRole(role);
         }
 
         return super.isUserInRole(role);

Reply via email to