`
ihuashao
  • 浏览: 4561824 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

SecureAWebApplicationInJBoss

阅读更多

Securing a Web Application in JBoss AS

Securing web resources basically involves setting some stuff in the web deployment descriptor, and in jboss-web.xml. You also have to do a little prep work to the server itself to configure a security domain for JBoss SX. These instructions assume that you have JBoss AS installed, and you have a server instance created with at least Tomcat included. The "default" instance is a good choice here. The variable ${jboss.dist} refers to the location you extracted/installed JBoss AS to, and ${server.name} cooresponds to the name of the server instance you are configuring for security. The first part of these instructions refers to setting up JBoss SX for security, and the second part deals with setting up the web application for security using basic authentication.

Create a simple security domain for JBoss SX

Securing the Web Application with Basic Authentication

Note:Attached is a sample application that can be used to test out securing a web application. There are two files that need to be added/modified in your web application to attach it to the security domain we defined in the previous steps. The web.xml and jboss-web.xml file contain commented out versions of the text to add to a web application that are covered in the next two steps. Also included, is a simple index.jsp that outputs the name of the authenticated JAAS Subject via HttpServletRequest.getRemoteUser().

1. Configure the web application for security by adding constraints to the web deployment descriptor.

You need to modify the web.xml in the WEB-INF directory of the web application you are securing to add in the following:

	<security-constraint>
<web-resource-collection>
<web-resource-name>All resources</web-resource-name>
<description>Protects all resources</description>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>WebAppUser</role-name>
</auth-constraint>
</security-constraint>

<security-role>
<role-name>WebAppUser</role-name>
</security-role>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Test Realm</realm-name>
</login-config>
The "security-constraint" section is what is used to define what resources in the web application are protected. You can have multiple security-constraint elements in the web.xml that have different protections for different resources. You have to have at least one web-resource-collection element to specify what this constraint it protecting. The "url-pattern" element specifies the URL pattern to protect. The example above protects _all_ resources in the web application. The auth-contstraint element specifies which roles have access to the protected resource. The example just specifies one role, but multiple roles can be included by specifying additional role-name elements. This role name needs to match the name of the role you specified in the my-web-roles.properties file. There are ways to have a level of indirection with this role name by using the "security-role-ref" element instead. Finally, the "login-config" element specifies how authentication occurs with the web application. The "auth-method" element specifies how the browser gets credentials from the user. The spec defines "BASIC", "DIGEST", "FORM", and "CLIENT-CERT" as the possible methods to retrieve data from the browser user. The example uses "BASIC" since it is the simplest, but this method shouldn't be used in a production app unless you are also using SSL/TLS since user names and passwords are transmitted in clear text over the network. The "realm-name" element just specifies the authentication realm name that is given to the browser for authentication. This realm is just shown to a user when the authentication dialog is presented.

2. Configure the jboss-web.xml file to point to the "my-web" application.

Add/edit the jboss-web.xml in the WEB-INF directory of the web application you are securing to add the following in the "jboss-web" element:

<security-domain>java:/jaas/my-web</security-domain>
This element tells JBoss AS to connect the web application to the "my-web" security domain we defined in the login-config.xml file earlier. JBoss AS exposes security domains via JNDI by prepending "java:/jaas/" to the name element in the application-policy element in the login-config.xml file.

3. Start up the application server, navigate to your application.

The browser should prompt you for username and password. Enter "chris" for the username, and "secure" for the password. You should then be allowed access to the web application. You can verify this by closing the browser, opening it back up and navigating back to your protected application. When the browser prompts you, you can either enter no credentials, or use the "admin" user account that was in the file originally (password: admin), and see that the web application won't be presented because you didn't log in with a user that had the "WebAppUser?" role.

Related:

JavaWorld JAAS article by Scott Stark: http://prdownloads.sourceforge.net/jboss/jaashowto-32x.zip?download
Attachments:
test.war Info on test.war 1147 bytes
分享到:
评论

相关推荐

    【图像融合】加权算法高分辨率和低分辨率图像融合(含清晰度)【含Matlab源码 4405期】.zip

    Matlab领域上传的视频均有对应的完整代码,皆可运行,亲测可用,适合小白; 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主或扫描视频QQ名片; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作

    源代码-BASISBBS最易ASP论坛 v1.0.7.zip

    源代码-BASISBBS最易ASP论坛 v1.0.7.zip

    【图像去噪】高斯滤波+均值滤波+中值滤波+双边滤波图像去噪(含信噪比)【含Matlab源码 2747期】.zip

    Matlab领域上传的视频均有对应的完整代码,皆可运行,亲测可用,适合小白; 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主或扫描视频QQ名片; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作

    华为2019创新大赛的工程文件+各种模型的backbone和tricks

    华为大模型 华为2019创新大赛的工程文件+各种模型的backbone和tricks 华为2019创新大赛的工程文件+各种模型的backbone和tricks 华为2019创新大赛的工程文件+各种模型的backbone和tricks 华为2019创新大赛的工程文件+各种模型的backbone和tricks 华为2019创新大赛的工程文件+各种模型的backbone和tricks 华为2019创新大赛的工程文件+各种模型的backbone和tricks

    【脑肿瘤检测】 GUI SOM脑肿瘤检测【含Matlab源码 2322期】.zip

    【脑肿瘤检测】 GUI SOM脑肿瘤检测【含Matlab源码 2322期】

    顾客满意度调查表.doc

    顾客满意度调查表.doc

    Excel模板个人简历优雅简约单页30.docx

    Excel模板个人简历优雅简约单页30.docx

    响应式web前段开发程序源代码

    响应式web前段开发程序一书的所有源代码,PPT,课件,免费不要钱,有需要的下载即可,我是好人!给我点赞,让更多的大学生看见,大学生help大学生!

    HC400-20标定版描述文件及标定版ps文件

    HC400-20标定版描述文件及标定版ps文件

    光伏出力、风电出力基于skleran算法实现对光伏和风电输出进行准确预测Python源码+详细注释+报告.zip

    【备注】 1.项目代码功能经验证ok,确保稳定可靠运行。欢迎下载使用!在使用过程中,如有问题或建议,请及时私信沟通。 2.主要针对各个计算机相关专业,包括计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网等领域的在校学生、专业教师或企业员工使用。 3.项目具有丰富的拓展空间,不仅可作为入门进阶,也可直接作为毕设、课程设计、大作业、初期项目立项演示等用途。 4.当然也鼓励大家基于此进行二次开发。 5.期待你能在项目中找到乐趣和灵感,也欢迎你的分享和反馈! 光伏出力、风电出力基于skleran算法实现对光伏和风电输出进行准确预测Python源码+详细注释+报告.zip 光伏出力、风电出力基于skleran算法实现对光伏和风电输出进行准确预测Python源码+详细注释+报告.zip 光伏出力、风电出力基于skleran算法实现对光伏和风电输出进行准确预测Python源码+详细注释+报告.zip 光伏出力、风电出力基于skleran算法实现对光伏和风电输出进行准确预测Python源码+详细注释+报告.zip

    【交通标志识别】 GUI BP神经网络雾霾天气交通标志识别(带面板)【含Matlab源码 1771期】.zip

    【交通标志识别】 GUI BP神经网络雾霾天气交通标志识别(带面板)【含Matlab源码 1771期】

    【图像加密】 GUI混沌系统图像加密解密【含Matlab源码 147期】.zip

    Matlab领域上传的视频均有对应的完整代码,皆可运行,亲测可用,适合小白; 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主或扫描视频QQ名片; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作

    stm32八路灰度循迹小车

    STM32F103

    Excel模板Github上10个值得学习的Springboot开发项目.pdf

    Spring Boot 是一个开源的 Java 框架,用于简化 Spring 应用程序的初始搭建以及开发过程。它提供了许多默认配置,使得开发者能够更快速地构建应用。以下是一些 Spring Boot 的开发案例,这些案例展示了如何使用 Spring Boot 来构建不同类型的应用程序。 Web 应用程序: 博客系统:可以使用 Spring Boot 创建一个简单的博客系统,包括用户注册、登录、发布文章、评论等功能。利用 Spring Boot 的自动配置特性,可以快速搭建起一个 Web 服务器,并通过 Spring MVC 实现 RESTful API。 在线商店:Spring Boot 可以用来构建电商网站,包括商品展示、购物车、订单处理、支付集成等功能。

    node-v0.9.6-x64.msi

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    从交易模式看游戏陪玩平台的运行逻辑(一).docx

    从交易模式看游戏陪玩平台的运行逻辑(一).docx

    产品属性检验记录表(注塑).xls

    产品属性检验记录表(注塑).xls

    【车牌识别】 GUI模板匹配车牌识别门禁系统(带面板)【含Matlab源码 1091期】.zip

    Matlab领域上传的视频均有对应的完整代码,皆可运行,亲测可用,适合小白; 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主或扫描视频QQ名片; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作

    基于SpringBoot+Maven的校园二手交易网站

    项目背景: 校园二手交易网站旨在为学生提供一个便捷、安全的二手物品交易平台,促进资源循环利用,减轻学生经济负担。通过SpringBoot和Maven技术栈,构建一个高效、易维护的二手交易网站。 项目目标: 搭建一个功能齐全的二手交易平台,方便学生发布和浏览二手商品信息。 提供安全的用户认证和交易保护机制,确保交易的可靠性和安全性。 实现简洁美观的用户界面,提升用户体验。 主要功能: 用户管理:支持用户注册、登录、信息修改和账户管理。 商品发布与管理:用户可以发布、编辑、删除自己的二手商品信息,并查看其他用户发布的商品。 商品搜索与分类:支持按关键词、类别和价格范围等条件搜索商品,方便用户快速找到所需物品。 消息通知:提供买卖双方的消息通知和交流功能,促进交易沟通。 交易记录:记录用户的交易历史,方便用户查看和管理交易信息。 技术实现: 后端开发:使用SpringBoot框架构建后端服务,处理用户认证、商品管理和交易记录等功能。 前端开发:使用Thymeleaf模板引擎和Bootstrap框架开发用户界面,实现响应式设计和良好的用户体验。 数据持久化:使用MySQL数据库存储用

    labelme, 一个用于图像标记的工具

    使用python3以上版本

Global site tag (gtag.js) - Google Analytics