Java 你好-帮助Shiro

Java 你好-帮助Shiro,java,web,shiro,Java,Web,Shiro,我的应用程序未就绪shiro.ini。我使用的是一个VRaptor框架,但不是这么慢的shiro.ini。此文件位于类路径上,不读取 public LoginController() { Factory<SecurityManager> factory = new IniSecurityManagerFactory(); SecurityManager securityManager = factory.getInstance(); SecurityUtils.s

我的应用程序未就绪shiro.ini。我使用的是一个VRaptor框架,但不是这么慢的shiro.ini。此文件位于类路径上,不读取

public LoginController()  {
   Factory<SecurityManager> factory = new IniSecurityManagerFactory();
   SecurityManager securityManager = factory.getInstance();
   SecurityUtils.setSecurityManager(securityManager);
}
public boolean autenticar(String email, String password, Boolean rememberMe) throws NoSuchAlgorithmException, UnsupportedEncodingException {
    UsernamePasswordToken token = new UsernamePasswordToken(email, password);
    token.setRememberMe(true);
    Subject subject = SecurityUtils.getSubject();

    try {
        subject.login(token);

    } catch ( UnknownAccountException uae ) { 
        System.out.println(uae.getMessage());
    } catch ( IncorrectCredentialsException ice ) {
        System.out.println(ice.getMessage());
    } catch ( LockedAccountException lae ) {
        System.out.println(lae.getMessage());
    } catch ( ExcessiveAttemptsException eae ){
        System.out.println(eae.getMessage());
    }
    result.redirectTo(LoginController.class).admin();
    return false;
}
西罗·伊尼

[主要]

在shiro.ini中,当[AUTH]将其作为内部错误时,无法识别并且在没有它的情况下出现此错误

`The server encountered an internal error that prevented it from fulfilling this request.`


javax.enterprise.event.ObserverException
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
com.google.common.util.concurrent.ExecutionError:java.lang.NoClassDefFoundError:org/apache/commons/logging/LogFactory com.google.common.cache.LocalCache$Segment.getLocalCache.java:2197 com.google.common.cache.LocalCache.getLocalCache.java:3932 com.google.common.cache.LocalCache.getOrLoadLocalCache.java:3936 com.google.common.cache.LocalCache$LocalLoadingCache.getLocalCache.java:4806 org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValueLoadingCacheUtils.java:52 org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValueLoadingCacheUtils.java:80 org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxyClientProxyProvider.java:204 org.jboss.weld.manager.BeanManagerImpl.getReferenceBeanManagerImpl.java:727
org.jboss.weld.manager.BeanManagerImpl.getReferenceBeanManagerImpl.java:753

如果应用程序正在查找shiro.ini的类路径,则src/main/webapp/web inf目录不是放置它的正确路径

看起来您正在使用maven,如果是这样,它应该放在src/main/resources中。
在生成的webapp中,它应该以WEB-INF/classes结尾

不清楚您在问什么…当从文件not found ERROR访问它时,将它放在shiro.ini的几个地方,但仍然找不到。可以代替shiro.ini穿上table@DiegoSantos看来你在表达自己的问题时遇到了困难。也许您想尝试一下堆栈跟踪,它表明您没有为securityManager设置任何领域。securityManager实例至少需要一个领域。如果您使用的是.ini文件,您可以这样配置OK,谢谢,现在出现了更多的问题,下面的错误配置错误。指定了属性为[loginUrl]的对象[authc],但没有首先定义该对象的类。请首先指定类属性,例如myObject=fully_qualified_class_name,然后定义其他属性。java.lang.IllegalArgumentException:配置错误。指定了属性为[loginUrl]的对象[authc],但没有首先定义该对象的类。请首先指定类属性,例如myObject=fully_qualified_class_name,然后定义其他属性我的系统将重定向解释为link/example并重定向到页面examplo.jspas将其放入shiro.ini中,而不是自己的页面链接
authc.loginUrl = /login
jdbcRealm = br.com.genius.shiro.auth.MyCustomRealm
sha256Matcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
sha256Matcher.storedCredentialsHexEncoded = false  
sha256Matcher.hashIterations = 1024  
jdbcRealm.credentialsMatcher = $sha256Matcher  
jdbcRealm.authenticationQuery = SELECT password, salt FROM User WHERE email = ?
jdbcRealm.permissionsLookupEnabled = true
jdbcRealm.userRolesQuery = select roleName from UserRole where email = ?
jdbcRealm.permissionsQuery = select permission from RolesPermission where    roleName = ?
ds = com.mysql.jdbc.jdbc2.optional.MysqlDataSource
ds.serverName = x.x.x.x
ds.user = xxxx
ds.password = xxxx
ds.databaseName = data
jdbcRealm.dataSource=$ds
authc.usernameParam = email
authc.passwordParam = password
authc.failureKeyAttribute = shiroLoginFailure
builtInCacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $builtInCacheManager
securityManager.realms = $jdbcRealm
[urls]  
/login = authc
/logout = logout
/admin/** = user, roles[admin]
/guest/** = user, roles[guest]`
`The server encountered an internal error that prevented it from fulfilling this request.`


javax.enterprise.event.ObserverException
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)