You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2004/05/15 03:57:09 UTC
cvs commit: jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/demo/security roles.jsp help.html
taylor 2004/05/14 18:57:09
Modified: applications/demo/src/webapp/WEB-INF web.xml portlet.xml
applications/security/src/webapp/WEB-INF web.xml
Added: applications/demo/src/webapp/WEB-INF/demo/security roles.jsp
help.html
Log:
patch from Ate Douma (hopefully his last now that he's voted in)
new portlet for testing portletRequest.isUserInRole
see portlet help mode for usage
PR:
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.7 +16 -3 jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/web.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- web.xml 18 Mar 2004 19:35:09 -0000 1.6
+++ web.xml 15 May 2004 01:57:09 -0000 1.7
@@ -14,10 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<!--
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2.3.dtd">
--->
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>HelloWorld-DN</display-name>
<description>Hello World Description</description>
@@ -38,4 +36,19 @@
</url-pattern>
</servlet-mapping>
+ <security-role>
+ <description>The admin role</description>
+ <role-name>admin</role-name>
+ </security-role>
+
+ <security-role>
+ <description>The manager role</description>
+ <role-name>manager</role-name>
+ </security-role>
+
+ <security-role>
+ <description>The user role</description>
+ <role-name>user</role-name>
+ </security-role>
+
</web-app>
1.12 +40 -1 jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/portlet.xml
Index: portlet.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/portlet.xml,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- portlet.xml 7 May 2004 13:40:57 -0000 1.11
+++ portlet.xml 15 May 2004 01:57:09 -0000 1.12
@@ -198,7 +198,46 @@
</portlet-info>
</portlet>
-
+ <portlet id="RoleSecurityTest">
+ <init-param>
+ <name>ViewPage</name>
+ <value>/WEB-INF/demo/security/roles.jsp</value>
+ </init-param>
+ <init-param>
+ <name>EditPage</name>
+ <value>/WEB-INF/demo/security/roles.jsp</value>
+ </init-param>
+ <init-param>
+ <name>HelpPage</name>
+ <value>/WEB-INF/demo/security/help.html</value>
+ </init-param>
+ <portlet-name>RoleSecurityTest</portlet-name>
+ <display-name>Role Security Test</display-name>
+ <portlet-class>org.apache.jetspeed.portlet.ServletPortlet</portlet-class>
+ <expiration-cache>-1</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ <portlet-mode>HELP</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Role Security Test</title>
+ <short-title>Role Security Test</short-title>
+ </portlet-info>
+ <security-role-ref>
+ <role-name>Administrator</role-name>
+ <role-link>admin</role-link>
+ </security-role-ref>
+ <security-role-ref>
+ <role-name>Manager</role-name>
+ <role-link>manager</role-link>
+ </security-role-ref>
+ <security-role-ref>
+ <role-name>User</role-name>
+ <role-link>user</role-link>
+ </security-role-ref>
+ </portlet>
+
<user-attribute>
<description>User Given Name</description>
<name>user.name.given</name>
1.2 +1 -3 jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/web.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- web.xml 1 May 2004 17:01:03 -0000 1.1
+++ web.xml 15 May 2004 01:57:09 -0000 1.2
@@ -14,10 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<!--
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2.3.dtd">
--->
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Security Portlets</display-name>
<description>Security Portlets</description>
1.1 jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/demo/security/roles.jsp
Index: roles.jsp
===================================================================
<%--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ taglib uri='/WEB-INF/portlet.tld' prefix='portlet'%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<portlet:defineObjects/>
<h3>User roles</h3>
<c:choose>
<c:when test="${empty renderRequest.userPrincipal}">
Login to see the roles you've been assigned
</c:when>
<c:otherwise>
User: <c:out value='${renderRequest.userPrincipal.name}'/><br>
<br>
isUserInRole:<br>
<table border="1">
<tr>
<th>Role Ref Name</th>
<th>Role Name</th>
<th>PortletRequest</th>
<th>ServletRequest</th>
</tr>
<tr>
<td>Administrator</td>
<td>admin</td>
<td><%= renderRequest.isUserInRole("Administrator") %></td>
<td><%= request.isUserInRole("Administrator") %></td>
</tr>
<tr>
<td>Manager</td>
<td>manager</td>
<td><%= renderRequest.isUserInRole("Manager") %></td>
<td><%= request.isUserInRole("Manager") %></td>
</tr>
<tr>
<td>User</td>
<td>user</td>
<td><%= renderRequest.isUserInRole("User") %></td>
<td><%= request.isUserInRole("User") %></td>
</tr>
</table>
</c:otherwise>
</c:choose>
<br>
For help on role configuration select the help icon.
1.1 jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/demo/security/help.html
Index: help.html
===================================================================
<h3>Example user role configuration</h3>
<p>
To be able to test the Role Security Test Portlet one or more users should be
assigned the role of <code>admin</code>, <code>manager</code> and/or
<code>user</code>.
</p>
<p>
At this moment, only the default Tomcat MemoryRealm has been tested. For this
realm, users and their roles are defined in tomcat/conf/tomcat-users.xml.
</p>
<p>
An example tomcat-users.xml for testing this portlet might look like:
<pre>
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="user"/>
<role rolename="manager"/>
<role rolename="admin"/>
<role rolename="tomcat"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="user" password="user" roles="user"/>
<user username="manager" password="manager" roles="manager,user"/>
<user username="admin" password="admin" roles="admin,manager,user"/>
</tomcat-users>
</pre>
</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org