标签:imp iss public null for pac real 密码 vat
流程图:
@BeforeClass -> @before -> @Test ->@After ->@AfterClass
public class IsSpringbootShiroApplicationTests {
private DefaultSecurityManager defaultSecurityManager = new
DefaultSecurityManager();
private SimpleAccountRealm realm = new SimpleAccountRealm();
@Before
public void init (){
//初始化数据源
realm.addAccount("woxbwo","123");
realm.addAccount("zbbiex","456");
//构建SecurityManager的执行环境
defaultSecurityManager.setRealm(realm);
}
@Test
public void testAuthentication() {
SecurityUtils.setSecurityManager(defaultSecurityManager);
//获取当前主题 application 或者 user
Subject subject = SecurityUtils.getSubject();
//用户名密码
UsernamePasswordToken usernamePasswordToken = new
UsernamePasswordToken("zbbiex","456");
subject.login(usernamePasswordToken);
//获取认证结果
boolean res = subject.isAuthenticated();
System.out.println("认证结果为:"+res);
}
}
测试结果:
17:43:51.857 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager - No sessionValidationScheduler set. Attempting to create default instance.
17:43:51.857 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager - Enabling session validation scheduler...
17:43:51.863 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
认证结果为:true
标签:imp iss public null for pac real 密码 vat
原文地址:https://www.cnblogs.com/woxbwo/p/11277718.html