securitymanager

Shiro 身份验证

梦想与她 提交于 2019-12-18 21:44:04
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 身份验证 ,即在应用中谁能证明他就是他本人。一般提供如他们的身份 ID 一些标识信息来表明他就是他本人,如提供身份证,用户名 / 密码来证明。 在 shiro 中,用户需要提供 principals (身份)和 credentials (证明) 给 shiro ,从而应用能验证用户身份: principals :身份,即主体的标识属性,可以是任何东西,如用户名、邮箱等,唯一即可。一个主体可以有多个 principals ,但只有一个 Primary principals ,一般是用户名 / 密码 / 手机号。 credentials :证明 / 凭证,即只有主体知道的安全值,如密码 / 数字证书等。 最常见的 principals 和 credentials 组合就是用户名 / 密码了。接下来先进行一个基本的身份认证。 另外两个相关的概念是之前提到的 Subject 及 Realm ,分别是主体及验证主体的数据源。 2.2 环境准备 本文使用Maven构建,因此需要一点Maven知识。首先准备环境依赖: Java代码 <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version> 4.9

Security: Restrict internal access by third-party software

半城伤御伤魂 提交于 2019-12-18 18:40:12
问题 I have a Java application in which third-party "plugins" can be loaded by users to enhance the user experience. An API exists for use by these plugins, but the third-party software should be restricted from access to internal application classes for purpose of security. The restricted package to plugins would be "com.example" and the allowed would be "com.example.api". The API classes do make calls to the internal, obfuscated classes. After researching this, I came across a couple methods of

Java Policy file - Deny permissions to a codebase

倾然丶 夕夏残阳落幕 提交于 2019-12-18 04:21:36
问题 In the Java policy file, the grant codeBase syntax specifies which codebase should be granted which permissions. for example, grant codeBase "file:/C:/abc.jar" { permission java.security.AllPermission; }; grants AllPermission to code inside abc.jar In a similar way, Is there a way to deny permissions to a specific syntax? Like this: deny codeBase "file:/C:/def.jar" { permission java.io.FilePermission; }; so that the code inside def.jar gets every other permissions except the FilePermission?

Java Policy file - Deny permissions to a codebase

…衆ロ難τιáo~ 提交于 2019-12-18 04:21:17
问题 In the Java policy file, the grant codeBase syntax specifies which codebase should be granted which permissions. for example, grant codeBase "file:/C:/abc.jar" { permission java.security.AllPermission; }; grants AllPermission to code inside abc.jar In a similar way, Is there a way to deny permissions to a specific syntax? Like this: deny codeBase "file:/C:/def.jar" { permission java.io.FilePermission; }; so that the code inside def.jar gets every other permissions except the FilePermission?

SpringBoot(十四):springboot整合shiro-登录认证和权限管理

橙三吉。 提交于 2019-12-17 03:16:47
原文出处: 纯洁的微笑 这篇文章我们来学习如何使用Spring Boot集成Apache Shiro。安全应该是互联网公司的一道生命线,几乎任何的公司都会涉及到这方面的需求。在Java领域一般有Spring Security、Apache Shiro等安全框架,但是由于Spring Security过于庞大和复杂,大多数公司会选择Apache Shiro来使用,这篇文章会先介绍一下Apache Shiro,在结合Spring Boot给出使用案例。 Apache Shiro What is Apache Shiro? Apache Shiro是一个功能强大、灵活的,开源的安全框架。它可以干净利落地处理身份验证、授权、企业会话管理和加密。 Apache Shiro的首要目标是易于使用和理解。安全通常很复杂,甚至让人感到很痛苦,但是Shiro却不是这样子的。一个好的安全框架应该屏蔽复杂性,向外暴露简单、直观的API,来简化开发人员实现应用程序安全所花费的时间和精力。 Shiro能做什么呢? 验证用户身份 用户访问权限控制,比如:1、判断用户是否分配了一定的安全角色。2、判断用户是否被授予完成某个操作的权限 在非 web 或 EJB 容器的环境下可以任意使用Session API 可以响应认证、访问控制,或者 Session 生命周期中发生的事件

Preventing System.exit() from API

▼魔方 西西 提交于 2019-12-17 02:23:25
问题 I am using a third party library that does a System.exit() if it encounters exceptions. I am using the APIs from a jar. Is there anyway that I can prevent the System.exit() call because it causes my application to shutdown? I cannot decompile and recompile the jar after removing the System.exit() because of a lot of other licensing issues. I once came across an answer [to some other question that I do not remember] in stackoverflow that we can use the SecurityManager in Java to do something

springBoot整合shiro

孤街醉人 提交于 2019-12-16 00:19:25
依赖包 <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.3.2</version> </dependency> 数据库表 一切从简,用户 user 表,以及角色 role 表 Shiro 相关类 Shiro 配置类 @Configuration public class ShiroConfig { @Bean public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) { ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); // 必须设置 SecurityManager shiroFilterFactoryBean.setSecurityManager(securityManager); // setLoginUrl 如果不设置值,默认会自动寻找Web工程根目录下的"/login.jsp"页面 或 "/login" 映射 shiroFilterFactoryBean.setLoginUrl("/notLogin"); // 设置无权限时跳转的

shiro权限管理

天涯浪子 提交于 2019-12-15 00:38:51
shiro 1、shiro简介 Apache Shiro是一个强大且易用的Java安全框架,有身份验证、授权、密码学和会话管理。使用Shiro的易于理解的API,您可以快速、轻松地获得任何应用程序,从最小的移动应用程序到最大的网络和企业应用程序。 shiro四大基石: 1、Authentication(身份认证/登录) 2、Authorization(授权) 3、Session Management(会话管理) 4、Cryptography(密码学) 2、shiro架构 Subject: 表示当前用户,不一定是人,也有可能是网络爬虫、机器人等 SecurityManager: 安全管理器, shiro的核心 Realm: 获取安全数据(用户,角色,权限) 3、shiro入门 1、导包 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

上手spring boot项目(二)之spring boot整合shiro安全框架

做~自己de王妃 提交于 2019-12-14 09:31:53
题记 :在学习了springboot和thymeleaf之后,想完成一个项目练练手,于是使用springboot+mybatis和thymeleaf完成一个博客系统,在完成的过程中出现的一些问题,将这些问题记录下来,作为自己的学习心得。在这先感谢群主TyCoding的Tumo项目,虽然本人实在太菜了,好些地方看不懂,但还是使我受益匪浅。 shiro作为一个小巧灵活的安全框架,在认证和授权方面简约但又不简单,十分容易上手使用。下面是整合shiro的具体流程。 1.添加依赖 1 <!--shiro和spring整合--> 2 <dependency> 3 <groupId>org.apache.shiro</groupId> 4 <artifactId>shiro-spring</artifactId> 5 <version>1.3.2</version> 6 </dependency> 7 <!--shiro核心包--> 8 <dependency> 9 <groupId>org.apache.shiro</groupId> 10 <artifactId>shiro-core</artifactId> 11 <version>1.3.2</version> 12 </dependency> 2.在springboot控制台中添加基础包的扫描和实体类的扫描注解 由于本人实在粗心

AccessController doPrivileged can create thread when modifyThreadGroup not granted?

萝らか妹 提交于 2019-12-14 02:47:45
问题 I am trying to prohibit thread creation in an AccessController.doPriviliged() method. The method below creates and runs the thread. I run this with -Djava.security.manager. According to this link, if modifyThreadGroup is not granted, then Thread creation should be disallowed? http://docs.oracle.com/javase/7/docs/technotes/guides/security/permissions.html Can anyone enlighten me as to why this is happening and the correct way to disallow Thread creation using AccessController? // .java.policy