portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r910838 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/openid/ webapp/WEB-INF/ webapp/WEB-INF/view/openid/
Date Wed, 17 Feb 2010 06:23:01 GMT
Author: rwatler
Date: Wed Feb 17 06:23:01 2010
New Revision: 910838

URL: http://svn.apache.org/viewvc?rev=910838&view=rev
Log:
JS2-1101: OpenID Support: add OpenIDIFramePortlet that displays its content only when a specific
OpenID provider domain has been used for the current portal session login

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDIFramePortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-iframe-help.html
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-not-available.vm
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDIFramePortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDIFramePortlet.java?rev=910838&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDIFramePortlet.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDIFramePortlet.java
Wed Feb 17 06:23:01 2010
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portlets.openid;
+
+import java.io.IOException;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletPreferences;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.security.auth.Subject;
+
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.portals.applications.webcontent.portlet.IFrameGenericPortlet;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * IFrame portlet variant that loads content only when the portal
+ * has an active OpenID login.
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class OpenIDIFramePortlet extends IFrameGenericPortlet
+{
+    private static final Logger log = LoggerFactory.getLogger(OpenIDLoginPortlet.class);
+
+    public static final String SESSION_OPEN_ID_PROVIDER_ATTR_NAME = "sessionOpenIDProvider";
+    public static final String REQUIRED_OPEN_ID_PROVIDER_ATTR_NAME = "requiredOpenIDProvider";
+    public static final String REQUIRED_OPEN_ID_PROVIDER_LABEL_ATTR_NAME = "requiredOpenIDProviderLabel";
+
+    private static final String REQUIRED_OPEN_ID_PROVIDER_LABEL_PREF_NAME = "REQUIREDOPENIDPROVIDERLABEL";
+    private static final String REQUIRED_OPEN_ID_PROVIDER_PREF_NAME = "REQUIREDOPENIDPROVIDER";
+    
+    private static final String NOT_AVAILABLE_VIEW_PAGE_INIT_PARAM = "NotAvailableViewPage";
+
+    private String notAvailableViewPage;
+    
+    /* (non-Javadoc)
+     * @see org.apache.portals.applications.webcontent.portlet.IFrameGenericPortlet#init(javax.portlet.PortletConfig)
+     */
+    public void init(PortletConfig config) throws PortletException
+    {
+        super.init(config);
+        notAvailableViewPage = config.getInitParameter(NOT_AVAILABLE_VIEW_PAGE_INIT_PARAM);
+    }
+    
+    /* (non-Javadoc)
+     * @see javax.portlet.GenericPortlet#destroy()
+     */
+    public void destroy()
+    {
+        notAvailableViewPage = null;
+        super.destroy();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.portals.applications.webcontent.portlet.IFrameGenericPortlet#doView(javax.portlet.RenderRequest,
javax.portlet.RenderResponse)
+     */
+    public void doView(RenderRequest request, RenderResponse response) throws PortletException,
IOException
+    {
+        // get current session OpenID login state
+        RequestContext requestContext = (RequestContext)request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        Subject sessionSubject = (Subject)requestContext.getSessionAttribute(PortalReservedParameters.SESSION_KEY_SUBJECT);
+        String sessionOpenIDProvider = (String)requestContext.getSessionAttribute(PortalReservedParameters.SESSION_OPEN_ID_PROVIDER);
+        PortletPreferences prefs = request.getPreferences();
+        String requiredOpenIDProvider = prefs.getValue(REQUIRED_OPEN_ID_PROVIDER_PREF_NAME,
null);
+        String requiredOpenIDProviderLabel = prefs.getValue(REQUIRED_OPEN_ID_PROVIDER_LABEL_PREF_NAME,
null);
+
+        // check against configured requirements
+        if ((sessionSubject == null) || ((requiredOpenIDProvider != null) && !requiredOpenIDProvider.equals(sessionOpenIDProvider)))
+        {
+            if (notAvailableViewPage != null)
+            {
+                // render not available page
+                request.setAttribute(PARAM_VIEW_PAGE, notAvailableViewPage);
+                request.setAttribute(SESSION_OPEN_ID_PROVIDER_ATTR_NAME, sessionOpenIDProvider);
+                request.setAttribute(REQUIRED_OPEN_ID_PROVIDER_ATTR_NAME, requiredOpenIDProvider);
+                request.setAttribute(REQUIRED_OPEN_ID_PROVIDER_LABEL_ATTR_NAME, requiredOpenIDProviderLabel);
+                super.doView(request, response);
+            }
+            return;
+        }
+        
+        // continue with IFrame generation
+        super.doView(request, response);
+    }
+}

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=910838&r1=910837&r2=910838&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml Wed
Feb 17 06:23:01 2010
@@ -2534,7 +2534,102 @@
         <name>PROXYPORT</name>
         <value></value>
       </preference>
-    </portlet-preferences>        
+    </portlet-preferences>
+  </portlet>
+
+  <portlet>
+    <description>
+      Places an HTML IFrame inside a portlet for easily hosting other
+      web application content within a portlet. This portlet will display
+      a configured page when the current session is not logged in using
+      a specified OpenID provider. Sizes of both normal and maximized
+      modes are configurable in edit mode.
+    </description>
+    <portlet-name>OpenIDIFramePortlet</portlet-name>
+    <display-name>OpenID IFrame Portlet</display-name>
+    <portlet-class>org.apache.jetspeed.portlets.openid.OpenIDIFramePortlet</portlet-class>
+    <init-param>
+      <name>EditPage</name>
+      <value>/WEB-INF/view/edit-prefs.vm</value>
+    </init-param>
+    <init-param>
+      <name>HelpPage</name>
+      <value>/WEB-INF/view/openid/openid-iframe-help.html</value>
+    </init-param>
+    <init-param>
+      <name>NotAvailableViewPage</name>
+      <value>/WEB-INF/view/openid/openid-not-available.vm</value>
+    </init-param>
+    <init-param>
+      <name>portlet-icon</name>
+      <value>applications-internet.png</value>
+    </init-param>
+    <expiration-cache>300</expiration-cache>
+    <supports>
+      <mime-type>text/html</mime-type>
+      <portlet-mode>EDIT</portlet-mode>
+      <portlet-mode>VIEW</portlet-mode>
+      <portlet-mode>HELP</portlet-mode>
+    </supports>
+    <supported-locale>en</supported-locale>
+    <portlet-info>
+      <title>OpenID IFrame</title>
+      <short-title>OpenID IFrame</short-title>
+      <keywords>tool,iframe,web,frame,content,host</keywords>
+    </portlet-info>
+    <portlet-preferences>
+      <preference>
+        <name>EDITABLEPREFS</name>
+        <value>TITLE, SRC, WIDTH, HEIGHT, MAX-WIDTH, MAX-HEIGHT, SCROLLING, AUTORESIZE,
VISITLASTPAGE, REQUIREDOPENIDPROVIDER</value>
+      </preference>
+      <preference>
+        <name>TITLE</name>
+        <value></value>
+      </preference>
+      <preference>
+        <name>SRC</name>
+        <value>http://portals.apache.org/</value>
+      </preference>
+      <!-- You can set AUTORESIZE to true when the SRC can be in the same domain of the
portal web pages. -->
+      <preference>
+        <name>AUTORESIZE</name>
+        <value>false</value>
+      </preference>
+      <!-- You can set VISITLASTPAGE to true when the SRC can be in the same domain of
the portal web pages. -->
+      <preference>
+        <name>VISITLASTPAGE</name>
+        <value>false</value>
+      </preference>
+      <!--
+        Don't specify a HEIGHT if you want a normal filled out layout
+        because percentage values result in the content not to be
+        displayed on IE6. Specific values are ok though.
+      -->
+      <preference>
+        <name>HEIGHT</name>
+        <value>300</value>
+      </preference>
+      <preference>
+        <name>WIDTH</name>
+        <value>100%</value>
+      </preference>
+      <preference>
+        <name>MAX-HEIGHT</name>
+        <value>800</value>
+      </preference>
+      <preference>
+        <name>MAX-WIDTH</name>
+        <value>100%</value>
+      </preference>
+      <preference>
+        <name>SCROLLING</name>
+        <value>AUTO</value>
+      </preference>
+      <preference>
+        <name>REQUIREDOPENIDPROVIDER</name>
+        <value></value>
+      </preference>
+    </portlet-preferences>
   </portlet>
   
   <custom-portlet-mode>

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-iframe-help.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-iframe-help.html?rev=910838&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-iframe-help.html
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-iframe-help.html
Wed Feb 17 06:23:01 2010
@@ -0,0 +1,36 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<h1>OpenID IFrame Help</h1>
+<p>
+The following preferences can be used with the OpenID IFrame Portlet in addition to the standard
IFrame preferences 
+</p>
+<p>
+<table border="1" cellspacing="1" cellpadding="3">
+<tr>
+<th class="portlet-section-body">Preference</th>	
+<th class="portlet-section-body">Usage</th>
+</tr>
+<tr>
+<td class='portlet-section-body'>REQUIREDOPENIDPROVIDERLABEL</td>
+<td class='portlet-section-body'>Required login OpenID provider label for IFRAME inclusion.</td>
+</tr>
+<tr>
+<td class='portlet-section-body'>REQUIREDOPENIDPROVIDER</td>
+<td class='portlet-section-body'>Required login OpenID provider domain name for IFRAME
inclusion.</td>
+</tr>
+</table>	
+</p>

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-not-available.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-not-available.vm?rev=910838&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-not-available.vm
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/openid/openid-not-available.vm
Wed Feb 17 06:23:01 2010
@@ -0,0 +1,30 @@
+#*
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*#
+#set($rc = $renderRequest.getAttribute("org.apache.jetspeed.request.RequestContext"))
+#set($sessionOpenIDProvider = $rc.getAttribute("sessionOpenIDProvider"))
+#set($requiredOpenIDProviderLabel = $rc.getAttribute("requiredOpenIDProviderLabel"))
+#set($requiredOpenIDProvider = $rc.getAttribute("requiredOpenIDProvider"))
+#if($!sessionOpenIDProviderLabel == "")
+#set($requiredOpenIDProviderLabel = $requiredOpenIDProvider)
+#end
+<div class="portlet-msg-alert">Unable to view content.
+#if($!requiredOpenIDProviderLabel == "")
+Please log in using your OpenID account.
+#else
+Please log in using your $!{requiredOpenIDProviderLabel} OpenID account.
+#end
+</div>



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


Mime
View raw message