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/14 00:57:54 UTC
cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/login LoginRedirectorServlet.java LogoutServlet.java LoginServlet.java LoginProxyServlet.java LoginErrorServlet.java
taylor 2004/05/13 15:57:54
Added: portal/src/java/org/apache/jetspeed/login
LoginRedirectorServlet.java LogoutServlet.java
LoginServlet.java LoginProxyServlet.java
LoginErrorServlet.java
Log:
Start of Login Portlet and Active Authentication
contributed by Ate Douma
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.1 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java
Index: LoginRedirectorServlet.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.login;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* LoginRedirectorServlet
*
* @author <a href="mailto:ate@douma.nu">Ate Douma </a>
* @version $id: $
*/
public class LoginRedirectorServlet extends HttpServlet
{
public final void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
HttpSession session = request.getSession(true);
String destination = (String) session
.getAttribute(LoginConstants.DESTINATION);
if (destination == null)
destination = request.getContextPath();
else
session.removeAttribute(LoginConstants.DESTINATION);
session.removeAttribute(LoginConstants.USERNAME);
session.removeAttribute(LoginConstants.PASSWORD);
session.removeAttribute(LoginConstants.RETRYCOUNT);
response.sendRedirect(response.encodeURL(destination));
}
public final void doPost(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
doGet(request, response);
}
}
1.1 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/login/LogoutServlet.java
Index: LogoutServlet.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.login;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* LogoutServlet
*
* @author <a href="mailto:ate@douma.nu">Ate Douma </a>
* @version $id: $
*/
public class LogoutServlet extends HttpServlet
{
public final void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
request.getSession(true).invalidate();
response.sendRedirect(response.encodeURL(request.getContextPath()));
}
}
1.1 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/login/LoginServlet.java
Index: LoginServlet.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.login;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* LoginServlet
*
* @author <a href="mailto:ate@douma.nu">Ate Douma </a>
* @version $id: $
*/
public class LoginServlet extends HttpServlet
{
public final void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
HttpSession session = request.getSession(true);
if (request.getUserPrincipal() != null)
{
String destination = (String) session
.getAttribute(LoginConstants.DESTINATION);
if (destination == null)
destination = request.getContextPath() + "/";
response.sendRedirect(response.encodeURL(destination));
}
PrintWriter out = response.getWriter();
out.print("<html>");
out.print("<body onLoad='document.forms[\"login\"].submit();'>");
out.print("<form id='login' method='POST' action='"
+ response.encodeURL("j_security_check") + "'>");
out.print("<input type='hidden' name='j_username' value='"
+ session.getAttribute(LoginConstants.USERNAME) + "'>");
out.print("<input type='hidden' name='j_password' value='"
+ session.getAttribute(LoginConstants.PASSWORD) + "'>");
out.print("</form>");
out.print("</body>");
out.print("</html>");
out.close();
}
public final void doPost(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
doGet(request, response);
}
}
1.1 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/login/LoginProxyServlet.java
Index: LoginProxyServlet.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.login;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* LoginProxyServlet
*
* @author <a href="mailto:ate@douma.nu">Ate Douma </a>
* @version $id: $
*/
public class LoginProxyServlet extends HttpServlet
{
public final void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
String parameter;
HttpSession session = request.getSession(true);
parameter = request.getParameter(LoginConstants.DESTINATION);
if (parameter != null)
session.setAttribute(LoginConstants.DESTINATION, parameter);
else
session.removeAttribute(LoginConstants.DESTINATION);
parameter = request.getParameter(LoginConstants.USERNAME);
if (parameter != null)
session.setAttribute(LoginConstants.USERNAME, parameter);
else
session.removeAttribute(LoginConstants.USERNAME);
parameter = request.getParameter(LoginConstants.PASSWORD);
if (parameter != null)
session.setAttribute(LoginConstants.PASSWORD, parameter);
else
session.removeAttribute(LoginConstants.PASSWORD);
response.sendRedirect(response.encodeURL(request.getContextPath()
+ "/login/redirector"));
}
public final void doPost(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
doGet(request, response);
}
}
1.1 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java
Index: LoginErrorServlet.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.login;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* LoginErrorServlet
*
* @author <a href="mailto:ate@douma.nu">Ate Douma </a>
* @version $id: $
*/
public class LoginErrorServlet extends HttpServlet
{
public final void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
HttpSession session = request.getSession();
String destination = (String) session
.getAttribute(LoginConstants.DESTINATION);
if (destination == null)
destination = request.getContextPath() + "/";
else
session.removeAttribute(LoginConstants.DESTINATION);
Integer retryCount = (Integer) session
.getAttribute(LoginConstants.RETRYCOUNT);
if (retryCount == null)
retryCount = new Integer(1);
else
retryCount = new Integer(retryCount.intValue() + 1);
session.setAttribute(LoginConstants.RETRYCOUNT, retryCount);
response.sendRedirect(response.encodeURL(destination));
}
public final void doPost(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
doGet(request, response);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org