shiro的Helloworld
package shiro; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.util.Factory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject; public class ShiroTest { public static void main(String[] args) {
//初始化工厂
Factory<SecurityManager> factory=new IniSecurityManagerFactory("classpath:shiro/shiro.ini");
SecurityManager securityManager=factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
Subject subject=SecurityUtils.getSubject();
UsernamePasswordToken token=new UsernamePasswordToken("tom1","123");
try {
subject.login(token);
System.out.println("登陆成功");
} catch (Exception e) {
e.printStackTrace();
System.out.println("登陆失败");
}
subject.logout();
}
}
shiro
se4j
shiro的Helloworld的更多相关文章
- Shiro 的 HelloWorld
密码文件 [users] zhang=123 wang=123 测试 package org.zln.hello; import org.apache.log4j.LogManager; import ...
- Shiro 加密helloWorld
承接第一章 初解加密 只贴更改的源码,其他看上一篇. ShiroRealm.java package com.lkk.shiro.realms; import org.apache.shiro.aut ...
- Shiro —— 从一个简单的例子开始
一.Shiro是用来做权限的. 二.权限 1.基本概念: (1)安全实体:要保护的数据. (2)权限:是否有能力去操作(查看.修改.删除 )保护的数据. 2.权限的两个特性 (1)权限的继承性:A 包 ...
- Shiro学习笔记(一)
首先展示一下项目的结构目录 工程是用maven创建的 主要是方便管理Jar包 maven的 pom文件中所需要的jar包 <dependencies> <dependency ...
- Apache shiro 笔记整理之web整合一
下面内容是在看了涛哥的<跟我一起学shiro> 和 视频<一头扎入进shiro> 后整理出来备忘和方便自己和其它人学习. 个人主页:http://www.itit123.cn/ ...
- Shiro的基本使用
目录 前言 Shiro的介绍 Shiro功能 补充 HelloWorld 依赖包: 示例代码 代码解析 对于shiro.ini: 对于ShiroDemo.java: 补充 一些概念 Realm 认证 ...
- Shiro-HelloWord
HelloWorld Shiro的HelloWorld不是我们写的,而是看Shiro给我们提供的一段代码.通过这段代码可以看到Shiro大致的使用方式. 1.找到Shiro的jar包 目前的最新稳定版 ...
- Shrio第一天——入门与基本概述
一.Shiro是什么 Apache Shiro是Java的一个安全框架.(希罗:/笑哭) Shiro可以非常容易的开发出足够好的应用,其不仅可以用在JavaSE环境,也可以用在JavaEE环境. sh ...
- Shiro SpringMVC 非maven HelloWorld
项目用到Shiro就从网上找一些案例看看吧,结果看了很多都是maven的,没有办法就自己弄了一个.废话不多说,原理自己找开始上菜. 配置web.xml <?xml version="1 ...
随机推荐
- ExtJS4笔记 Data
The data package is what loads and saves all of the data in your application and consists of 41 clas ...
- A B-tree index can be used for column comparisons in expressions that use the =, >, >=, <, <=, or BETWEEN operators.
http://dev.mysql.com/doc/refman/5.7/en/index-btree-hash.html MySQL 5.7 Reference Manual / ... / ...
- C# base64编码的文本与图片互转
/// <summary> /// base64编码的文本转为图片 /// </summary> /// <param name="txtFilePath&qu ...
- Android 高德地图No implementation found for long com.autonavi.amap.mapcore.MapCore
此篇博客最后更新时间写自2016.5.18.当下高德地图jar版本为3.3.1. 使用高德地图碰到此问题,纠结许久(接近4个多小时). 记录在此,希望遇到相同问题的读者可以有所借鉴. 错误截图: 导致 ...
- mongoose index
1. 当应用程序启动时,Mongoose会自动为模式中的每个定义的索引调用ensureIndex. 虽然很好用于开发,但建议在生产中禁用此行为,因为索引创建可能会导致显着的性能影响. 通过将模式的au ...
- MySQL字符编码
数据表tb的col列编码为latin1.而实际存储的字符是gbk编码时,用下面的语句可以查看到非乱码的原始字符串. select convert( binary(col) using gbk) fro ...
- php函数、php定义数组和数组遍历
<?php //php函数//1.简单函数//四要素:返回类型,函数名,参数列表,函数体 /*function Show(){ echo "hello";} Show();* ...
- OleContainer控件介绍
OLEContainer 控件的主要属性 1) AllowInPlace property AllowInPlace:Boolean; 这个属性用于决定启动O ...
- Python 集合操作
1.集合操作 集合是一个无序的,不重复的数据组合, 他的主要作业如下. 1.去重,把一个列表变成集合,就自动去重了 2.关系测试,测试两组数据之前的交集.差集.并集等关系 list_1 = [1,4, ...
- STL之容器(1)
STL容器类的模板 容器部分主要由头文件<vector>,<list>,<deque>,<set>,<map>,<stack>和 ...