Java EE 8:构建现代企业应用的全面指南
1. 安全概述
在当今的 IT 领域,安全是至关重要的。过去,一些重大的安全问题包括弱加密和哈希算法、密码存储方式以及自行开发的安全实现。以下是一些重要的安全原则:
- 对通信进行加密。
- 使用外部可信的安全提供商进行身份验证和授权。
- 避免将凭据置于版本控制之下。
- 包含验证保护的测试场景。
通信通常在传输层使用 TLS 进行加密,使用的证书应通过公司内部或官方证书颁发机构正确签名。其他方法包括使用协议层的安全功能,例如在加密通信之上使用 HTTP 基本身份验证。
1.1 SecurityContext 示例
以下是 SecurityContext 的示例用法:
import javax.security.enterprise.SecurityContext;
@Stateless
public class CompanyProcesses {
@Inject
SecurityContext securityContext;
public void executeProcess() {
executeUserProcess();
if (securityContext.isCallerInRole("admin")) {
String name = securityContext.getCallerPrincipal().getName();
executeAdminProcess(name);
超级会员免费看
订阅专栏 解锁全文
1033

被折叠的 条评论
为什么被折叠?



