【Shiro 框架总结】1 简介

Shiro简介 之前在工作中有比较快速的学习过Shiro安全框架,但经过一年的荒废,已经不是很熟悉了,通过这个系列,深入研究和学习Shiro的一些知识,填补安全管理方面的知识漏洞。使我们在web 开发领域更具竞争力,不做只会CRUD的程序员! 一、Shiro介绍 Shiro是一个Java安全框架,执行身份验证、授权、密码、会话管理。Shiro是Apache 的一个开源项目,前身是JSecurity 项目,始于20... 阅读详情

一、简介

• Apache Shiro 是 Java 的一个安全(权限)框架。
• Shiro 可以非常容易的开发出足够好的应用,其不仅可以用在JavaSE 环境,也可以用在 JavaEE 环境。
• Shiro 可以完成:认证、授权、加密、会话管理、与Web 集成、缓存等。
• 下载:http://shiro.apache.org/

 

二、功能简介

1. Authentication:身份认证/登录,验证用户是不是拥有相应的身份
2. Authorization:授权,即权限验证,验证某个已认证的用户是否拥有某个权限;即判断用户是否能进行什么操作,如:验证某个用户是否拥有某个角色。或者细粒度的验证某个用户对某个资源是否具有某个权限
3. Session Manager:会话管理,即用户登录后就是一次会话,在没有退出之前,它的所有信息都在会话中;会话可以是普通 JavaSE 环境,也可以是 Web 环境的
4. Cryptography:加密,保护数据的安全性,如密码加密存储到数据库,而不是明文存储
5. Web Support:Web 支持,可以非常容易的集成到Web 环境;
6. Caching:缓存,比如用户登录后,其用户信息、拥有的角色/权限不必每次去查,这样可以提高效率
7. Remember Me:记住我,这个是非常常见的功能,即一次登录后,下次再来的话不用登录了

 

三、Shiro架构

1. 从外部来看Shiro ,即从应用程序角度的来观察如何使用 Shiro 完成工作

(1)Subject:应用代码直接交互的对象是 Subject,也就是说 Shiro 的对外API 核心就是 Subject。Subject 代表了当前“用户”, 这个用户不一定是一个具体的人,与当前应用交互的任何东西都是 Subject,如网络爬虫,机器人等;与 Subject 的所有交互都会委托给 SecurityManager;Subject 其实是一个门面,SecurityManager 才是实际的执行者


(2)SecurityManager:安全管理器;即所有与安全有关的操作都会与SecurityManager 交互;且其管理着所有 Subject;可以看出它是 Shiro的核心,它负责与 Shiro 的其他组件进行交互,它 相当于 SpringMVC 中DispatcherServlet 的角色


(3)Realm:Shiro 从 Realm 获取安全数据(如用户、角色、权限),就是说SecurityManager 要验证用户身份,那么它需要从 Realm 获取相应的用户进行比较以确定用户身份是否合法;也需要从 Realm 得到用户相应的角色/权限进行验证用户是否能进行操作;可以把 Realm 看成 DataSource

 

2. 从内部看Shiro架构

(1)Subject:任何可以与应用交互的“用户”
(2)SecurityManager :相当于SpringMVC 中的 DispatcherServlet;是 Shiro 的心脏;所有具体的交互都通过 SecurityManager 进行控制;它管理着所有 Subject、且负责进行认证、授权、会话及缓存的管理
(3)Authenticator:负责 Subject 认证,是一个扩展点,可以自定义实现;可以使用认证策略(Authentication Strategy),即什么情况下算用户认证通过了
(4) Authorizer:授权器、即访问控制器,用来决定主体是否有权限进行相应的操作;即控制着用户能访问应用中的哪些功能
(5) Realm:可以有 1 个或多个 Realm,可以认为是安全实体数据源,即用于获取安全实体的;可以是JDBC 实现,也可以是内存实现等等;由用户提供;所以一般在应用中都需要实现自己的 Realm
(6) SessionManager:管理 Session 生命周期的组件;而 Shiro 并不仅仅可以用在 Web 环境,也可以用在如普通的 JavaSE 环境
 (7)CacheManager:缓存控制器,来管理如用户、角色、权限等的缓存的;因为这些数据基本上很少改变,放到缓存中后可以提高访问的性能
(8) Cryptography:密码模块,Shiro 提高了一些常见的加密组件用于如密码加密/解密。

 

四、简单的案例

1. 创建java的项目,并导入jar包

2. 粘贴配置文件

【提示】shiro-root的资源可以在git上下载

3. 粘贴案例helloworld

4. 运行

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.Factory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * Simple Quickstart application showing how to use Shiro's API.
 *
 * @since 0.9 RC2
 */
public class Quickstart {

    private static final transient Logger log = LoggerFactory.getLogger(Quickstart.class);


    public static void main(String[] args) {

        // The easiest way to create a Shiro SecurityManager with configured
        // realms, users, roles and permissions is to use the simple INI config.
        // We'll do that by using a factory that can ingest a .ini file and
        // return a SecurityManager instance:

        // Use the shiro.ini file at the root of the classpath
        // (file: and url: prefixes load from files and urls respectively):
        Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini");
        SecurityManager securityManager = factory.getInstance();

        // for this simple example quickstart, make the SecurityManager
        // accessible as a JVM singleton.  Most applications wouldn't do this
        // and instead rely on their container configuration or web.xml for
        // webapps.  That is outside the scope of this simple quickstart, so
        // we'll just do the bare minimum so you can continue to get a feel
        // for things.
        SecurityUtils.setSecurityManager(securityManager);

        // Now that a simple Shiro environment is set up, let's see what you can do:

        // get the currently executing user:
        Subject currentUser = SecurityUtils.getSubject();

        // Do some stuff with a Session (no need for a web or EJB container!!!)
        Session session = currentUser.getSession();
        session.setAttribute("someKey", "aValue");
        String value = (String) session.getAttribute("someKey");
        if (value.equals("aValue")) {
            log.info("Retrieved the correct value! [" + value + "]");
        }

        // let's login the current user so we can check against roles and permissions:
        if (!currentUser.isAuthenticated()) {
            UsernamePasswordToken token = new UsernamePasswordToken("lonestarr", "vespa");
            token.setRememberMe(true);
            try {
                currentUser.login(token);
            } catch (UnknownAccountException uae) {
                log.info("There is no user with username of " + token.getPrincipal());
            } catch (IncorrectCredentialsException ice) {
                log.info("Password for account " + token.getPrincipal() + " was incorrect!");
            } catch (LockedAccountException lae) {
                log.info("The account for username " + token.getPrincipal() + " is locked.  " +
                        "Please contact your administrator to unlock it.");
            }
            // ... catch more exceptions here (maybe custom ones specific to your application?
            catch (AuthenticationException ae) {
                //unexpected condition?  error?
            }
        }

        //say who they are:
        //print their identifying principal (in this case, a username):
        log.info("User [" + currentUser.getPrincipal() + "] logged in successfully.");

        //test a role:
        if (currentUser.hasRole("schwartz")) {
            log.info("May the Schwartz be with you!");
        } else {
            log.info("Hello, mere mortal.");
        }

        //test a typed permission (not instance-level)
        if (currentUser.isPermitted("lightsaber:weild")) {
            log.info("You may use a lightsaber ring.  Use it wisely.");
        } else {
            log.info("Sorry, lightsaber rings are for schwartz masters only.");
        }

        //a (very powerful) Instance Level permission:
        if (currentUser.isPermitted("winnebago:drive:eagle5")) {
            log.info("You are permitted to 'drive' the winnebago with license plate (id) 'eagle5'.  " +
                    "Here are the keys - have fun!");
        } else {
            log.info("Sorry, you aren't allowed to drive the 'eagle5' winnebago!");
        }

        //all done - log out!
        currentUser.logout();

        System.exit(0);
    }
}

小结:自己看一下代码,里面有英文解析!

`全网最细!! 入门必看Git教程链接:https://gitee.com/all-about-git` 全网 Git 入门教程 gitee.com。如果显示The requested URL returned error: 403错误,那就表示没有和window本地建立token令牌 阅读详情

相关推荐

Keil MDK编译错误#541解决方案与ARM_Compiler包解析

在嵌入式开发中,编译器工具链的依赖管理是确保项目顺利构建的关键环节。以Keil MDK为例,其软件包依赖机制通过组件化设计实现功能解耦,其中ARM_Compiler包专门处理系统IO重定向等编译器扩展功能。这种架构既提升了模块复用性,也带来了版本兼容性挑战。当出现'Error #541: component missing'报错时,通常是由于中间件组件(如文件系统)在新版本中显式依赖了ARM_Compiler包。开发者需要通过Pack Installer安装该包,并在Run-Time Environment

weixin_32129187的博客 373

SHIRO框架学习-1基础框架

一、SHIRO API,基本功能点: Authentication:身份认证/登录,验证用户是不是拥有相应的身份。 Authorization:授权,即权限验证,验证某个已认证的用户是否拥有某个权限;常见的如:验证某个用户是否拥有某个角色,或者是否对某个资源具有某个权限。 Session Manager:会话管理,及用户登录后就是一次会话,在没有退出之前,他的所有信息都在会话中. Cr...

visionzheng的博客 305

编码约定的自由度:重新思考Hamming码在实际工程中的灵活应用

本文探讨Hamming码在实际工程中的灵活应用,突破标准实现的思维定式。通过分析不同编码约定的优缺点和资源受限环境下的设计权衡,展示如何根据嵌入式系统、通信协议等具体需求定制汉明码实现,优化编解码效率并降低硬件开销。

perl8的博客 179

基于RBAC的权限管理框架Shiro(1)框架简介

Shiro是apache旗下一个开源框架,它将软件系统的安全认证相关的功能抽取出来,实现用户身份认证,权限授权、加密、会话管理等功能,组成了一个通用的安全认证框架。也是当下比较主流的轻量级权限管理框架。相较于spring security(原名Acegi)必须依赖spring ,shiro就显的非常独立。 Shiro 的核心: Subject 主体 用于记录当前的操作用户,Subject在shir

科技改变生活,技术连接你我 5113

Matlab机械臂建模:机器人工具箱的使用&&导入自己的机械臂模型

本文主要介绍如何在matlab中建立机械臂模型(前提要下载了Robotics Toolbox机器人工具箱~),并进行基于正逆运动学计算的轨迹运动。对于已有的Solidworks机械臂三维模型,如何导入Matlab,并对其进行运动控制。

m0_46427461的博客 5万+

OmniQuant:全方位校准实现大语言模型高效量化与移动端部署

模型量化是一种通过降低模型权重和激活值的数值精度来压缩模型大小、减少内存占用和计算开销的核心技术。其原理在于将高精度浮点数映射到低精度整数表示,从而在保持模型性能的同时,显著提升存储和计算效率。这项技术的价值在于,它使得大规模语言模型能够在消费级硬件和资源受限的移动设备上运行,极大地拓宽了AI应用场景。OmniQuant作为一项前沿的量化技术,通过引入可学习权重裁剪和可学习等价变换机制,实现了对权重分布不均匀和激活值异常值问题的协同优化,从而在极低的比特数下仍能保持优异的模型性能。本文深入探讨了OmniQu

weixin_30719711的博客 485

Shiro 安全框架1—简介、核心组件与架构

Shiro 安全框架1—简介、核心组件与架构 一、简介 1.1 概述 Apache Shiro(发音为“shee-roh”,日语“堡垒(Castle)”的意思)是一个强大易用的 Java 安全框架,可以干净地处理身份验证,授权,企业会话管理,单点登录和加密服务,可为任何应用提供安全保障 - 从命令行应用、移动应用到大型网络及企业应用。 1.2 特点 Apache Shiro的首要目标是易于使用和理...

JackiAndroid的专栏 1416

车载软件架构 -- SOA服务分层设计原则

摘要: 本文系统阐述了车载SOA(面向服务架构)的核心价值与分层设计原则。传统汽车软件架构因功能耦合度高、升级困难等问题难以适应智能汽车发展需求,而SOA通过服务化设计实现模块化解耦,支持跨域协同与生态开放,显著提升开发效率和可维护性。文章详细解析了服务分层策略(原子服务、基础服务、应用服务)及其设计原则:原子服务作为最小功能单元实现硬件抽象;基础服务整合原子服务提供通用能力;应用服务面向具体业务场景。分层架构有效降低了系统复杂度,使各层可独立演进,为智能汽车软件生态建设提供了方法论支撑。

Soly_kun的博客 731

Shiro权限框架简介

最近加入了gxpt项目组,被安排做权限模块,所以也有幸第一次接触到了Shiro框架。让我们来一起领略Shiro的风采吧。 什么是Apache Shiro?        Apache Shiro(发音为“shee-roh”,日语“堡垒(Castle)”的意思)是一个强大易用的Java安全框架,提供了认证、授权、加密和会话管理功能,可为任何应用提供安全保障 - 从命令行应用、移动应用到大型网络及

崔成龙 . 勇往直前 2万+

Python爬虫应对Cloudflare防护:5秒盾+Turnstile验证码实战(AST反混淆+指纹模拟,成功率95%)

Cloudflare 5秒盾+Turnstile验证码的防护核心,是通过“前端JS挑战+多维度指纹校验”确认请求来源的真实性。用AST反混淆还原CF的验证逻辑,避免执行无用代码导致的验证失败;基于真实浏览器采集指纹,确保指纹维度100%匹配真人环境;结合轻量级JS引擎和自动化工具,模拟完整的浏览器执行环境。该方案的绕过成功率可达95%(剩余5%主要是IP或请求频率导致的风控),适用于绝大多数部署CF防护的网站。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1719

基于方差分解分析气象/水文干旱驱动因素(含MATLAB全代码)

简介基于方差分解方法分析气象/水文干旱驱动因素

WW、forever的博客 803

Apache Shiro框架简介

shiro是什么 我们在做web应用时总会需要做登录等身份认证。 一般情况下我们都是自己写加密(例如MD5加密)和 帐号密码对比。 一般做法通过表单提交用户名及密码达到认证目的。 权限方面的管理则通过一般的判断。 比如哪个账户可以看到哪些模块,可以进行哪些操作。 而shiro就是一个封装以上需求操作的开源框架。它能帮助我们更好更方便的做好web应用的安全管理。而不需

直到世界的尽头 1965

【Bug已解决】Codex CLI 运行时出现 command not found: codex 解决方案

方案适用场景推荐指数修复 PATH 配置最常见的基础排查方向⭐⭐⭐⭐⭐检查原生二进制完整性PATH 正常但执行仍然异常⭐⭐⭐⭐统一包管理器混用多种包管理器导致混乱⭐⭐⭐⭐确认安装脚本未被跳过CI/CD 或企业策略环境⭐⭐⭐⭐排查网络下载渠道企业内网/受限网络环境⭐⭐⭐需要留意 warning 中是否涉及脚本执行失败、网络超时重试等信息,这类 warning 往往是后续问题的前兆,建议出现明显的下载/网络相关警告时就主动重新安装一次确认。Codex CLI 报。

一键难忘的博客 1万+

Shiro(一)shiro 框架简介

Shiro简介 Apache Shiro是一个强大且易用的Java安全框架,执行身份验证、授权、密码学和会话管理。 Apache Shiro 体系结构: 1、Authentication 认证 ---- 用户登录 2、Authorization 授权 — 用户具有哪些权限 3、Cryptography 安全数据加密 4、Session Management 会话管理 5、Web Integrat...

qq_40634246的博客 271

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

java框架之Shiro-安全/权限框架

准备 简介 Apache Shiro 是 Java 的一个安全(权限)框架。 Shiro 不仅可以用在 JavaSE 环境,也可以用在 JavaEE 环境。 Shiro 可以完成:认证、授权、加密、会话管理、与 Web 集成、缓存等。 Shiro 官网:https://shiro.apache.org|官网下载 shiro-1.3.2 源码包 | 百度云下载 shiro-1....

weixin_30463341的博客 378

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

Apache Shiro 使用手册(一)Shiro架构介绍 博客分类: 开发 安全框架Shiro 一、什么是Shiro Apache Shiro是一个强大易...

Apache Shiro 使用手册(一)Shiro架构介绍 博客分类:   开发 安全框架Shiro 一、什么是Shiro Apache Shiro是一个强大易用的Java安全框架,提供了认证、授权、加密和会话管理等功能:  认证 - 用户身份识别,常被称为用户“登录”; 授权 - 访问控制; 密码加密 - 保护或隐藏数据防止被偷窥; 会话管理 - 每用户相关的时...

lishoubin 200

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Shiro框架的简介

1, 什么是shiro Apache Shiro 是Java 的一个安全框架。Shiro 可以非常容易的开发出足够好的应用,其不仅可以用在JavaSE 环境,也可以用在JavaEE 环境。Shiro 可以帮助我们完成:认证、授权、加密、会话管理、与Web 集成、缓存等。 2,为什么要学shiro 1,既然shiro将安全认证相关的功能抽取出来组成一个框架,使用shiro就可以非常快速的完成...

weixin_44664095的博客 916

Shiro安全框架简介

Shiro默认实用的是simpleCredentialsMatcher中的doCredentialsMatcher方法,这个方法使用的是equals的方式进行比较密码。调用subject中的isPermittedAll方法,参数为可变长参数(可以传一个或者多个)【如果是多个,那么这个主体需要拥有参数里面所有的权限字符串才能访问】在doGetAuthenticationInfo方法中获取用户的身份信息,然后校验是否和数据库中的一致。Shiro不依赖于WEB,即使是一个测试程序也能够使用Shiro中的功能。

weixin_45934981的博客 1634

shiro框架简介

前言 Apache Shiro是Java的一个轻量级安全框架,shiro可以帮助我们完成:认证、授权、加密、会话管理、与Web集成、缓存 使用起来简单方便。 而spring的安全框架Spring Security,虽然功能更加强大,但使用起来复杂,但是在实际工作时可能并不需要那么复杂的东西,所以使用小而简单的Shiro就足够了 1.shiro 框架功能 功能图: ...

weixin_42325327的博客 743

Shiro框架

本文主要介绍了Shiro框架的概念与使用,包括权限管理、Shiro框架简介、Shiro的配置、认证业务、认证后获得用户信息、登出、Handler方法与权限等内容。供个人学习使用。

专注Java和MySQL领域知识分享 1509

Shiro框架1——基础概念

身份认证,就是判断一个用户是否为合法用户的处理过程。最常用的简单身份认证方式是系统通过核对用户输入的用户名和口令,看其是否与系统中存储的该用户的用户名和口令一致,来判断用户身份是否正确。对于采用指纹等系统,则出示指纹;对于硬件Key等刷卡系统,则需要刷卡。授权,即访问控制,控制谁能访问哪些资源。主体进行身份认证后需要分配权限方可访问系统的资源,对于某些资源没有权限是无法访问的。

qq_64064246的博客 857

安全框架Shiro——Shiro简介、架构、Quickstart程序

目录 一、Shiro简介 1、功能简介 2、Shiro 架构 二、Shiro的HelloWorld程序 Quickstart类的分析 一、Shiro简介 Apache Shiro 是 Java 的一个安全(权限)框架。 Shiro 可以非常容易的开发出足够好的应用,其不仅可以用在JavaSE 环境,也可以用在 JavaEE 环境。• Shiro 可以完成:认证、授权、加密、会...

Guizy 1048

权限管理框架Shiro简介

权限管理框架shiro

weixin_38526781的博客 2494

Shiro(1)--Shiro简介

强烈推荐一个大神的人工智能的教程:http://www.captainbed.net/zhanghan 一、作用简介 Apache Shiro是一个强大且易用的Java安全框架,可以执行身份验证、授权、密码学和会话管理。 二、功能简介 Authentication:身份认证/登录,验证用户是不是拥有相应的身份。 Authorization:授权,即权限认证...

至尊宝 2万+

shiro框架的基本理解

1.简介 shiro是一个安全框架,可以进行认证、授权、密码加密、会话管理 从外部来解析shiro框架: Subject:主体,代表了当前“用户”,这个用户不一定是一个具体的人,与当前应用交互的任何东西都是Subject,如网络爬虫,机器人等;即一个抽象概念;所有Subject都绑定到SecurityManager,与Subject的所有交互都会委托给SecurityManage

明天 1万+

shiro框架简介以及与spring的整合搭建

1.shiro框架简介 1.1.shiro是什么? Apache Shiro是Java的一个安全(权限)框架。 Shiro 可以非常容易的开发出足够好的应用,其不仅可以用在JavaSE 环境,也可以用在 JavaEE 环境。Shiro 可以完成:认证、授权、加密、会话管理、与Web 集成、缓存等。 1.2.shiro基本功能 Authentication:身份认证/登录,验证用户是不是拥有相应的身份; Authorization:授权,即权限验证,验证某个已认证的用户是否拥有某个权限;即判断用

qq_41644069的博客 1215
上一篇: 【SpringMVC 3.X 总结】10 拦截器
下一篇: 【Shiro框架总结】2. Shiro集成SpringMVC
Rita楠神
博客等级 码龄9年 27粉丝 61原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值