Shiro web example我遵循了这一点,但是在步骤2中,stormpath被移动到另一个站点okta,所以我不知道我应该做什么。有一个例外:
java.lang.IllegalStateException: Unable to load credentials from any provider in the chain.所以我自己写了一个扩音器。
public class CustomSecurityRealm extends JdbcRealm{
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
char[] psw = upToken.getPassword();
String username = upToken.getUsername();
return new SimpleAuthenticationInfo(username, psw, getName());
}
@Override
public void setDataSource(DataSource dataSource) {
// TODO Auto-generated method stub
DruidDataSource ds=new DruidDataSource();
ds.setUrl("jdbc:mysql://localhost:3306/test2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE");
ds.setUsername("root");
ds.setPassword("root");
dataSource=ds;
}
}在shiro.ini中,我将securityManager.realm = $stormpathRealm更改为securityManager.realm = realm.CustomSecurityRealm,但exception是相同的。或者,当我从tomcat中删除它并重新添加时,有时没有错误,但是没有找到主页--404。我讨厌这样,我只是想看看如何在网络项目中使用shiro,为什么它这么难?我没有jndi,所以我没有复制这个example,我只是想让事情变得简单。如何运行web示例?
发布于 2018-02-20 06:04:20
看一下https://github.com/apache/shiro/tree/master/samples中的示例
我们也会更新该教程。
https://stackoverflow.com/questions/48837649
复制相似问题