JDK源码分析——SecurityManager安全管理器实例分析

目录


1 样例github

https://github.com/mh47838704/JavaExample

参考文章:http://47777205.com/view/24


2 安全管理器简介

* The security manager is a class that allows
* applications to implement a security policy. It allows an
* application to determine, before performing a possibly unsafe or
* sensitive operation, what the operation is and whether
* it is being attempted in a security context that allows the
* operation to be performed. The
* application can allow or disallow the operation

上面是摘自安全管理器的介绍:Java安全管理器允许应用程序设置一个安全管理策略,通过安全管理策略实现对应用程序中的敏感的操作的管理(运行或者是禁制)

2.1 获取系统管理器

在Java中应用程序启动的时候是默认没有设置安全管理器的,可以通过下面的代码观察,下面的代码在常规的启动的时候会输出null:

System.out.println("系统当前的安全管理器:"+System.getSecurityManager());

2.2 设置系统管理器

在Java中可以通过配置启用jdk中默认的安全管理器,然后再使用上面的代码调试,那么会显示相应的实例,而不是null


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值