shiro01-HelloWorld
[users] zhangsan=123456 lisi=123456 public class Test01 { public static void main(String[] args) throws Exception{ Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro01.ini"); SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken("zhangsan", "123456"); subject.login(token); boolean b = subject.isAuthenticated(); System.out.println(b); subject.logout(); b = subject.isAuthenticated(); System.out.println(b); } }