shiro學習 二 入門認證

2021-10-23 12:50:10 字數 1230 閱讀 1858

使用 test  完成最基本簡單的認證流程。

1、建立 securitymanager 

2、主體(subject) 提交請求

3、securitymanager 認證

4、authenticator 認證

5、realm 驗證

org.apache.shiro

shiro-core

1.6.0

junit

junit

4.12

test

package ch.shiro.test;

import org.apache.shiro.securityutils;

import org.apache.shiro.authc.authenticationtoken;

import org.apache.shiro.authc.usernamepasswordtoken;

import org.apache.shiro.mgt.defaultsecuritymanager;

import org.apache.shiro.realm.******accountrealm;

import org.apache.shiro.subject.subject;

import org.junit.before;

import org.junit.test;

/** * 認證測試類.

* * @author ch

* @version 1.0.0

* @since 1.0.0

* * created at 2020/8/19 4:52 下午

如果修改賬號,則會報錯:

如果修改密碼,則會報錯:

shiro入門學習二

shiro是 apache 的乙個開源框架,是乙個許可權管理的框架,實現 使用者認證 使用者授權。spring中有 spring security 原名acegi 是乙個許可權框架,它和 spring 依賴過於緊密,沒有 shiro 使用簡單。shiro不依賴於 spring shiro 不僅可以實...

Shiro認證 初學(二)

1 前後端分離 更改以前的ajax請求,由於目前的專案基本上都是前後端分離的,所以我們所有的資料都已json格式返回給前端,對沒有登入的請求進行攔截,覆蓋掉shiro原本的跳轉到login.jsp頁面,繼承formauthenticationfilter public class ajaxpermi...

Shiro入門 認證過程詳解

1 shiro認證流程 2 建立表單 3 編寫shirohandler controller public class shirohandler 所有認證時異常的父類 catch authenticationexception ae return redirect list.jsp return s...