标签:pat ini span 失败 cat oid man classpath sys
1 package shiro; 2 3 import org.apache.shiro.SecurityUtils; 4 import org.apache.shiro.authc.UsernamePasswordToken; 5 import org.apache.shiro.config.IniSecurityManagerFactory; 6 import org.apache.shiro.util.Factory; 7 import org.apache.shiro.mgt.SecurityManager; 8 import org.apache.shiro.subject.Subject; 9 10 public class ShiroTest { 11 12 public static void main(String[] args) { 13 //初始化工厂 14 Factory<SecurityManager> factory=new IniSecurityManagerFactory("classpath:shiro/shiro.ini"); 15 SecurityManager securityManager=factory.getInstance(); 16 SecurityUtils.setSecurityManager(securityManager); 17 Subject subject=SecurityUtils.getSubject(); 18 UsernamePasswordToken token=new UsernamePasswordToken("tom1","123"); 19 try { 20 subject.login(token); 21 System.out.println("登陆成功"); 22 } catch (Exception e) { 23 e.printStackTrace(); 24 System.out.println("登陆失败"); 25 } 26 subject.logout(); 27 } 28 }
shiro
se4j
标签:pat ini span 失败 cat oid man classpath sys
原文地址:http://www.cnblogs.com/javaweb2/p/6260725.html