1 / 22

J2EE —— 第 32 章 安全

J2EE —— 第 32 章 安全. 概述. 组件的安全性由容器提供 声明性安全:部署描述符 程序性安全:应用程序中 域:相同身份验证策略的一批用户和组 角色:访问资源权限的抽象名字 JBoss 安全设置 server/default/conf/login-config.xml roles.properties 和 users.properties 文件. 角色映射. 保护 Web 资源. 参见 web.xml 中的 <security-constraint> 指定安全连接 SSL : <transport-guarantee>

sammy
Download Presentation

J2EE —— 第 32 章 安全

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. J2EE——第32章 安全

  2. 概述 • 组件的安全性由容器提供 • 声明性安全:部署描述符 • 程序性安全:应用程序中 • 域:相同身份验证策略的一批用户和组 • 角色:访问资源权限的抽象名字 • JBoss安全设置 • server/default/conf/login-config.xml • roles.properties和users.properties文件

  3. 角色映射

  4. 保护Web资源 • 参见web.xml中的<security-constraint> • 指定安全连接SSL:<transport-guarantee> • CONFIDENGTIAL和INTEGRAL • 角色用户映射:ibm-application-bnd.xmi • 在Web层使用应用程序安全 • GetRemoteUser • IsUserInRole • GetUserPrincipal

  5. 了解登录身份验证 • HTTP基本身份验证 • 基于表单的身份验证 • 客户端证书身份验证 • 相互身份验证 • 摘要身份验证

  6. 使用HTTP基本身份验证

  7. 使用基于表单的身份验证

  8. 使用客户端证书身份验证 • HTTP上的SSL • 公开密钥验证身份 • 数据加密 • 服务器身份验证 • 消息完整性 • 客户端身份验证 • X.509证书

  9. 使用基于证书的相互身份验证

  10. 使用基于密码的相互身份验证

  11. 使用摘要身份验证 • 基于用户名和密码的摘要(加密) • 比基本身份验证的base64编码安全得多 • 举例:创建基于表单验证的Web客户端 • 什么是SSL • 身份验证 • 机密性 • 完整性

  12. 了解数字证书 • 身份验证:知名发证机构签发 • 数据加密:自签发证书 • 使用keytool • 生成服务器证书keystore.jks • 导出证书到server.cer • 签发证书 • 导入证书到信任库cacerts.jks • 生成客户端证书 • 导出到client.cer • 添加证书到信任库cacerts.jks

  13. 配置SSL连接器 • 参照JBoss有关文档 • 验证:https://localhost:1043/ • 并非所有页面都需要安全连接,主要是: • 登录、个人信息、对帐单、信用卡信息页面 • 激活SSL上的相互身份验证 • 将身份验证方法设为Client-Certificate • 或将cerificate域的clientAuth属性设置为true • 证实相互身份验证正在运行:调试消息 <sysproperty key=“javax.net.debug” value=“ssl, handshake”/> <sysproperty key=“javax.net.ssl.keystore” value=“${key.store}”/> <sysproperty key=“java.net.ssl.keyStorePassword” value=“${key.store.password}”/>

  14. 传输层安全 • 部署描述符中指定用户身份验证方法<auth-method> • 部署描述符中定义传输保证 <transport-guarantee>

  15. 具有JAX-RPC的基本身份验证 Stub stub = createProxy(); stub._setProperty( javax.xml.rpc.Stub.USERNAME_PROPERTY, username); stub._setProperty( javax.xml.rpc.Stub.PASSWORD_PROPERTY, password); stub._setProperty (javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, endpointAddress); HelloIF hello = (HelloIF)stub; System.out.println(hello.sayHello("Duke (secure)")); private static Stub createProxy() { // Note: MyHelloService_Impl is implementation-specific. return (Stub)(new MyHelloService_Impl().getHelloIFPort()); }

  16. 具有JAX-RPC的HTTP/SSL之上的客户端证书身份验证 trust.store=${j2ee.home}/domains/domain1/config/cacerts.jks trust.store.password=changeit key.store=${j2ee.home}/domains/domain1/config/keystore.jks key.store.password=changeit System.setProperty("javax.net.ssl.keyStore", keyStore); System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword); System.setProperty("javax.net.ssl.trustStore", trustStore); System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword); stub._setProperty( javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, endpointAddress); • 指定<auth-method>为Client-Certificate • 指定<transport-guarantee>为CONFIDENTIAL

  17. EJB层安全 • 声明方法权限:ejb-jar.xml <security-role> <role-name>Administrators</role-name></security-role> <method-permission> <role-name>Administrators</role-name> <method> <ejb-name>StatelessContainer</ejb-name> <method-name>helloManagers</method-name> </method> </method-permission> • 程序性安全 context.getCallerPrincipal().getName(); context.isCallerInRole(“customer”)

  18. 应用程序客户端层安全 • Java Authentication and Authrorization Service (JAAS) • 初始化LoginContext对象激活身份验证 • 实现CallBackHandler,回调实现与用户的交互

  19. EIS层安全 • 容器管理签名 Context initctx = new InitialContext(); javax.resource.cci.ConnectionFactory cxf =(javax.resource.cci.ConnectionFactory)initctx.lookup( "java:comp/env/eis/MainframeCxFactory"); javax.resource.cci.Connection cx = cxf.getConnection(); • 组件管理签名 com.myeis.ConnectionSpecImpl properties = //.. properties.setUserName("..."); properties.setPassword("..."); javax.resource.cci.Connection cx = cxf.getConnection(properties);

  20. 配置资源适配器安全性 • 身份验证机制:用户名/密码,Kerberos • 重新验证支持:用不同于建立连接时所用的安全上下文来调用getConnection时 • 安全权限:例如允许资源查找任何远程主机名 permission java.net.SocketPermission *, "resolve";

  21. 传播安全标识

  22. 配置组件的传播安全标识 • Security Identity • Use Caller ID • Run As Roles

More Related