Jboss7.1 加入realm auth认证 bootsfaces 美化的登录页面
jboss-as-7.1.1.Final\standalone\configuration:
1, standalone.xml中 <security-domains>标签里面添加:
<security-domain name="myRealm" cache-type="default">
<authentication>
<login-module code="Remoting" flag="required">
<module-option name="usersProperties" value="${jboss.server.config.dir}/application-users.properties"/>
<module-option name="rolesProperties" value="${jboss.server.config.dir}/application-roles.properties"/>
<module-option name="realm" value="ApplicationRealm"/>
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
</authentication>
</security-domain>
使用application-users.properties,application-roles.properties中定义的用户和角色。
2,在war中 WEB-INF 中加入文件 jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>java:/jaas/myRealm</security-domain>
</jboss-web>
3,在 web.xml中加入:
<security-constraint>
<display-name>Example Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>guest</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>myRealm</realm-name>
</login-config>
<security-role>
<description> A user </description>
<role-name>guest</role-name>
</security-role>
另外需注意,如果使用 primefaces,bootsfaces,由于他们使用css样式或者js,ttf等文件,如果他们位于需要认证的目录,但是login.xhtml又需要访问。这时需要在web.xml中排除掉 secure-constaint. 由于这个原因,登录页面的用户图标一直不显示,还得我调试了一天b:icon。
用bootfaces做的登录页面:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:b="http://bootsfaces.net/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:head>
<title>Sign In Template for BootsFaces</title>
<meta name="author" content="Riccardo Massera"></meta>
<style type="text/css">
.form-signin {
margin: 0 auto;
max-width: 330px;
padding: 15px;
}
</style>
</h:head>
<h:body style="padding-top: 60px; background-color: #add;">
<b:container>
<h:form id="login" onsubmit="action='j_security_check';" styleClass="form-signin">
<h2 class="form-signin-heading">请登陆</h2>
<b:inputText id="j_username1" placeholder="Email address" fieldId="j_username" name="j_username">
<f:facet name="prepend">
<b:icon name="user" />
</f:facet>
</b:inputText>
<b:inputText id="j_password1" placeholder="Password" type="password" fieldId="j_password" name="j_password">
<f:facet name="prepend">
<b:iconAwesome name="key" />
</f:facet>
</b:inputText> <b:commandButton look="primary btn-block" id="submit" value="登录" ajax="false" size="lg"/>
</h:form>
</b:container>
</h:body>
</html>
primefaces使用这个登录页面:
<h:form id="login" onsubmit="action='j_security_check';" prependId="false">
<h:panelGrid columns="2">
<p:outputLabel for="j_username" value="Username" />
<p:inputText id="j_username" />
<p:outputLabel for="j_password" value="Password" />
<p:password id="j_password" />
<p:commandButton id="submit" value="Login" ajax="false"/>
</h:panelGrid>
</h:form>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/faces/index.xhtml</welcome-file>
</welcome-file-list> <security-constraint>
<display-name>Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/faces/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Manager</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint> <login-config>
<auth-method>FORM</auth-method>
<realm-name>dbdomain</realm-name>
<form-login-config>
<form-login-page>/faces/views/login.xhtml</form-login-page>
<form-error-page>/faces/views/loginError.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>Manager</role-name>
</security-role> <!-- not secure page -->
<security-constraint>
<display-name>UnSecuredPages</display-name>
<web-resource-collection>
<!-- *.js no use. -->
<web-resource-name>login-required</web-resource-name>
<url-pattern>*.js</url-pattern>
</web-resource-collection>
<web-resource-collection>
<web-resource-name>ttf</web-resource-name>
<url-pattern>/faces/fonts/*</url-pattern>
</web-resource-collection>
<web-resource-collection>
<web-resource-name>login-required1</web-resource-name>
<url-pattern>/faces/javax.faces.resource/*</url-pattern>
</web-resource-collection>
</security-constraint> <context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param> <session-config>
<session-timeout>
0
</session-timeout>
</session-config> <context-param>
<param-name>net.bootsfaces.get_fontawesome_from_cdn</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>bootstrap</param-value>
</context-param>
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>auto</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
参考:
http://blog.sina.com.cn/s/blog_7253d65401018syh.html
http://www.cnblogs.com/davidwang456/p/3897684.html
Jboss7.1 加入realm auth认证 bootsfaces 美化的登录页面的更多相关文章
- Http basic Auth 认证方式帮助类
BasicAuthenticationUtil import java.io.IOException; import java.security.MessageDigest; import javax ...
- java 发送带Basic Auth认证的http post请求
构造http header private static final String URL = "url"; private static final String APP_KEY ...
- Bootstrap+Thinkphp3.2+Auth认证+jquery-validator后台
Auth权限认证 本例采用auth权限认证,用户和用户组采用多对多关系处理,自动添加rule规则,带有jquery-validator插件,自动控制菜单显示或隐藏. config.php中的配置 ...
- Django学习之九: auth 认证组件
目录 Django auth 认证组件 配置使用auth组件及其中间件 request.user 可以直接在template模版中使用 auth组件常用api 获取认证model类 认证检测装饰器@l ...
- Django auth认证
Django自带的用户认证 我们在开发一个网站的时候,无可避免的需要设计实现网站的用户系统.此时我们需要实现包括用户注册.用户登录.用户认证.注销.修改密码等功能,这还真是个麻烦的事情呢. Djang ...
- Django auth认证系统
Django自带的用户认证 我们在开发一个网站的时候,无可避免的需要设计实现网站的用户系统.此时我们需要实现包括用户注册.用户登录.用户认证.注销.修改密码等功能,这还真是个麻烦的事情呢. Djang ...
- Django认证系统auth认证
使用Django认证系统auth认证 auth认证系统可以处理范围非常广泛的任务,且具有一套细致的密码和权限实现.对于需要与默认配置不同需求的项目,Django支持扩展和自定义认证;会将用户信息写入到 ...
- django之auth认证系统
Django自带的用户认证 我们在开发一个网站的时候,无可避免的需要设计实现网站的用户系统.此时我们需要实现包括用户注册.用户登录.用户认证.注销.修改密码等功能,这还真是个麻烦的事情呢. Djang ...
- laravel中的Auth认证:
简介 Laravel 5.3 的 Auth 认证在 5.2 的基础上又有一些改变,本文说明如何在 Laravel 5.3 下做不同用户表的登录认证. Auth 认证原理简述 Laravel 的认证是使 ...
随机推荐
- 开源:ASP.NET MVC+EF6+Bootstrap开发框架
前言 我在博客园潜水两三年了,在这里看过很多大神的文章,也学到了很多东西.可以说我是汲取着博客园的营养成长的. 想当年,我也是拿10个G的精神粮食从一个博客园大神那里换来一套开发框架,正式走上开发之路 ...
- java的HashCode方法
总的来说,Java中的集合(Collection)有两类,一类是List,再有一类是Set. 前者集合内的元素是有序的,元素可以重复: 后者元素无序,但元素不可重复. 要想保证元素不重复,可两个元素是 ...
- nodepad++快捷键收集
Notepad++ 快捷键 大全Ctrl+C 复制Ctrl+X 剪切Ctrl+V 粘贴Ctrl+Z 撤消Ctrl+Y 恢复Ctrl+A 全选Ctrl+F 键查找对话框启动Ctrl+H 查找/替换对话框 ...
- C# has three timers
结论 *1.窗体timer和线程timer.计时器timer不同,因为后两者dispose之后,GC可以收集,而前者无法收集 *2.如果一个对象的成员函数正在被执行,那么这个对象肯定不会被收集 *3. ...
- Beta冲刺---Day2
站立式会议 站立式会议内容总结: 221: 昨日完成: 1.这几天的安排,接口测试. 今天要完成: 1.协作编写系负责人审核 遇到问题: 1.无 328: 昨天完成的事情: 1.无 今天要完成的事情: ...
- MVC的理解
一: MVC MVC是一种经典的设计模式,全名为Model-View-Controller,即模型-视图-控制器. 模型是用于封装数据的载体,例如,在Java中一般通过一个简单的POJO(Plain ...
- iOS开发小技巧--即时通讯项目:使用富文本在UILabel中显示图片和文字;使用富文本占位显示图片
Label借助富文本显示图片 1.即时通讯项目中语音消息UI的实现,样式如图: 借助富文本在UILabel中显示图片和文字 // 1.创建一个可变的富文本 NSMutableAttributedStr ...
- IOS并发编程GCD
iOS有三种多线程编程的技术 (一)NSThread (二)Cocoa NSOperation (三)GCD(全称:Grand Central Dispatch) 这三种编程方式从上到下,抽象度层次 ...
- poj3694 缩点边双连通分量
Network Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 8669 Accepted: 3175 Descripti ...
- 系统间通信(10)——RPC的基本概念
1.概述 经过了详细的信息格式.网络IO模型的讲解,并且通过JAVA RMI的讲解进行了预热.从这篇文章开始我们将进入这个系列博文的另一个重点知识体系的讲解:RPC.在后续的几篇文章中,我们首先讲解R ...