portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r909922 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/openid/ webapp/WEB-INF/ webapp/WEB-INF/security/login/
Date Sat, 13 Feb 2010 21:52:17 GMT
Author: rwatler
Date: Sat Feb 13 21:52:16 2010
New Revision: 909922

URL: http://svn.apache.org/viewvc?rev=909922&view=rev
Log:
JS2-1101: OpenID Support Update
---------------------------------------------------------------
- add additional configuration parameters and preferences to OpenIDLoginPortlet
  - provider button labels and OpenID hosts/domains
  - flag to enable/disable OpenID provider/URL entry


Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDLoginPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login-prefs.jsp
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDLoginPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDLoginPortlet.java?rev=909922&r1=909921&r2=909922&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDLoginPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/openid/OpenIDLoginPortlet.java
Sat Feb 13 21:52:16 2010
@@ -17,6 +17,11 @@
 package org.apache.jetspeed.portlets.openid;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -49,6 +54,14 @@
 {
     private static final Logger log = LoggerFactory.getLogger(OpenIDLoginPortlet.class);
 
+    public static final String PROVIDER_LABELS_INIT_PARAM_NAME = "providerLabels";
+    public static final String PROVIDER_DOMAINS_INIT_PARAM_NAME = "providerDomains";
+    public static final String ENABLE_OPEN_ID_ENTRY_INIT_PARAM_NAME = "enableOpenIDEntry";
+    
+    public static final String PROVIDER_LABELS_PREF_NAME = "providerLabels";
+    public static final String PROVIDER_DOMAINS_PREF_NAME = "providerDomains";
+    public static final String ENABLE_OPEN_ID_ENTRY_PREF_NAME = "enableOpenIDEntry";
+
     public static final String ENABLE_REGISTRATION_CONFIG_PREF_NAME = "enableRegistrationConfig";
     public static final String ENABLE_REGISTRATION_PREF_NAME = "enableRegistration";
     public static final String REGISTRATION_USER_TEMPLATE_PREF_NAME = "newUserTemplateDirectory";
@@ -59,18 +72,30 @@
     public static final String REGISTRATION_PROFILER_RULE_VALUES_PREF_NAME = "rulesValues";
     
     public static final String SAVE_ACTION_PARAM_NAME = "save";
+    
+    public static final String PROVIDER_BUTTONS_ATTR_NAME = "providerButtons";
+    public static final String ENABLE_OPEN_ID_ENTRY_ATTR_NAME = "enableOpenIDEntry";
 
-    private static final String [] REGISTRATION_PREF_NAMES = new String[]{ENABLE_REGISTRATION_CONFIG_PREF_NAME,
-                                                                          ENABLE_REGISTRATION_PREF_NAME,
-                                                                          REGISTRATION_USER_TEMPLATE_PREF_NAME,
-                                                                          REGISTRATION_SUBSITE_ROOT_PREF_NAME,
-                                                                          REGISTRATION_ROLES_PREF_NAME,
-                                                                          REGISTRATION_GROUPS_PREF_NAME,
-                                                                          REGISTRATION_PROFILER_RULE_NAMES_PREF_NAME,
-                                                                          REGISTRATION_PROFILER_RULE_VALUES_PREF_NAME};
+    private static final List<String> PREF_NAMES = Arrays.asList(new String[]{PROVIDER_LABELS_PREF_NAME,
+                                                                              PROVIDER_DOMAINS_PREF_NAME,
+                                                                              ENABLE_OPEN_ID_ENTRY_PREF_NAME,
+                                                                              ENABLE_REGISTRATION_CONFIG_PREF_NAME,
+                                                                              ENABLE_REGISTRATION_PREF_NAME,
+                                                                              REGISTRATION_USER_TEMPLATE_PREF_NAME,
+                                                                              REGISTRATION_SUBSITE_ROOT_PREF_NAME,
+                                                                              REGISTRATION_ROLES_PREF_NAME,
+                                                                              REGISTRATION_GROUPS_PREF_NAME,
+                                                                              REGISTRATION_PROFILER_RULE_NAMES_PREF_NAME,
+                                                                              REGISTRATION_PROFILER_RULE_VALUES_PREF_NAME});
+    private static final List<String> BOOLEAN_PREF_NAMES = Arrays.asList(new String[]{ENABLE_OPEN_ID_ENTRY_PREF_NAME,
+                                                                                      ENABLE_REGISTRATION_CONFIG_PREF_NAME,
+                                                                                      ENABLE_REGISTRATION_PREF_NAME});
     private static final String OPEN_ID_RELAYING_PARTY_SERVLET_MAPPING = "/openid";
     
-    OpenIDRegistrationConfiguration initRegistrationConfiguration;
+    private List<String> initProviderLabels;
+    private List<String> initProviderDomains;
+    private boolean initEnableOpenIDEntry;
+    private OpenIDRegistrationConfiguration initRegistrationConfiguration;
     
     /* (non-Javadoc)
      * @see org.apache.portals.bridges.common.GenericServletPortlet#init(javax.portlet.PortletConfig)
@@ -80,6 +105,9 @@
         super.init(config);
 
         // registration configuration parameters
+        initProviderLabels = OpenIDRegistrationConfiguration.parseParameterList(config.getInitParameter(PROVIDER_LABELS_INIT_PARAM_NAME));
+        initProviderDomains = OpenIDRegistrationConfiguration.parseParameterList(config.getInitParameter(PROVIDER_DOMAINS_INIT_PARAM_NAME));
+        initEnableOpenIDEntry = Boolean.parseBoolean(config.getInitParameter(ENABLE_OPEN_ID_ENTRY_INIT_PARAM_NAME));
         if (Boolean.parseBoolean(config.getInitParameter(OpenIDConstants.ENABLE_REGISTRATION_CONFIG_INIT_PARAM_NAME)))
         {
             initRegistrationConfiguration = new OpenIDRegistrationConfiguration();
@@ -126,6 +154,35 @@
      */
     public void doView(RenderRequest request, RenderResponse response) throws PortletException,
IOException
     {
+        // provider button labels and domains
+        PortletPreferences prefs = request.getPreferences();
+        List<String> providerButtonLabels = OpenIDRegistrationConfiguration.parseParameterList(prefs.getValue(PROVIDER_LABELS_PREF_NAME,
null));
+        List<String> providerButtonDomains = OpenIDRegistrationConfiguration.parseParameterList(prefs.getValue(PROVIDER_DOMAINS_PREF_NAME,
null));
+        if ((providerButtonLabels == null) || providerButtonLabels.isEmpty() || (providerButtonDomains
== null) || providerButtonDomains.isEmpty())
+        {
+            providerButtonLabels = initProviderLabels;
+            providerButtonDomains = initProviderDomains;
+        }
+        if ((providerButtonLabels != null) && !providerButtonLabels.isEmpty() &&
(providerButtonDomains != null) && !providerButtonDomains.isEmpty())
+        {
+            Map<String,String> providerButtons = new LinkedHashMap<String,String>();
+            Iterator<String> labelsIter = providerButtonLabels.iterator();
+            Iterator<String> domainsIter = providerButtonDomains.iterator();
+            while (labelsIter.hasNext() && domainsIter.hasNext())
+            {
+                providerButtons.put(domainsIter.next(), labelsIter.next());
+            }
+            request.setAttribute(PROVIDER_BUTTONS_ATTR_NAME, providerButtons);
+        }
+        // enable OpenID entry
+        boolean enableOpenIDEntry = initEnableOpenIDEntry;
+        String enableOpenIDEntryPref = prefs.getValue(ENABLE_OPEN_ID_ENTRY_PREF_NAME, null);
+        if (enableOpenIDEntryPref != null)
+        {
+            enableOpenIDEntry = Boolean.parseBoolean(enableOpenIDEntryPref);
+        }
+        request.setAttribute(ENABLE_OPEN_ID_ENTRY_ATTR_NAME, Boolean.toString(enableOpenIDEntry));
+        
         // access login errors in session from OpenIDRelayingPartyServlet
         RequestContext requestContext = (RequestContext)request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
         String errorCode = (String)requestContext.getSessionAttribute(OpenIDConstants.OPEN_ID_ERROR);
@@ -144,9 +201,9 @@
      */
     public void doEdit(RenderRequest request, RenderResponse response) throws PortletException,
IOException
     {
-        // access registration preferences to edit
+        // access provider and registration preferences to edit
         PortletPreferences prefs = request.getPreferences();
-        for (String prefName : REGISTRATION_PREF_NAMES)
+        for (String prefName : PREF_NAMES)
         {
             String prefValue = prefs.getValue(prefName, null);
             if (prefValue != null)
@@ -232,10 +289,10 @@
             // default preferences edit mode
             if (actionRequest.getParameter(SAVE_ACTION_PARAM_NAME) != null)
             {
-                // save preferences
+                // save provider and registration preferences
                 PortletPreferences prefs = actionRequest.getPreferences();
                 boolean storePrefs = false;
-                for (String prefName : REGISTRATION_PREF_NAMES)
+                for (String prefName : PREF_NAMES)
                 {
                     String prefValue = actionRequest.getParameter(prefName);
                     if ((prefValue != null) && (prefValue.length() > 0))
@@ -246,6 +303,15 @@
                             storePrefs = true;
                         }
                     }
+                    else if (BOOLEAN_PREF_NAMES.indexOf(prefName) != -1)
+                    {
+                        String booleanPrefValue = prefs.getValue(prefName, null);
+                        if ((booleanPrefValue == null) || !booleanPrefValue.equals("false"))
+                        {
+                            prefs.setValue(prefName, "false");
+                            storePrefs = true;
+                        }
+                    }
                     else if (prefs.getValue(prefName, null) != null)
                     {
                         prefs.setValue(prefName, null);

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=909922&r1=909921&r2=909922&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 Sat
Feb 13 21:52:16 2010
@@ -116,6 +116,21 @@
       <value>/WEB-INF/security/login/openid-login-prefs.jsp</value>
     </init-param>
     <init-param>
+      <description>Display names for OpenID provider buttons.</description>
+      <name>providerLabels</name>
+      <value>Gmail, Yahoo!, myOpenID</value>
+    </init-param>
+    <init-param>
+      <description>Domain names for OpenID provider buttons.</description>
+      <name>providerDomains</name>
+      <value>gmail.com, yahoo.com, myopenid.com</value>
+    </init-param>
+    <init-param>
+      <description>Enable OpenID provider or URL entry.</description>
+      <name>enableOpenIDEntry</name>
+      <value>true</value>
+    </init-param>
+    <init-param>
       <description>Enable portlet init parameter registration configuration.</description>
       <name>enableRegistrationConfig</name>
       <value>false</value>
@@ -167,6 +182,21 @@
     </supports>
     <resource-bundle>org.apache.jetspeed.portlets.security.resources.OpenIDLoginResources</resource-bundle>
     <portlet-preferences>
+      <!-- Display names for OpenID provider buttons. -->
+      <preference>
+        <name>providerLabels</name>
+        <value>Gmail, Yahoo!, myOpenID</value>
+      </preference>
+      <!-- Domain names for OpenID provider buttons. -->
+      <preference>
+        <name>providerDomains</name>
+        <value>gmail.com, yahoo.com, myopenid.com</value>
+      </preference>
+      <!-- Enable OpenID provider or URL entry. -->
+      <preference>
+        <name>enableOpenIDEntry</name>
+        <value>true</value>
+      </preference>
       <!-- Enable portlet preferences registration configuration. -->
       <preference>
         <name>enableRegistrationConfig</name>

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login-prefs.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login-prefs.jsp?rev=909922&r1=909921&r2=909922&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login-prefs.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login-prefs.jsp
Sat Feb 13 21:52:16 2010
@@ -23,6 +23,12 @@
 
 <portlet:defineObjects/>
 <c_rt:set var="saveAction" value="<%=OpenIDLoginPortlet.SAVE_ACTION_PARAM_NAME%>"/>
+<c_rt:set var="providerLabelsPrefName" value="<%=OpenIDLoginPortlet.PROVIDER_LABELS_PREF_NAME%>"/>
+<c_rt:set var="providerLabels" value="<%=renderRequest.getAttribute(OpenIDLoginPortlet.PROVIDER_LABELS_PREF_NAME)%>"/>
+<c_rt:set var="providerDomainsPrefName" value="<%=OpenIDLoginPortlet.PROVIDER_DOMAINS_PREF_NAME%>"/>
+<c_rt:set var="providerDomains" value="<%=renderRequest.getAttribute(OpenIDLoginPortlet.PROVIDER_DOMAINS_PREF_NAME)%>"/>
+<c_rt:set var="enableOpenIDEntryPrefName" value="<%=OpenIDLoginPortlet.ENABLE_OPEN_ID_ENTRY_PREF_NAME%>"/>
+<c_rt:set var="enableOpenIDEntry" value="<%=Boolean.parseBoolean((String)renderRequest.getAttribute(OpenIDLoginPortlet.ENABLE_OPEN_ID_ENTRY_PREF_NAME))%>"/>
 <c_rt:set var="enableConfigPrefName" value="<%=OpenIDLoginPortlet.ENABLE_REGISTRATION_CONFIG_PREF_NAME%>"/>
 <c_rt:set var="enableConfig" value="<%=Boolean.parseBoolean((String)renderRequest.getAttribute(OpenIDLoginPortlet.ENABLE_REGISTRATION_CONFIG_PREF_NAME))%>"/>
 <c_rt:set var="enablePrefName" value="<%=OpenIDLoginPortlet.ENABLE_REGISTRATION_PREF_NAME%>"/>
@@ -44,7 +50,25 @@
   <form method="POST" action='<portlet:actionURL/>'>
     <table border="0">
       <tr>
-        <td nowrap align="right" class="portlet-section-alternate">Enable Preferences:&nbsp;</td>
+        <td nowrap align="right" class="portlet-section-alternate">OpenId Provider
Labels:&nbsp;</td>
+        <td align="left" class="portlet-section-body">
+          <input type="text" size="40" name="${providerLabelsPrefName}" value="${providerLabels}"
class="portlet-form-field-label"/>
+        </td>  
+      </tr>
+      <tr>
+        <td nowrap align="right" class="portlet-section-alternate">OpenId Provider
Domains:&nbsp;</td>
+        <td align="left" class="portlet-section-body">
+          <input type="text" size="40" name="${providerDomainsPrefName}" value="${providerDomains}"
class="portlet-form-field-label"/>
+        </td>  
+      </tr>
+      <tr>
+        <td nowrap align="right" class="portlet-section-alternate">Enable OpenID provider
or URL entry:&nbsp;</td>
+        <td align="left" class="portlet-section-body">
+          <input type="checkbox" name="${enableOpenIDEntryPrefName}" value="true" <c:if
test="${enableOpenIDEntry == 'true'}">checked</c:if>/>
+        </td>  
+      </tr>
+      <tr>
+        <td nowrap align="right" class="portlet-section-alternate">Enable Registration
Preferences:&nbsp;</td>
         <td align="left" class="portlet-section-body">
           <input type="checkbox" name="${enableConfigPrefName}" value="true" <c:if
test="${enableConfig == 'true'}">checked</c:if>/>
         </td>  

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login.jsp?rev=909922&r1=909921&r2=909922&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/security/login/openid-login.jsp
Sat Feb 13 21:52:16 2010
@@ -20,6 +20,7 @@
 <%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 
 <%@page import="org.apache.jetspeed.openid.OpenIDConstants"%>
+<%@page import="org.apache.jetspeed.portlets.openid.OpenIDLoginPortlet"%>
 
 <fmt:setBundle basename="org.apache.jetspeed.portlets.security.resources.OpenIDLoginResources"/>
 
@@ -32,6 +33,9 @@
 <c_rt:set var="openIDLogoutRequest" value="<%=OpenIDConstants.OPEN_ID_LOGOUT_REQUEST%>"/>
 <c_rt:set var="openIDError" value="<%=renderRequest.getAttribute(OpenIDConstants.OPEN_ID_ERROR)%>"/>
 
+<c_rt:set var="providerButtons" value="<%=renderRequest.getAttribute(OpenIDLoginPortlet.PROVIDER_BUTTONS_ATTR_NAME)%>"/>
+<c_rt:set var="enableOpenIDEntry" value="<%=renderRequest.getAttribute(OpenIDLoginPortlet.ENABLE_OPEN_ID_ENTRY_ATTR_NAME)%>"/>
+
 <div class="portlet-section-text">
   <c:choose>
     <c:when test="${pageContext.request.userPrincipal != null}">
@@ -43,19 +47,23 @@
     </c:when>
     <c:otherwise>
       <c:if test="${openIDError != null}"><div class="portlet-msg-alert"><fmt:message
key="openid-login.label.${openIDError}"/></div><br/></c:if>
-      <form method="POST" action='<portlet:actionURL/>'>
-        <input type="hidden" name="${openIDProvider}"/>
-        <input type="submit" value='<fmt:message key="openid-login.label.ProviderLogin"><fmt:param><c:out
value="Google"/></fmt:param></fmt:message>' onclick="this.form.elements[0].value='gmail.com';
true"/>
-        <input type="submit" value='<fmt:message key="openid-login.label.ProviderLogin"><fmt:param><c:out
value="Yahoo!"/></fmt:param></fmt:message>' onclick="this.form.elements[0].value='yahoo.com';
true"/>
-        <input type="submit" value='<fmt:message key="openid-login.label.ProviderLogin"><fmt:param><c:out
value="myOpenID"/></fmt:param></fmt:message>' onclick="this.form.elements[0].value='myopenid.com';
true"/>
-        <input type="hidden" name="${openIDRequest}" value="${openIDLoginRequest}"/>
-      </form>
-      <form method="POST" action='<portlet:actionURL/>'>
-        <span class="portlet-form-field-label"><fmt:message key="openid-login.label.OpenID"/></span>
-        <input type="text" class="portlet-form-field" size="30" name="${openIDDiscovery}"/>
-        <input type="submit" class="portlet-form-button" value='<fmt:message key="openid-login.label.Login"/>'/>
-        <input type="hidden" name="${openIDRequest}" value="${openIDLoginRequest}"/>
-      </form>
+      <c:if test="${not empty providerButtons}">
+        <form method="POST" action='<portlet:actionURL/>'>
+          <input type="hidden" name="${openIDProvider}"/>
+          <c:forEach var="providerButton" items="${providerButtons}">
+            <input type="submit" value='<fmt:message key="openid-login.label.ProviderLogin"><fmt:param><c:out
value="${providerButton.value}"/></fmt:param></fmt:message>' onclick="this.form.elements[0].value='${providerButton.key}';
true"/>
+          </c:forEach>
+          <input type="hidden" name="${openIDRequest}" value="${openIDLoginRequest}"/>
+        </form>
+      </c:if>
+      <c:if test="${enableOpenIDEntry == 'true'}">
+        <form method="POST" action='<portlet:actionURL/>'>
+          <span class="portlet-form-field-label"><fmt:message key="openid-login.label.OpenID"/></span>
+          <input type="text" class="portlet-form-field" size="30" name="${openIDDiscovery}"/>
+          <input type="submit" class="portlet-form-button" value='<fmt:message key="openid-login.label.Login"/>'/>
+          <input type="hidden" name="${openIDRequest}" value="${openIDLoginRequest}"/>
+        </form>
+      </c:if>
     </c:otherwise>
   </c:choose>
 </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