portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets WebPagePortlet.java
Date Sat, 30 Mar 2002 00:14:04 GMT
taylor      02/03/29 16:14:04

  Modified:    src/java/org/apache/jetspeed/portal/portlets
                        WebPagePortlet.java
  Log:
  - new username/password feature added to WebPagePortlet
  
  Revision  Changes    Path
  1.9       +26 -0     jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/WebPagePortlet.java
  
  Index: WebPagePortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/WebPagePortlet.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- WebPagePortlet.java	5 Feb 2002 05:27:26 -0000	1.8
  +++ WebPagePortlet.java	30 Mar 2002 00:14:04 -0000	1.9
  @@ -62,6 +62,7 @@
   import org.apache.jetspeed.portal.PortletConfig;
   import org.apache.jetspeed.portal.PortletException;
   import org.apache.jetspeed.util.HTMLRewriter;
  +import org.apache.jetspeed.util.Base64;
   
   //turbine
   import org.apache.turbine.util.Log;
  @@ -81,6 +82,7 @@
    *@author <a href="mailto:rammer@sycom.at">Ingo Rammer</a>
    *@author <a href="mailto:sgala@apache.org">Santiago Gala</a>
    *@author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  + *@author <a href="mailto:david@pssp.com">David G. Powers</a>
    */
   public class WebPagePortlet extends AbstractPortlet {
   
  @@ -88,6 +90,8 @@
       boolean initDone = false;
       boolean contentStale = true;
       boolean cacheContent = false;
  +    String  username = null;
  +    String  password = null;
       
       /**
        * Initialize this portlet by defining a HTML rewriter.
  @@ -123,6 +127,11 @@
                       config.getInitParameter("open_in_popup","no")
                           .equalsIgnoreCase("yes")
                           );
  +
  +            // fetch username and password for HTTP Basic Autentication
  +            username = config.getInitParameter("username");
  +            password = config.getInitParameter("password");
  +            
               contentStale = true;
               initDone = true;
           } catch (Exception e) {
  @@ -141,7 +150,24 @@
       private Reader getReader(String url) throws IOException 
       {
           URL            pageUrl = new URL(url);
  +
           URLConnection  pageConn = pageUrl.openConnection();
  +        try
  +        {
  +            // set HTTP Basic Authetication header if username and password are set
  +            if (username != null && password !=null)
  +            {
  +                pageConn.setRequestProperty("Authorization", "Basic " +
  +                                        Base64.encodeAsString(username + ":" + password));
  +            }
  +                
  +        }
  +        catch (Exception e)
  +        {
  +            Log.info("Exception occurred:" + e.toString());
  +            e.printStackTrace();
  +        }
  +        
           long           pageExpiration = pageConn.getExpiration();
           String         encoding = pageConn.getContentEncoding();
           String         tempString = null;
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>


Mime
View raw message