Author: nbelaevski
Date: 2010-05-25 20:44:13 -0400 (Tue, 25 May 2010)
New Revision: 17244
Added:
root/examples/misc-demo/
root/examples/misc-demo/branches/
root/examples/misc-demo/tags/
root/examples/misc-demo/trunk/
root/examples/misc-demo/trunk/pom.xml
root/examples/misc-demo/trunk/src/
root/examples/misc-demo/trunk/src/main/java/
root/examples/misc-demo/trunk/src/main/java/org/
root/examples/misc-demo/trunk/src/main/java/org/richfaces/
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/TestIdentityFilter.java
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/UserBean.java
Removed:
root/examples/misc-demo/trunk/src/main/webapp/pages/error.html
root/examples/misc-demo/trunk/src/main/webapp/pages/index.jsp
root/examples/misc-demo/trunk/src/main/webapp/pages/login.html
Modified:
root/examples/misc-demo/trunk/src/main/webapp/WEB-INF/web.xml
root/examples/misc-demo/trunk/src/main/webapp/index.jsp
root/examples/misc-demo/trunk/src/main/webapp/pages/index.xhtml
root/examples/pom.xml
Log:
https://jira.jboss.org/browse/RF-7983
Copied: root/examples/misc-demo/trunk/pom.xml (from rev 16894,
branches/community/3.3.X/samples/functions-demo/pom.xml)
===================================================================
--- root/examples/misc-demo/trunk/pom.xml (rev 0)
+++ root/examples/misc-demo/trunk/pom.xml 2010-05-26 00:44:13 UTC (rev 17244)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of
+ individual contributors. This is free software; you can
+ redistribute it and/or modify it under the terms of the GNU
+ Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1 of the License, or (at your
+ option) any later version. This software is distributed in the
+ hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not,
+ write to the Free Software Foundation, Inc., 51 Franklin St,
+ Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
+
http://www.fsf.org.
+-->
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces.examples</groupId>
+ <artifactId>examples-aggregator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.richfaces.examples</groupId>
+ <artifactId>misc-demo</artifactId>
+ <packaging>war</packaging>
+ <name>RichFaces Examples: Miscellanous</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui-misc-ui</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Copied: root/examples/misc-demo/trunk/src (from rev 16894,
branches/community/3.3.X/samples/functions-demo/src)
Added:
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/TestIdentityFilter.java
===================================================================
---
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/TestIdentityFilter.java
(rev 0)
+++
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/TestIdentityFilter.java 2010-05-26
00:44:13 UTC (rev 17244)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import java.io.IOException;
+import java.security.Principal;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TestIdentityFilter implements Filter {
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException,
+ ServletException {
+
+ HttpServletRequestWrapper wrapper = new
HttpServletRequestWrapper((HttpServletRequest) request) {
+
+ private UserBean getUserBean() {
+ HttpSession session = getSession(false);
+ if (session != null) {
+ return (UserBean) session.getAttribute("userBean");
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean isUserInRole(String role) {
+ UserBean userBean = getUserBean();
+ if (userBean != null) {
+ return userBean.isUserInRole(role);
+ }
+
+ return false;
+ }
+
+ @Override
+ public Principal getUserPrincipal() {
+ UserBean userBean = getUserBean();
+ if (userBean != null) {
+ return userBean.getPrincipal();
+ }
+
+ return null;
+ }
+
+ @Override
+ public String getRemoteUser() {
+ UserBean userBean = getUserBean();
+ if (userBean != null) {
+ return userBean.getRolename();
+ }
+ return null;
+ }
+ };
+
+ chain.doFilter(wrapper, response);
+ }
+
+}
Added: root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/UserBean.java
===================================================================
--- root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/UserBean.java
(rev 0)
+++
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/UserBean.java 2010-05-26
00:44:13 UTC (rev 17244)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import java.security.Principal;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class UserBean {
+
+ private String rolename;
+
+ public String getRolename() {
+ return rolename;
+ }
+
+ public void setRolename(String username) {
+ this.rolename = username;
+ }
+
+ public Principal getPrincipal() {
+ if (rolename != null) {
+ return new PrincipalImpl(rolename);
+ }
+
+ return null;
+ }
+
+ public boolean isUserInRole(String role) {
+ Principal principal = getPrincipal();
+ if (principal != null) {
+ //username & principal's name & role name are considered the
same
+ return principal.getName().equals(role);
+ }
+
+ return false;
+ }
+}
+
+class PrincipalImpl implements Principal {
+
+ private String name;
+
+ public PrincipalImpl(String name) {
+ super();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
Modified: root/examples/misc-demo/trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
---
branches/community/3.3.X/samples/functions-demo/src/main/webapp/WEB-INF/web.xml 2010-05-05
09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/WEB-INF/web.xml 2010-05-26 00:44:13 UTC
(rev 17244)
@@ -1,83 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
-<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- <display-name>Archetype Created Web Application</display-name>
- <context-param>
- <param-name>javax.faces.CONFIG_FILES</param-name>
- <param-value>/WEB-INF/faces-config.xml</param-value>
- </context-param>
- <context-param>
- <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
- <param-value>server</param-value>
- </context-param>
- <!-- Use Documents Saved as *.xhtml -->
- <context-param>
- <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
- <param-value>.jsp</param-value>
- </context-param>
+<web-app id="WebApp_ID" version="2.5"
+
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>misc-demo</display-name>
- <!-- Facelets pages will use the .xhtml extension -->
- <context-param>
- <param-name>facelets.VIEW_MAPPINGS</param-name>
- <param-value>*xhtml</param-value>
- </context-param>
-
- <context-param>
- <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
- <param-value>com.sun.facelets.FaceletViewHandler</param-value>
- </context-param>
-
- <!--
- -->
<filter>
- <display-name>Ajax4jsf Filter</display-name>
- <filter-name>ajax4jsf</filter-name>
- <filter-class>org.ajax4jsf.Filter</filter-class>
+ <filter-name>Test Identity Filter</filter-name>
+ <filter-class>org.richfaces.demo.TestIdentityFilter</filter-class>
</filter>
+
<filter-mapping>
- <filter-name>ajax4jsf</filter-name>
+ <filter-name>Test Identity Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
- <dispatcher>REQUEST</dispatcher>
- <dispatcher>FORWARD</dispatcher>
- <dispatcher>INCLUDE</dispatcher>
- <dispatcher>ERROR</dispatcher>
</filter-mapping>
- <!-- Faces Servlet -->
+
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
</servlet>
- <!--
- Use prefix mapping for Facelets pages, e.g.
-
http://localhost:8080/webapp/faces/mypage.xhtml
- -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
- <url-pattern>/faces/*</url-pattern>
+ <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
-
- <servlet-mapping>
- <servlet-name>Faces Servlet</servlet-name>
- <url-pattern>/faces-auth/*</url-pattern>
- </servlet-mapping>
-
- <login-config>
- <auth-method>FORM</auth-method>
- <form-login-config>
- <form-login-page>/pages/login.html</form-login-page>
- <form-error-page>/pages/error.html</form-error-page>
- </form-login-config>
- </login-config>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>faces-auth</web-resource-name>
- <url-pattern>/faces-auth/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>user</role-name>
- <role-name>admin</role-name>
- </auth-constraint>
- </security-constraint>
</web-app>
Modified: root/examples/misc-demo/trunk/src/main/webapp/index.jsp
===================================================================
--- branches/community/3.3.X/samples/functions-demo/src/main/webapp/index.jsp 2010-05-05
09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/index.jsp 2010-05-26 00:44:13 UTC (rev
17244)
@@ -5,10 +5,7 @@
<head></head>
<body>
- <a href="faces/pages/index.jsp">JSP</a><br/>
- <a href="faces-auth/pages/index.jsp">JSP
authenticated</a><br/>
- <a href="faces/pages/index.xhtml">Facelets</a><br />
- <a href="faces-auth/pages/index.xhtml">Facelets
authenticated</a>
+ <a href="pages/index.jsf">Facelets</a><br />
</body>
</html>
\ No newline at end of file
Deleted: root/examples/misc-demo/trunk/src/main/webapp/pages/error.html
===================================================================
---
branches/community/3.3.X/samples/functions-demo/src/main/webapp/pages/error.html 2010-05-05
09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/pages/error.html 2010-05-26 00:44:13 UTC
(rev 17244)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html
xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
/>
-<title>Login failed</title>
-</head>
-<body>
-Login failed
-</body>
-</html>
\ No newline at end of file
Deleted: root/examples/misc-demo/trunk/src/main/webapp/pages/index.jsp
===================================================================
---
branches/community/3.3.X/samples/functions-demo/src/main/webapp/pages/index.jsp 2010-05-05
09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/pages/index.jsp 2010-05-26 00:44:13 UTC
(rev 17244)
@@ -1,36 +0,0 @@
-<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
-<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f" %>
-<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/functions"
prefix="fn" %>
-<html>
- <head>
- <title></title>
- </head>
- <body>
- <f:view>
- <f:subview id="view">
- <h:form id="myForm">
- <h:inputText id="input" value="abc" />
- </h:form>
- </f:subview>
-
- <h:outputText value="#{fn:clientId('input')}" />
- <br />
- <h:outputText value="#{fn:element('input')}" />
- <br />
- <h:outputText value="#{fn:component('input')}" />
- <br />
- <h:outputText value="#{fn:findComponent('input').value}" />
- <br />
-
- Roles:
- <h:outputText rendered="#{fn:isUserInRole('admin, user')}"
value="admin/user" />
- <br />
- <h:outputText rendered="#{fn:isUserInRole('admin')}"
value="admin" />
- <br />
- <h:outputText rendered="#{fn:isUserInRole('user')}"
value="user" />
- <br />
-
-
- </f:view>
- </body>
-</html>
Modified: root/examples/misc-demo/trunk/src/main/webapp/pages/index.xhtml
===================================================================
---
branches/community/3.3.X/samples/functions-demo/src/main/webapp/pages/index.xhtml 2010-05-05
09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/pages/index.xhtml 2010-05-26 00:44:13
UTC (rev 17244)
@@ -1,33 +1,40 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:fn="http://labs.jboss.com/jbossrichfaces/ui/functions"
- >
- <f:view>
- <f:subview id="view">
- <h:form id="myForm">
- <h:inputText id="input" value="abc"/>
- </h:form>
- </f:subview>
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:fn="http://richfaces.org/misc">
+<f:view>
+ <h:form>
+ <h:outputLabel value="Role name:" for="roleName" />
+ <h:inputText value="#{userBean.rolename}" id="roleName" />
+ <br />
+ <h:commandLink value="Apply role name" />
+ </h:form>
- <h:outputText value="#{fn:clientId('input')}" />
- <br />
- <h:outputText value="#{fn:element('input')}" />
- <br />
- <h:outputText value="#{fn:component('input')}" />
- <br />
- <h:outputText value="#{fn:findComponent('input').value}" />
- <br />
+ <f:subview id="view">
+ <h:form id="myForm">
+ <h:inputText id="input" value="abc" />
+ </h:form>
+ </f:subview>
+
+ <h:outputText value="#{fn:clientId('input')}" />
+ <br />
+ <h:outputText value="#{fn:element('input')}" />
+ <br />
+ <h:outputText value="#{fn:component('input')}" />
+ <br />
+ <h:outputText value="#{fn:findComponent('input').value}" />
+ <br />
- Roles:
- <h:outputText rendered="#{fn:isUserInRole('admin, user')}"
value="admin/user" />
- <br />
- <h:outputText rendered="#{fn:isUserInRole('admin')}"
value="admin" />
- <br />
- <h:outputText rendered="#{fn:isUserInRole('user')}"
value="user" />
- <br />
-
- </f:view>
-</html>
\ No newline at end of file
+ Roles:
+ <h:outputText rendered="#{fn:isUserInRole('admin, user')}"
+ value="admin or user" />
+ <br />
+ <h:outputText rendered="#{fn:isUserInRole('admin')}"
value="admin" />
+ <br />
+ <h:outputText rendered="#{fn:isUserInRole('user')}"
value="user" />
+ <br />
+
+</f:view>
+</html>
Deleted: root/examples/misc-demo/trunk/src/main/webapp/pages/login.html
===================================================================
---
branches/community/3.3.X/samples/functions-demo/src/main/webapp/pages/login.html 2010-05-05
09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/pages/login.html 2010-05-26 00:44:13 UTC
(rev 17244)
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html
xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
/>
-<title>Insert title here</title>
-</head>
-<body>
- <form action="j_security_check" method="post">
- <input type="text" name="j_username" />
- <br />
- <input type="password" name="j_password" />
- <br />
- <input type="submit" value="Login" />
- </form>
-</body>
-</html>
\ No newline at end of file
Modified: root/examples/pom.xml
===================================================================
--- root/examples/pom.xml 2010-05-25 23:55:03 UTC (rev 17243)
+++ root/examples/pom.xml 2010-05-26 00:44:13 UTC (rev 17244)
@@ -37,6 +37,7 @@
<modules>
<module>core-demo/trunk</module>
+ <module>misc-demo/trunk</module>
<module>repeater-demo/trunk</module>
<!--<module>richfaces-showcase/trunk</module>-->
<!--<module>dist/trunk</module>-->
@@ -60,6 +61,14 @@
<type>pom</type>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui-misc-bom</artifactId>
+ <version>${project.version}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+
<!-- simple logger binding: only messages of level INFO and higher are
printed-->
<dependency>
<groupId>org.slf4j</groupId>