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/02 04:13:30 UTC
cvs commit: jakarta-jetspeed-2/applications/demo/src/java/org/apache/jetspeed/demo/servlet SSOBasicDemoServlet.java SSODemoServlet.java
taylor 2004/12/01 19:13:30
Modified: applications/demo/src/java/org/apache/jetspeed/demo/servlet
SSODemoServlet.java
Added: applications/demo/src/java/org/apache/jetspeed/demo/servlet
SSOBasicDemoServlet.java
Log:
test servlet for basic authentication
Revision Changes Path
1.3 +6 -2 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SSODemoServlet.java 1 Dec 2004 01:28:47 -0000 1.2
+++ SSODemoServlet.java 2 Dec 2004 03:13:30 -0000 1.3
@@ -51,6 +51,10 @@
{
authenticatedPrincipal = "guest";
}
+ else
+ {
+ authenticatedPrincipal = userPrincipal.toString();
+ }
if (principal == null)
{
error403(request, response, "SSO Principal is not valid. Please provide a valid SSO principal.");
@@ -75,7 +79,7 @@
// 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/>");
+ response.getWriter().println("Remote User = " + authenticatedPrincipal + "<br/>");
}
private void error403(HttpServletRequest request, HttpServletResponse response, String message)
1.1 jakarta-jetspeed-2/applications/demo/src/java/org/apache/jetspeed/demo/servlet/SSOBasicDemoServlet.java
Index: SSOBasicDemoServlet.java
===================================================================
/*
* Copyright 2000-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.
*/
package org.apache.jetspeed.demo.servlet;
import java.io.IOException;
import java.security.Principal;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* SSOBasicDemoServlet - this will only run in Tomcat 4 and 5
* where there is a tomcat user name tomcat with the password tomcat
* and with a role named tomcat.
*
* @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id: SSOBasicDemoServlet.java,v 1.1 2004/12/02 03:13:30 taylor Exp $
*/
public class SSOBasicDemoServlet extends HttpServlet
{
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 authenticatedPrincipal = "";
Principal userPrincipal = request.getUserPrincipal();
if (userPrincipal == null)
{
authenticatedPrincipal = "guest";
}
else
{
authenticatedPrincipal = userPrincipal.toString();
}
// create the session
request.getSession(true);
// authenticated
response.getWriter().println("<b>Welcome to the Basic Authentication SSO Gateway!</b><br/>");
response.getWriter().println("Remote Principal has been authenticated.<br/>");
response.getWriter().println("Remote User = " + authenticatedPrincipal + "<br/>");
}
public final void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
{
doGet(req, res);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org