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 的认证是使 ...
随机推荐
- C#微信公众号开发系列教程六(被动回复与上传下载多媒体文件)
微信公众号开发系列教程一(调试环境部署) 微信公众号开发系列教程一(调试环境部署续:vs远程调试) C#微信公众号开发系列教程二(新手接入指南) C#微信公众号开发系列教程三(消息体签名及加解密) C ...
- 打磨程序员的专属利器——命令行&界面
工欲善其事,必先利其器,程序员更是如此,如果没有一套与自己思维同步的工具,将非常难受并且编码效率会非常低. 但十个程序员就有对工具的十种不同理解,本人现在冒然将自己的“工具箱”拿出来晒晒.若对大家没帮 ...
- 必须要会的技能(一) 如何实现设计时Binding
今天我们来分享一个主题:DesignTime Binding设计时绑定. 这一项技术可以使用在所有包括WPF及其衍生出来的技术上,比如Sliverlight,当然也包括UWP 先来说明一下设计时Bin ...
- 清除webBrowser 缓存和Cookie的解决方案
通过测试webBrowser与IE缓存和Cookie都存放在Local Settings\Temporary Internet Files,我们可以直接调用IE API进行清除 解决方案1: publ ...
- 网页设计:Meta标签详解
很多人忽视了HTML标签META的强大功效,一个好的META标签设计可以大大提高你的个人网站被搜索到的可能性,有兴趣吗,谁我来重新认识一下META标签吧! META标签是HTML语言HEAD区的一个辅 ...
- jquery+bootstrap使用数字增减按钮
<div class="container"> <div class="page-header"><h1>Bootstrap ...
- python基础--基本数据类型考试_day3
1.执行 Python 脚本的两种方式 终端和交互模式 法1:python helloword.py 法2:ps: 执行前需给预chmod 755 helloword.py (linux系统中)./h ...
- “CEPH浅析”系列之八——小结
最初决定写这些文章的时候,本打算大致记录一下,几千字也就了事了.可是越写越觉得东西多,不说明白总有些不甘心,于是就越写越长,到这儿为止貌似已经有一万七千多字了.除了博士论文之外,应该是没有写过更长的东 ...
- 关于mysql数据库行级锁的使用(一)
项目上一个业务需要对某条数据库记录加锁,使用的是mysql数据库 因此做了一个关于mysql数据库行级锁的例子做测试 package com.robert.RedisTest; import java ...
- linux-查看系统是32位还是64位
可以用命令“getconf LONG_BIT”查看, 如果返回的结果是32则说明是32位,返回的结果是64则说明是64位. 此外还可以使用命令“uname -a”查看, 输出的结果中,如果有x86_6 ...