Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: joist/java/org/joist/security UnsecureServlet.java

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

CVS update: joist/java/org/joist/security UnsecureServlet.java

Author davidp
Full name David C. Pellegrini
Date 2000-11-13 17:13:58 PST
Message User: davidp
  Date: 00/11/13 17:13:58

  Modified: java/org/joist/util URL.java
               java/org/joist/security UnsecureServlet.java
  Log:
  Refactored URL, moving redirectToHomePage() functionality into UnsecureServlet
  and removing URL.schemeToMountPoint() and redirectForScheme().
  
  Revision Changes Path
  1.10 +1 -91 joist/java/org/joist​/util/URL.java
  
  Index: URL.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/util/URL.java,​v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- URL.java 2000/11/14 00:45:16 1.9
  +++ URL.java 2000/11/14 01:13:57 1.10
  @@ -62,7 +62,7 @@
    * Parses and builds URLs
    *
    * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
  - * @version $Revision: 1.9 $
  + * @version $Revision: 1.10 $
    *
    * Copyright (c) 1999 dataweb systems, inc.
    * Copyright (c) 1999, 2000 Collab.Net, Inc.
  @@ -119,95 +119,5 @@
       if (debug) log.debug("httpAndServer: " + newURL.toString());
       return newURL;
       }
  -
  -
  - /**
  - * Generates the leading part of the URL, up through the jserv mount point
  - *
  - * @param context the WebContext
  - * @param newScheme A variable of type String
  - * @return StringBuffer
  - * @exception HandlerException
  - */
  - static public StringBuffer
  - schemeToMountPoint (WebContext context, String newScheme)
  - throws HandlerException
  - {
  - StringBuffer newURL = new StringBuffer(newScheme);
  - HttpServletResponse response = context.getResponse();
  - HttpServletRequest request = context.getRequest();
  - String serverName = request.getServerName();
  - //FIX: int p = request.getServerPort(); do we care about port #?
  - //FIX: String port = (p == 80) ? "" : ":" + p;
  - String uri = request.getRequestURI();
  - String mountPoint = uri.substring(0, uri.lastIndexOf('/') + 1);
  - newURL.append("://")​.append(serverName).​append(mountPoint);
  - if (debug) log.debug("schemeToMountPoint: " + newURL.toString());
  - return newURL;
  - }
  -
  -
  - /**
  - * Redirect to use a different scheme
  - *
  - * @param context the WebContext
  - * @param newScheme the scheme to use
  - * @param servletName the servlet to which we are redirecting
  - * @exception HandlerException
  - * @exception RedirectURLException
  - */
  - static public void
  - redirectForScheme (WebContext context, String newScheme, String servletName)
  - throws HandlerException, RedirectURLException
  - {
  - if (debug) log.debug("redirectForScheme: to " + servletName);
  - try
  - {
  - HttpServletResponse response = context.getResponse();
  - StringBuffer newURL = schemeToMountPoint(context, newScheme);
  - newURL.append(servletName);
  - if (debug) log.debug("redirectForScheme: " + newURL.toString());
  - response.sendRedirec​t(response.encodeRed​irectUrl(newURL.toSt​ring()));
  - throw new RedirectURLException();
  - }
  - catch (IOException e)
  - {
  - if (debug) log.debug("redirectForScheme: " + e.getMessage());
  - throw new HandlerException(e.g​etMessage());
  - }
  - }
  -
  -
  - /**
  - * Redirect to the site home page. Does <i>not</i> make the provided
  - * context available in the next servlet.
  - *
  - * @param context the WebContext
  - * @param config A variable of type ServletConfig
  - * @exception HandlerException
  - * @exception RedirectURLException
  - */
  - static public void
  - redirectToHomePage (WebContext context)
  - throws HandlerException, RedirectURLException
  - {
  - try
  - {
  - HttpServletResponse response = context.getResponse();
  - StringBuffer newURL = httpAndServer(context);
  - newURL.append(JoistP​roperties.getPropert​y("HomePage"));
  - if (debug) log.debug("redirectToHomePage: " + newURL);
  - response.sendRedirect
  - (response.encodeRedi​rectUrl(newURL.toStr​ing()));
  - throw new RedirectURLException();
  - }
  - catch (IOException e)
  - {
  - if (debug) log.debug("redirectToHomePage: " + e.getMessage());
  - throw new HandlerException(e.g​etMessage());
  - }
  - }
  -
  -
   }
   
  
  
  
  1.74 +16 -18 joist/java/org/joist​/security/UnsecureSe​rvlet.java
  
  Index: UnsecureServlet.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/security/Unsec​ureServlet.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- UnsecureServlet.java 2000/11/14 00:45:16 1.73
  +++ UnsecureServlet.java 2000/11/14 01:13:58 1.74
  @@ -73,7 +73,7 @@
    * loading to WebMacro servlets.
    *
    * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
  - * @version $Revision: 1.73 $
  + * @version $Revision: 1.74 $
    *
    * Copyright (c) 1999 dataweb systems, inc.
    * Copyright (c) 1999, 2000 CollabNet, Inc.
  @@ -608,22 +608,6 @@
               if (newScheme.equals("https") && !inProductionEnvironment)
                   newScheme = "http";
   
  - // Get the port appropriate for the scheme.
  -//REM: String p;
  -//REM: if (newScheme.equals("http"))
  -//REM: {
  -//REM: p = myProperties.getProp​erty("http_port");
  -//REM: }
  -//REM: else if (newScheme.equals("https"))
  -//REM: {
  -//REM: p = myProperties.getProp​erty("https_port");
  -//REM: }
  -//REM: else
  -//REM: {
  -//REM: p = HTTP_PORT;
  -//REM: }
  - //REM: String p = myProperties.getProp​erty("http_port");
  - //REM: String port = p.equals(HTTP_PORT) ? "" : ':' + p;
           String port = "";
           String uri = request.getRequestURI();
           String queryString = "?redirect=SSL";
  @@ -655,7 +639,21 @@
       redirectToHomePage (WebContext context)
       throws HandlerException, RedirectURLException
       {
  - URL.redirectToHomePa​ge(context);
  + try
  + {
  + HttpServletResponse response = context.getResponse();
  + StringBuffer newURL = URL.httpAndServer(context);
  + newURL.append(JoistP​roperties.getPropert​y("HomePage"));
  + if (debug) log.debug("redirectToHomePage: " + newURL);
  + response.sendRedirect
  + (response.encodeRedi​rectUrl(newURL.toStr​ing()));
  + throw new RedirectURLException();
  + }
  + catch (IOException e)
  + {
  + if (debug) log.debug("redirectToHomePage: " + e.getMessage());
  + throw new HandlerException(e.g​etMessage());
  + }
       }

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: joist/java/org/joist/security UnsecureServlet.java davidp David C. Pellegrini 2000-11-13 17:13:58 PST
Messages per page: