Hi Alex,

1-3.)
Do you also have the Shiro Servlet Filter configured?

4.) We don't currently generate module-info metadata, but if there is
something that isn't working for you please start another thread :)

5.) We don't have sources & Javadoc jars for `shiro-all` we only produce
them for the individual modules.


On Wed, May 6, 2020 at 4:23 AM Alex Sviridov <[email protected]> wrote:

> Hi Brian,
>
> Thank you for quick answer.
>
> 1) This is my shiro.ini
>
> [main]
> cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
> securityManager.cacheManager = $cacheManager
> realm = com.foo.TestRealm
> securityManager.realms = $realm
>
> 2) This is my init code:
>
>             Environment env = new BasicIniEnvironment(url.toString());
>             final SecurityManager securityManager =
> env.getSecurityManager();
>             SecurityUtils.setSecurityManager(securityManager);
>
> 3) This is my TestRealm
>
> public class TestRealm extends AuthenticatingRealm {
>
>     private static final Logger logger =
> LoggerFactory.getLogger(TestRealm.class);
>     @Override
>     protected void onInit() {
>         logger.info("************************************On INIT");
>         try {
>             throw new Exception();
>         } catch (Exception ex) {
>             logger.error("Error", ex);
>         }
>         setCredentialsMatcher((AuthenticationToken at, AuthenticationInfo
> ai) -> {
>             logger.info("################################ [{}], [{}]",
> at, ai);
>             return false;
>         });
>
>     }
>
>
>     @Override
>     protected AuthenticationInfo
> doGetAuthenticationInfo(AuthenticationToken token) throws
> AuthenticationException {
>         UsernamePasswordToken upToken = (UsernamePasswordToken) token;
>         logger.info("REALM username [{}], password [{}]",
> upToken.getUsername(), upToken.getPassword());
>          return new SimpleAuthenticationInfo(new UserEntity(), null ,
> getName());
>     }
>
> }
>
>
> 4) I tried to use shiro-core + shiro-web, but it seems to be impossible to
> use
> shiro modules in jpms environment, so, I had to take shiro-all.
>
> 5) By the way, I couldn’t find javadoc and sources for shiro-al in maven
> repo
> https://repo1.maven.org/maven2/org/apache/shiro/shiro-all/1.5.3/
>
> Best regards, Alex
>
>
> Среда, 6 мая 2020, 4:09 +03:00 от Brian Demers <[email protected]>:
>
> It depends, we would need to see the full stack trace, it's unclear what
> is setting up your environment.  How are you configuring Shiro?
>
> Also, I'd recommend against using the `shiro-all` and instead use
> `shiro-web`
>
> On Tue, May 5, 2020 at 7:01 PM Alex Sviridov <[email protected]
> <//e.mail.ru/compose/?mailto=mailto%[email protected]>> wrote:
>
> Hi all,
>
> I am just learning Shiro, but I noticed that onInit method on  on
> AuthenticatingRealm
> is called twice. I have one TestRealm and this is stacktrace:
>
> First call:
>
>     at com.foo.TestRealm.onInit(TestRealm.java:37) [classes/:?]
>     at
> org.apache.shiro.realm.AuthenticatingRealm.init(AuthenticatingRealm.java:398)
> [shiro-all-1.5.3.jar:?]
>     at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:45)
> [shiro-all-1.5.3.jar:?]
>     at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:40)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.ReflectionBuilder$BeanConfigurationProcessor.execute(ReflectionBuilder.java:829)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:288)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:181)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:139)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:107)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:98)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:47)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniFactorySupport.createInstance(IniFactorySupport.java:150)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.util.AbstractFactory.getInstance(AbstractFactory.java:47)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.env.BasicIniEnvironment.<init>(BasicIniEnvironment.java:37)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.env.BasicIniEnvironment.<init>(BasicIniEnvironment.java:41)
> [shiro-all-1.5.3.jar:?]
>
>
> Second call:
>
>     at com.foo.TestRealm.onInit(TestRealm.java:37) [classes/:?]
>     at
> org.apache.shiro.realm.AuthenticatingRealm.init(AuthenticatingRealm.java:398)
> [shiro-all-1.5.3.jar:?]
>     at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:45)
> [shiro-all-1.5.3.jar:?]
>     at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:40)
> [shiro-all-1.5.3.jar:?]
>     at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:61)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:292)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:181)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:139)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:107)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:98)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:47)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.config.IniFactorySupport.createInstance(IniFactorySupport.java:150)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.util.AbstractFactory.getInstance(AbstractFactory.java:47)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.env.BasicIniEnvironment.<init>(BasicIniEnvironment.java:37)
> [shiro-all-1.5.3.jar:?]
>     at
> org.apache.shiro.env.BasicIniEnvironment.<init>(BasicIniEnvironment.java:41)
> [shiro-all-1.5.3.jar:?]
>
> Could anyone say if it is a bug or it was done intentionally?
>
> --
> Best regards, Alex Sviridov
>
>
>
> --
> Alex Sviridov
>
>

Reply via email to