shiro web 一步一步的例子不起作用,stormpath 被移动了
shiro web step by step example not work,stormpath is moved
Shiro web example
我按照这个,但是在第2步,stormpath is moved to another site okta,所以我不知道我该怎么做。
有一个例外:
java.lang.IllegalStateException: Unable to load credentials from any provider in the chain.
于是自己写了一个reamls
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
但例外是一样的。或者有时我从tomcat中删除它并再次添加时没有错误,但是找不到主页--404。
我讨厌这个,我只是想看看如何在 web 项目中使用 shiro,为什么这么难?
我没有jndi,所以我没有从这个example中复制,我只是想简单点。我怎样才能 运行 Web 样本?
看看https://github.com/apache/shiro/tree/master/samples
中的例子
我们也会更新该教程。
Shiro web example 我按照这个,但是在第2步,stormpath is moved to another site okta,所以我不知道我该怎么做。 有一个例外:
java.lang.IllegalStateException: Unable to load credentials from any provider in the chain.
于是自己写了一个reamls
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
但例外是一样的。或者有时我从tomcat中删除它并再次添加时没有错误,但是找不到主页--404。
我讨厌这个,我只是想看看如何在 web 项目中使用 shiro,为什么这么难?
我没有jndi,所以我没有从这个example中复制,我只是想简单点。我怎样才能 运行 Web 样本?
看看https://github.com/apache/shiro/tree/master/samples
中的例子我们也会更新该教程。