Author: taylor
Date: Fri May 1 00:25:02 2009
New Revision: 770498
URL: http://svn.apache.org/viewvc?rev=770498&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-621
https://issues.apache.org/jira/browse/JS2-671
SSO IFrame and Web Content portlets were broken
SSO Admin portlets were broken as well
Had to bring back the choosers since they are used by the SSO portlets. Im not
going to rewrite these in Wicket at this time
With this commits, all SSO (iframe, web content, sso browser, sso details)
portlets are now functional. However I am seeing problems when adding the same
remote user for two different users on the same site
This seems to blow up and cause some problems Im currently looking into.
Modified:
portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java
Modified:
portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java
URL:
http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java?rev=770498&r1=770497&r2=770498&view=diff
==============================================================================
---
portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java
(original)
+++
portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java
Fri May 1 00:25:02 2009
@@ -69,9 +69,9 @@
import org.apache.portals.bridges.velocity.GenericVelocityPortlet;
import org.apache.portals.messaging.PortletMessaging;
-
/**
- * WebContentPortlet
+ * WebContentPortlet * WebContentPortlet Allows navigation inside the portlet
+ * and caches the latest URL
*
* TODO: Preferences, cache stream instead of URL *
*
@@ -81,13 +81,7 @@
public class WebContentPortlet extends GenericVelocityPortlet
{
-
- /**
- * WebContentPortlet Allows navigation inside the portlet and caches the
- * latest URL
- */
-
- /**
+ /**
* Configuration constants.
*/
public static final String VIEW_SOURCE_PARAM = "viewSource";
@@ -99,22 +93,15 @@
public static final String BROWSER_ACTION_REFRESH_PAGE = "refreshPage";
public static final String BROWSER_ACTION_NEXT_PAGE = "nextPage";
- /**
- * Action Parameter
- */
-
// WebContent session data
-
public static final String HISTORY = "webcontent.history";
public static final String HTTP_STATE = "webcontent.http.state";
- // Class Data
-
+ // Class Data
protected final static Log log =
LogFactory.getLog(WebContentPortlet.class);
public final static String defaultEncoding = "UTF-8";
- // Data Members
-
+ // Data Members
private RulesetRewriter rewriter = null;
private RewriterController rewriteController = null;
@@ -166,11 +153,9 @@
if (history.hasNextPage())
history.getNextPage();
}
- }
-
+ }
return ; // proceed to doView() with adjusted history
- }
-
+ }
// Check if an action parameter was defined
String webContentURL =
actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_URL);
String webContentMethod =
actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_METHOD);
@@ -330,9 +315,12 @@
byte[] result = doPreemptiveAuthentication(httpClient, httpMethod,
request, response);
// ...get, cache, and return the content
- if (result == null) {
+ if (result == null)
+ {
return doHttpWebContent(httpClient, httpMethod, 0, request,
response);
- } else {
+ }
+ else
+ {
return result;
}
}
@@ -525,30 +513,35 @@
// formMethod = FORM_MULTIPART_METHOD;
HttpMethodBase httpMethod = null;
String useragentProperty = request.getProperty("User-Agent");
- if(formMethod.equalsIgnoreCase(FORM_MULTIPART_METHOD)){
+ if (formMethod.equalsIgnoreCase(FORM_MULTIPART_METHOD))
+ {
// http mutipart
- MultipartPostMethod mutlitPart = (MultipartPostMethod)( httpMethod
= new MultipartPostMethod(uri)) ;
+ MultipartPostMethod mutlitPart = (MultipartPostMethod) (httpMethod
= new MultipartPostMethod(uri));
if (params != null && !params.isEmpty())
{
Iterator iter = params.entrySet().iterator();
while (iter.hasNext())
{
- Map.Entry entry = (Map.Entry)iter.next();
- String name = (String)entry.getKey();
- String[] values = (String[])entry.getValue();
+ Map.Entry entry = (Map.Entry) iter.next();
+ String name = (String) entry.getKey();
+ String[] values = (String[]) entry.getValue();
if (values != null)
- for (int i=0,limit=values.length; i<limit; i++)
+ for (int i = 0, limit = values.length; i < limit; i++)
{
- // System.out.println("...adding >>>POST
parameter: "+name+", with value: "+values[i]+"<<<");
-
+ //System.out.println("...adding >>>POST parameter:
"
+ // +name+", with value: "+values[i]+"<<<");
+
mutlitPart.addParameter(name, values[i]);
}
- }
+ }
}
-
- }else if (formMethod.equalsIgnoreCase(FORM_GET_METHOD)){
-
- // System.out.println("WebContentPortlet.getHttpMethod() - HTTP
GET from URL: "+uri);
+
+ }
+ else if (formMethod.equalsIgnoreCase(FORM_GET_METHOD))
+ {
+
+ // System.out.println(
+ // "WebContentPortlet.getHttpMethod() - HTTP GET from URL: "+uri);
// http GET
httpMethod = new GetMethod(uri);
if (params != null && !params.isEmpty())
@@ -557,83 +550,65 @@
Iterator iter = params.entrySet().iterator();
while (iter.hasNext())
{
- Map.Entry entry = (Map.Entry)iter.next() ;
- String name = (String)entry.getKey() ;
- String[] values = (String [])entry.getValue() ;
+ Map.Entry entry = (Map.Entry) iter.next();
+ String name = (String) entry.getKey();
+ String[] values = (String[]) entry.getValue();
if (values != null)
- for (int i = 0,limit = values.length; i < limit; i++)
+ for (int i = 0, limit = values.length; i < limit; i++)
{
- // System.out.println("...adding >>>GET parameter:
"+name+", with value: "+values[i]+"<<<");
+ //System.out.println("...adding >>>GET parameter:
"+
+ // name+", with value: "+values[i]+"<<<");
pairs.add(new NameValuePair(name, values[i]));
}
}
- httpMethod.setQueryString((NameValuePair[])pairs.toArray(new
NameValuePair[pairs.size()]));
+ httpMethod.setQueryString((NameValuePair[]) pairs.toArray(new
NameValuePair[pairs.size()]));
}
-
- // automatically follow redirects (NOTE: not supported in POST -
will throw exeception if you ask for it, then sees a redirect!!)
+
+ // automatically follow redirects (NOTE: not supported in POST -
+ // will throw exeception if you ask for it, then sees a redirect!!)
httpMethod.setFollowRedirects(true);
- }else if (formMethod.equalsIgnoreCase(FORM_POST_METHOD)) {
- // System.out.println("WebContentPortlet.getHttpMethod() - HTTP
POST to URL: "+uri);
-
+ }
+ else if (formMethod.equalsIgnoreCase(FORM_POST_METHOD))
+ {
+ // System.out.println(
+ // "WebContentPortlet.getHttpMethod() - HTTP POST to URL: "+uri);
+
// http POST
- PostMethod postMethod = (PostMethod)( httpMethod = new
PostMethod(uri)) ;
+ PostMethod postMethod = (PostMethod) (httpMethod = new
PostMethod(uri));
if (params != null && !params.isEmpty())
{
Iterator iter = params.entrySet().iterator();
while (iter.hasNext())
{
- Map.Entry entry = (Map.Entry)iter.next();
- String name = (String)entry.getKey();
- String[] values = (String[])entry.getValue();
+ Map.Entry entry = (Map.Entry) iter.next();
+ String name = (String) entry.getKey();
+ String[] values = (String[]) entry.getValue();
if (values != null)
- for (int i=0,limit=values.length; i<limit; i++)
+ for (int i = 0, limit = values.length; i < limit; i++)
{
- // System.out.println("...adding >>>POST
parameter: "+name+", with value: "+values[i]+"<<<");
-
+ //System.out.println("...adding >>>POST parameter:
"
+ // +name+", with value: "+values[i]+"<<<");
+
postMethod.addParameter(name, values[i]);
}
- }
+ }
}
}
-
- // propagate User-Agent, so target site does not think we are a D.O.S.
attack
- httpMethod.addRequestHeader( "User-Agent", useragentProperty );
-
- // BOZO - DON'T do this. default policy seems to be more flexible!!!
-
//httpMethod.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
-
+
+ // propagate User-Agent, so target site does not think we are a D.O.S.
+ // attack
+ httpMethod.addRequestHeader("User-Agent", useragentProperty);
+
+ // BOZO - DON'T do this. default policy seems to be more flexible!!!
+ // httpMethod.getParams().setCookiePolicy(CookiePolicy.
+ // BROWSER_COMPATIBILITY);
+
// ...ready to use!
- return httpMethod ;
+ return httpMethod;
}
-
-
-
static final int BLOCK_SIZE = 4096;
- /*
- private void drain(InputStream reader, OutputStream writer) throws
IOException
- {
- byte[] bytes = new byte[BLOCK_SIZE];
- try
- {
- int length = reader.read(bytes);
- while (length != -1)
- {
- if (length != 0)
- {
- writer.write(bytes, 0, length);
- }
- length = reader.read(bytes);
- }
- }
- finally
- {
- bytes = null;
- }
- }
- */
-
private void drain(Reader r, Writer w) throws IOException
{
char[] bytes = new char[BLOCK_SIZE];
@@ -656,15 +631,6 @@
}
- /*
- private void drain(Reader r, OutputStream os) throws IOException
- {
- Writer w = new OutputStreamWriter(os);
- drain(r, w);
- w.flush();
- }
- */
-
private String getContentCharSet(InputStream is) throws IOException
{
if (!is.markSupported())