morciuch 2003/06/11 14:47:47
Modified: src/java/org/apache/jetspeed/portal/portlets
IFramePortlet.java
webapp/WEB-INF/conf portlets.xreg
xdocs changes.xml
Added: src/java/org/apache/jetspeed/portal/portlets
BASICAuthIFramePortlet.java
Log:
1. Added BASICAuthIFramePortlet contributed by Jacob Kjome (see Bugzilla issue#
18632)
2. Exposed BASICAuthIFramePortlet and IFramePortlet to non-admin users (see Bugzilla
issue# 20692)
Revision Changes Path
1.5 +57 -25
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/IFramePortlet.java
Index: IFramePortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/IFramePortlet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IFramePortlet.java 7 May 2003 15:16:50 -0000 1.4
+++ IFramePortlet.java 11 Jun 2003 21:47:47 -0000 1.5
@@ -115,6 +115,7 @@
* @created February 23, 2002
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Barnhill</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Mark Orciuch</a>
+ * @version $Id$
* @see AbstractPortlet
*/
@@ -124,6 +125,8 @@
"[Your user agent does not support inline frames or is currently"
+ " configured not to display frames]";
+ static final String NO_SOURCE_MSG = "Please customize source for this IFrame";
+
static final String DEFAULT_SOURCE = "http://127.0.0.1";
static final String DEFAULT_WIDTH = null;
static final String DEFAULT_HEIGHT = null;
@@ -163,32 +166,36 @@
*/
public void setSource(String source)
{
- // Handle replacement variables
- Hashtable parms = new Hashtable();
- if (source.indexOf("${") >= 0)
- {
- // Add all portlet parms
- parms.putAll(this.getPortletConfig().getInitParameters());
- // Add web app root variable replacement
- try
- {
- ServerData sd = new ServerData(TurbineServlet.getServerName(),
-
Integer.parseInt(TurbineServlet.getServerPort()),
- TurbineServlet.getServerScheme(),
- TurbineServlet.getContextPath(),
- TurbineServlet.getContextPath());
- DynamicURI uri = new DynamicURI(sd);
- parms.put(TurbineConstants.WEBAPP_ROOT, uri.toString() + "/");
- }
- catch (Exception e)
+ if (source != null)
+ {
+ // Handle replacement variables
+ Hashtable parms = new Hashtable();
+ if (source.indexOf("${") >= 0)
{
- Log.error(e);
+ // Add all portlet parms
+ parms.putAll(this.getPortletConfig().getInitParameters());
+
+ // Add web app root variable replacement
+ try
+ {
+ ServerData sd = new ServerData(TurbineServlet.getServerName(),
+
Integer.parseInt(TurbineServlet.getServerPort()),
+ TurbineServlet.getServerScheme(),
+ TurbineServlet.getContextPath(),
+ TurbineServlet.getContextPath());
+ DynamicURI uri = new DynamicURI(sd);
+ parms.put(TurbineConstants.WEBAPP_ROOT, uri.toString() + "/");
+ }
+ catch (Exception e)
+ {
+ Log.error(e);
+ }
+ // Add portlet name variable replacement
+ parms.put("portlet", this.getName());
}
- // Add portlet name variable replacement
- parms.put("portlet", this.getName());
+
+ this.iSource = org.apache.jetspeed.util.StringUtils.replaceVars(source,
parms);
}
-
- this.iSource = org.apache.jetspeed.util.StringUtils.replaceVars(source,
parms);
}
@@ -321,8 +328,28 @@
*/
public ConcreteElement getContent(RunData runData)
{
+
+ // Reinitialize if user customized the portlet (this will be useful
+ // when portlet preferences include user name and password for
authentication or
+ // when other exposed iframe attributes are changed)
+ if
(org.apache.jetspeed.util.PortletSessionState.getPortletConfigChanged(this, runData))
+ {
+ try {
+ this.init();
+ }
+ catch (PortletException pe)
+ {
+ Log.error(pe);
+ }
+ }
+
StringBuffer text = new StringBuffer();
- String href = getPortletConfig().getInitParameter("url");
+
+ if (getSource() == null || getSource().trim().length() == 0)
+ {
+ text.append(NO_SOURCE_MSG);
+ return (new StringElement(text.toString()));
+ }
text.append("<IFRAME ");
@@ -422,7 +449,12 @@
*/
public String getFrameBorder()
{
- return iFrameBorder;
+ String trueValues = "1,yes,true";
+ if (iFrameBorder != null && trueValues.indexOf(iFrameBorder) >= 0)
+ {
+ return "1";
+ }
+ return "0";
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/BASICAuthIFramePortlet.java
Index: BASICAuthIFramePortlet.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.portal.portlets;
import org.apache.jetspeed.portal.PortletException;
import org.apache.turbine.util.RunData;
import org.apache.ecs.ConcreteElement;
/**
* Same as IFramePortlet except that it allows to use basic authentication using
current
* user name and password (or whatever is provided in portlet preferences)
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jacob Kjome</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Mark Orciuch</a>
* @version $Id: BASICAuthIFramePortlet.java,v 1.1 2003/06/11 21:47:47 morciuch Exp $
*/
public class BASICAuthIFramePortlet extends IFramePortlet
{
private String origSource = null;
private static final String USERNAME = "username";
private static final String PASSWORD = "password";
/**
*
* @param runData
* @return
*/
public ConcreteElement getContent(RunData runData)
{
if
(org.apache.jetspeed.util.PortletSessionState.getPortletConfigChanged(this, runData))
{
try {
this.init();
}
catch (PortletException pe)
{
org.apache.turbine.util.Log.error(pe);
}
}
setSource(getSource(runData));
return super.getContent(runData);
}
/**
*
* @param runData
* @return
*/
public String getSource(RunData runData)
{
String source = origSource;
if (source == null || source.trim().length() == 0)
{
return null;
}
int schemeCount = 8;
int index = source.indexOf("https://");
if (index == -1)
{
schemeCount = 7;
index = source.indexOf("http://");
}
if (index != -1)
{
String user = this.getPortletConfig().getInitParameter(USERNAME);
if (user == null || user.trim().length() == 0)
{
user = runData.getUser().getUserName();
}
String pass = this.getPortletConfig().getInitParameter(PASSWORD);
if (pass == null || pass.trim().length() == 0)
{
pass = runData.getUser().getPassword();
}
String beginStr = source.substring(0, schemeCount);
String endStr = source.substring(schemeCount);
int size = user.length() + pass.length() + source.length() + 2;
StringBuffer buff = new StringBuffer(size);
source =
buff.append(beginStr).append(user).append(":").append(pass).append("@").append(endStr).toString();
}
return source;
}
/**
*
* @exception PortletException
*/
public void init() throws PortletException
{
super.init();
origSource = getSource();
}
}
1.39 +55 -3 jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg
Index: portlets.xreg
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- portlets.xreg 5 Jun 2003 18:22:05 -0000 1.38
+++ portlets.xreg 11 Jun 2003 21:47:47 -0000 1.39
@@ -162,15 +162,67 @@
<media-type ref="html"/>
<category>admin</category>
</portlet-entry>
- <portlet-entry name="IFramePortlet" hidden="false" type="abstract"
application="false">
- <security-ref parent="default"/>
+ <portlet-entry name="IFramePortlet" hidden="false" type="instance"
application="false">
+ <meta-info>
+ <title>IFrame Portlet</title>
+ <description>Display URL within IFrame</description>
+ </meta-info>
<classname>org.apache.jetspeed.portal.portlets.IFramePortlet</classname>
+ <parameter name="source" value="" hidden="false">
+ <meta-info>
+ <title>Source</title>
+ <description>Specify source URL for this iframe</description>
+ </meta-info>
+ </parameter>
+ <parameter name="width" value="640" hidden="false">
+ <meta-info>
+ <title>Width</title>
+ <description>Specify width for this iframe</description>
+ </meta-info>
+ </parameter>
+ <parameter name="height" value="480" hidden="false">
+ <meta-info>
+ <title>Height</title>
+ <description>Specify height for this iframe</description>
+ </meta-info>
+ </parameter>
+ <parameter name="frameborder" type="boolean" value="true" hidden="false">
+ <meta-info>
+ <title>Frameborder</title>
+ <description>Specify whether do display border around this
iframe</description>
+ </meta-info>
+ </parameter>
+ <media-type ref="html"/>
+ <category>frames</category>
+ <category>proxy</category>
+ <category>web</category>
+ </portlet-entry>
+ <portlet-entry name="BASICAuthIFramePortlet" hidden="false" type="ref"
parent="IFramePortlet" application="false">
+ <meta-info>
+ <title>BASIC Authentication IFrame Portlet</title>
+ <description>Display secured URL within IFrame after automatic
authentication</description>
+ </meta-info>
+
<classname>org.apache.jetspeed.portal.portlets.BASICAuthIFramePortlet</classname>
+ <parameter name="username" value="" hidden="false">
+ <meta-info>
+ <title>User Name</title>
+ <description>Specify user name to authenticate with. Leave blank to
use portal username.</description>
+ </meta-info>
+ </parameter>
+ <parameter name="password" value="" type="style" hidden="false">
+ <meta-info>
+ <title>Password</title>
+ <description>Specify password to authenticate with. Leave blank to
use portal password.</description>
+ </meta-info>
+ </parameter>
+ <parameter name="password.style" value="VelocityParameterPresentationStyle"
hidden="true"/>
+ <parameter name="password.style.template" value="Password.vm"
hidden="true"/>
+ <media-type ref="html"/>
<category>frames</category>
<category>proxy</category>
<category>web</category>
</portlet-entry>
<portlet-entry name="DatabaseBrowserPortlet" hidden="false" type="abstract"
application="false">
- <security-ref parent="default"/>
<classname>org.apache.jetspeed.portal.portlets.browser.DatabaseBrowserPortlet</classname>
<category>database</category>
</portlet-entry>
1.170 +7 -1 jakarta-jetspeed/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/changes.xml,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -r1.169 -r1.170
--- changes.xml 9 Jun 2003 22:06:58 -0000 1.169
+++ changes.xml 11 Jun 2003 21:47:47 -0000 1.170
@@ -24,6 +24,12 @@
</li>
-->
<li>
+ Add - Bug # 20692 - 2003/06/11 - Exposed BASICAuthIFramePortlet and
IFramePortlet to non-admin users (MO)
+</li>
+<li>
+ Add - Bug # 18632 - 2003/06/11 - Added BASICAuthIFramePortlet contributed by
Jacob Kjome (MO)
+</li>
+<li>
Add - Bug # 15684 - 2003/06/09 - It is no longer possible to remove predefined
system users/roles/groups/permissions (MO)
</li>
<li>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]