首页 > 代码库 > shiro的Helloworld
shiro的Helloworld
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
shiro的Helloworld
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。