I have created issue https://github.com/apache/shiro/issues/1424 
<https://github.com/apache/shiro/issues/1424> and PR 
https://github.com/apache/shiro/pull/1425 
<https://github.com/apache/shiro/pull/1425> and hopefully that will make things 
easier in the future

> On Apr 19, 2024, at 1:25 AM, Andrew G10i <andrewg...@outlook.com> wrote:
> 
> Trying to migrate to Shiro v2.x (from v1.13) and stuck with the following 
> code (which was working fine in 1.13):
> 
> public static MySecurityManager getSecurityManager() {
>     return (MySecurityManager) 
> org.apache.shiro.SecurityUtils.getSecurityManager();
> }
> 
> Getting the following exception:
> java.lang.ClassCastException: class 
> org.apache.shiro.ee.filters.ShiroFilter$WrappedSecurityManager cannot be cast 
> to class pkg.local.MySecurityManager 
> (org.apache.shiro.ee.filters.ShiroFilter$WrappedSecurityManager and 
> pkg.local.MySecurityManager are in unnamed module of loader 
> org.glassfish.web.loader.WebappClassLoader @26652402)
> 
> The issue is that some of my code need to iterate over realms, as result this 
> code doesn't work anymore:getSecurityManager().getRealms().
> 
> Any suggestions how to get access to own custom implementation of Security 
> Manager (MySecurityManager as per the code above) or at least get access to 
> realms?
> 
> Thanks!

Reply via email to