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/12/01 02:28:47 UTC
cvs commit: jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/velocity velocity-macros.vm
taylor 2004/11/30 17:28:47
Modified: applications/demo project.properties
applications/demo/src/webapp/WEB-INF/view iframe-help.html
sso-edit-prefs.vm
applications/demo/src/java/org/apache/jetspeed/demo/servlet
SSODemoServlet.java
applications/demo/src/webapp/WEB-INF portlet.xml
applications/demo/src/webapp/WEB-INF/velocity
velocity-macros.vm
Log:
implemented SSO IFrame Portlet with SSO via request params
Revision Changes Path
1.7 +2 -2 jakarta-jetspeed-2/applications/demo/project.properties
Index: project.properties
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/applications/demo/project.properties,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- project.properties 24 Jul 2004 11:13:36 -0000 1.6
+++ project.properties 1 Dec 2004 01:28:47 -0000 1.7
@@ -18,5 +18,5 @@
maven.multiproject.type=war
maven.license.licenseFile=${basedir}/../../LICENSE.TXT
-org.apache.jetspeed.portlet.app.name=HW_App
+org.apache.jetspeed.portlet.app.name=demo
1.2 +34 -1 jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/view/iframe-help.html
Index: iframe-help.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/view/iframe-help.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- iframe-help.html 12 Nov 2004 06:32:31 -0000 1.1
+++ iframe-help.html 1 Dec 2004 01:28:47 -0000 1.2
@@ -1 +1,34 @@
-<h1>Help Page</h1>
+<h1>SSO IFrame Demo Help</h1>
+<div class="portlet-msg-info">
+To use the SSO IFrame Demo with URL-based authentication, you will need to enter the following SSO<br/>
+URL preferences for the URL parameter names (principal, credential) to work with the <b>/demo/sso-demo</b> site:<br/>
+</div>
+<br/>
+<table border="1" cellspacing="1" cellpadding="3">
+<tr>
+<th class="portlet-section-header">sso.url.Principal</th>
+<th class="portlet-section-header">sso.url.Crendential</th>
+</tr>
+<tr>
+<td class='portlet-section-body'>sso-principal</td>
+<td class='portlet-section-body'>sso-credential</td>
+</tr>
+</table>
+<br/><br/>
+<div class="portlet-msg-info">
+To use the SSO IFrame Demo with URL-based authentication, you will need to enter the following SSO<br/>
+Principal and Credential for the <b>/demo/sso-demo</b> site as the demo will take the authenticated principal <br/>
+currently logged in as the SSO Principal, and *always* require the SSO Credential listed below<br/>
+If a user is not authenticated, you must supply the SSO Principal name <b>'guest'</b>.<br/>
+</div>
+<br/>
+<table border="1" cellspacing="1" cellpadding="3">
+<tr>
+<th class="portlet-section-header">SSO Principal</th>
+<th class="portlet-section-header">SSO Credential</th>
+</tr>
+<tr>
+<td class='portlet-section-body'>(current authenticated username)</td>
+<td class='portlet-section-body'>secret-password</td>
+</tr>
+</table>
1.2 +2 -2 jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/view/sso-edit-prefs.vm
Index: sso-edit-prefs.vm
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/view/sso-edit-prefs.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sso-edit-prefs.vm 29 Nov 2004 03:27:28 -0000 1.1
+++ sso-edit-prefs.vm 1 Dec 2004 01:28:47 -0000 1.2
@@ -7,8 +7,8 @@
#prefField($pref.Key $pref.Value "40")
#end
<hr/>
-#form4ColumnCell("SSO Username" $ssoUserName 30 "ssoUserName")
-#form4ColumnCell("SSO Credential" $ssoCredential 30 "ssoCredential")
+#form4ColumnCell("SSO Principal" $ssoPrincipal 30 "ssoPrincipal")
+#form4PasswordCell("SSO Credential" $ssoCredential 30 "ssoCredential")
</table>
<input type="submit" name="Save" value="Save" />
</form>
1.2 +52 -6 jakarta-jetspeed-2/applications/demo/src/java/org/apache/jetspeed/demo/servlet/SSODemoServlet.java
Index: SSODemoServlet.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/applications/demo/src/java/org/apache/jetspeed/demo/servlet/SSODemoServlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SSODemoServlet.java 26 Nov 2004 18:49:56 -0000 1.1
+++ SSODemoServlet.java 1 Dec 2004 01:28:47 -0000 1.2
@@ -16,6 +16,7 @@
package org.apache.jetspeed.demo.servlet;
import java.io.IOException;
+import java.security.Principal;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -34,14 +35,59 @@
*/
public class SSODemoServlet extends HttpServlet
{
- public final void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ public final static String DEMO_SSO_PRINCIPAL_PARAM = "sso-principal";
+ public final static String DEMO_SSO_CREDENTIAL_PARAM = "sso-credential";
+ public final static String DEMO_SSO_CREDENTIAL = "secret-password";
+
+ public final void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException
{
- String user = request.getParameter("ssouser");
- String password = request.getParameter("ssopw");
- response.getWriter().println("User = " + user);
- response.getWriter().println(" PW = " + password);
+ String principal = request.getParameter(DEMO_SSO_PRINCIPAL_PARAM);
+ String credential = request.getParameter(DEMO_SSO_CREDENTIAL_PARAM);
+ String authenticatedPrincipal = "";
+
+ Principal userPrincipal = request.getUserPrincipal();
+ if (userPrincipal == null)
+ {
+ authenticatedPrincipal = "guest";
+ }
+ if (principal == null)
+ {
+ error403(request, response, "SSO Principal is not valid. Please provide a valid SSO principal.");
+ return;
+ }
+ if (credential == null)
+ {
+ error403(request, response, "SSO Credential is not valid. Please provide a valid SSO credential.");
+ return;
+ }
+ if (!principal.equals(authenticatedPrincipal))
+ {
+ error403(request, response, "SSO Principal not found on SSO Server. Please provide a valid SSO principal.");
+ return;
+ }
+ if (!credential.equals(DEMO_SSO_CREDENTIAL))
+ {
+ error403(request, response, "SSO Credential does not match. Please provide a valid SSO credential.");
+ return;
+ }
+
+ // authenticated
+ response.getWriter().println("<b>Welcome to the SSO Gateway!</b><br/>");
+ response.getWriter().println("Remote Principal has been authenticated.<br/>");
+ response.getWriter().println("Remote User = " + principal + "<br/>");
}
+ private void error403(HttpServletRequest request, HttpServletResponse response, String message)
+ throws IOException, ServletException
+ {
+ response.getWriter().println("<b>HTTP Status 403: Access to SSO Demo Site not permitted.<br/>");
+ response.getWriter().println(message + "<br/>");
+ response.getWriter().println("To configure the SSO Principal, switch to Edit Mode.<br/>");
+ return;
+
+ }
+
public final void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
{
doGet(req, res);
1.27 +4 -4 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.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- portlet.xml 29 Nov 2004 03:28:23 -0000 1.26
+++ portlet.xml 1 Dec 2004 01:28:47 -0000 1.27
@@ -473,12 +473,12 @@
<value>url</value>
</preference>
<preference>
- <name>sso.url.param.username</name>
- <value>ssouser</value>
+ <name>sso.url.Principal</name>
+ <value>sso-principal</value>
</preference>
<preference>
- <name>sso.url.param.password</name>
- <value>ssopw</value>
+ <name>sso.url.Credential</name>
+ <value>sso-credential</value>
</preference>
</portlet-preferences>
<supported-locale>en</supported-locale>
1.3 +12 -1 jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/velocity/velocity-macros.vm
Index: velocity-macros.vm
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/applications/demo/src/webapp/WEB-INF/velocity/velocity-macros.vm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- velocity-macros.vm 27 Nov 2004 01:17:31 -0000 1.2
+++ velocity-macros.vm 1 Dec 2004 01:28:47 -0000 1.3
@@ -94,9 +94,20 @@
#macro (form4ColumnCell $label $value $size $id)
<tr colspan="4" align="right">
<td width="5%" class="portlet-form-label" align="left"> </td>
- <td nowrap class="portlet-form-field-label" align="right">$!label: </td>
+ <td nowrap class="portlet-section-alternate" align="left">$!label: </td>
<td class="portlet-form-input-field" align="left">
<input id="$!id" type="text" name="$!id" size="$!size" value="$!value">
+ </td>
+ <td width="5%" class="portlet-form-label" align="left"> </td>
+ </tr>
+#end
+
+#macro (form4PasswordCell $label $value $size $id)
+ <tr colspan="4" align="right">
+ <td width="5%" class="portlet-form-label" align="left"> </td>
+ <td nowrap class="portlet-section-alternate" align="left">$!label: </td>
+ <td class="portlet-form-input-field" align="left">
+ <input id="$!id" type="password" name="$!id" size="$!size" value="$!value">
</td>
<td width="5%" class="portlet-form-label" align="left"> </td>
</tr>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org