You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2003/05/27 19:02:37 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm RealmBase.java

remm        2003/05/27 10:02:36

  Modified:    catalina/src/share/org/apache/catalina/realm RealmBase.java
  Log:
  - Refactor without using SSL URLs, similar to what is done for sendRedirect.
  
  Revision  Changes    Path
  1.13      +15 -22    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/RealmBase.java
  
  Index: RealmBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/RealmBase.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RealmBase.java	23 Apr 2003 16:14:12 -0000	1.12
  +++ RealmBase.java	27 May 2003 17:02:36 -0000	1.13
  @@ -72,8 +72,6 @@
   import java.security.NoSuchAlgorithmException;
   import java.security.cert.X509Certificate;
   import java.io.IOException;
  -import java.net.URL;
  -import java.net.MalformedURLException;
   import java.util.Set;
   
   import javax.servlet.http.HttpServletRequest;
  @@ -669,9 +667,15 @@
           }
   
           // Redirect to the corresponding SSL port
  +        StringBuffer file = new StringBuffer();
           String protocol = "https";
           String host = hrequest.getServerName();
  -        StringBuffer file = new StringBuffer(hrequest.getRequestURI());
  +        // Protocol
  +        file.append(protocol).append("://");
  +        // Host with port
  +        file.append(host).append(":").append(redirectPort);
  +        // URI
  +        file.append(hrequest.getRequestURI());
           String requestedSessionId = hrequest.getRequestedSessionId();
           if ((requestedSessionId != null) &&
               hrequest.isRequestedSessionIdFromURL()) {
  @@ -683,21 +687,10 @@
               file.append('?');
               file.append(queryString);
           }
  -        URL url = null;
  -        try {
  -            url = new URL(protocol, host, redirectPort, file.toString());
  -            if (log.isDebugEnabled())
  -                log.debug("  Redirecting to " + url.toString());
  -            hresponse.sendRedirect(url.toString());
  -            return (false);
  -        } catch (MalformedURLException e) {
  -            if (log.isDebugEnabled())
  -                log.debug("  Cannot create new URL", e);
  -            hresponse.sendError
  -                (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  -                 hrequest.getRequestURI());
  -            return (false);
  -        }
  +        if (log.isDebugEnabled())
  +            log.debug("  Redirecting to " + file.toString());
  +        hresponse.sendRedirect(file.toString());
  +        return (false);
   
       }
       
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm RealmBase.java

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 28 May 2003, Remy Maucherat wrote:

> Date: Wed, 28 May 2003 00:13:31 +0200
> From: Remy Maucherat <re...@apache.org>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: Tomcat Developers List <to...@jakarta.apache.org>
> Subject: Re: cvs commit:
>     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm
>     RealmBase.java
>
> Bill Barker wrote:
> >>remm        2003/05/27 10:02:36
> >>
> >>  Modified:    catalina/src/share/org/apache/catalina/realm RealmBase.java
> >>  Log:
> >>  - Refactor without using SSL URLs, similar to what is done for
> > I really don't like the redirect to "https:host:443/...".  The easiest fix
> > would have been to simply change the import from "java.net.URL" to
> > "org.apache.catalina.util.URL" (or "org.apache.tomcat.util.net.URL", they
> > are much the same).
>
> sendRedirect does the same (and I think it used to use java.net.URL,
> then org.apache.catalina.util.URL). Isn't there a reason for doing
> things like that ?
> It's a bit confusing ...
>

Historical background (although it's fading somewhat :-) ... the
Authenticator implementation used to use java.net.URL when a transport
guarantee said we needed to switch to SSL.  Unfortunately, this meant that
you couldn't redirect to an SSL-based URl unless you had JSSE installed
(which made the corresponding URLStreamHandler available by default).  We
created o.a.c.u.URL to solve that problem, and it probably can be used for
the same purpose anywhere else in Catalina that java.net.URL is used.

Of course, if we were willing to depend on JDK 1.4 we could use
java.net.URI for this kind of thing ...

> Remy

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm RealmBase.java

Posted by Remy Maucherat <re...@apache.org>.
Bill Barker wrote:
>>remm        2003/05/27 10:02:36
>>
>>  Modified:    catalina/src/share/org/apache/catalina/realm RealmBase.java
>>  Log:
>>  - Refactor without using SSL URLs, similar to what is done for
> I really don't like the redirect to "https:host:443/...".  The easiest fix
> would have been to simply change the import from "java.net.URL" to
> "org.apache.catalina.util.URL" (or "org.apache.tomcat.util.net.URL", they
> are much the same).

sendRedirect does the same (and I think it used to use java.net.URL, 
then org.apache.catalina.util.URL). Isn't there a reason for doing 
things like that ?
It's a bit confusing ...

Remy


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm RealmBase.java

Posted by Bill Barker <wb...@wilshire.com>.
----- Original Message -----
From: <re...@apache.org>
To: <ja...@apache.org>
Sent: Tuesday, May 27, 2003 10:02 AM
Subject: cvs commit:
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm
RealmBase.java


> remm        2003/05/27 10:02:36
>
>   Modified:    catalina/src/share/org/apache/catalina/realm RealmBase.java
>   Log:
>   - Refactor without using SSL URLs, similar to what is done for
sendRedirect.
>
>   Revision  Changes    Path
>   1.13      +15 -22
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/RealmBa
se.java
>
>   Index: RealmBase.java
>   ===================================================================
>   RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/rea
lm/RealmBase.java,v
>   retrieving revision 1.12
>   retrieving revision 1.13
>   diff -u -r1.12 -r1.13
>   --- RealmBase.java 23 Apr 2003 16:14:12 -0000 1.12
>   +++ RealmBase.java 27 May 2003 17:02:36 -0000 1.13
>   @@ -72,8 +72,6 @@
>    import java.security.NoSuchAlgorithmException;
>    import java.security.cert.X509Certificate;
>    import java.io.IOException;
>   -import java.net.URL;
>   -import java.net.MalformedURLException;
>    import java.util.Set;
>
>    import javax.servlet.http.HttpServletRequest;
>   @@ -669,9 +667,15 @@
>            }
>
>            // Redirect to the corresponding SSL port
>   +        StringBuffer file = new StringBuffer();
>            String protocol = "https";
>            String host = hrequest.getServerName();
>   -        StringBuffer file = new StringBuffer(hrequest.getRequestURI());
>   +        // Protocol
>   +        file.append(protocol).append("://");
>   +        // Host with port
>   +        file.append(host).append(":").append(redirectPort);
>   +        // URI
>   +        file.append(hrequest.getRequestURI());

I really don't like the redirect to "https:host:443/...".  The easiest fix
would have been to simply change the import from "java.net.URL" to
"org.apache.catalina.util.URL" (or "org.apache.tomcat.util.net.URL", they
are much the same).



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org