You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by rw...@apache.org on 2010/02/07 06:06:39 UTC
svn commit: r907378 - in /portals/jetspeed-2/portal/trunk: ./
applications/jetspeed/src/main/webapp/WEB-INF/ components/jetspeed-portal/
components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/
components/jetspeed-portal/src/main/java/org/a...
Author: rwatler
Date: Sun Feb 7 05:06:39 2010
New Revision: 907378
URL: http://svn.apache.org/viewvc?rev=907378&view=rev
Log:
JS2-1101: OpenID Login Support
Added:
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/OpenIDRelayingPartyServlet.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/filter/
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/filter/OpenIDPortalFilter.java
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDConstants.java
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDRegistrationConfiguration.java
Modified:
portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml
portals/jetspeed-2/portal/trunk/pom.xml
Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml?rev=907378&r1=907377&r2=907378&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml (original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/web.xml Sun Feb 7 05:06:39 2010
@@ -43,12 +43,19 @@
<param-value>48</param-value>
</init-param>
</filter>
-<!--
+ <!--
<filter>
<filter-name>PortalFilter</filter-name>
<filter-class>org.apache.jetspeed.login.filter.PortalFilter</filter-class>
</filter>
--->
+ -->
+ <!--
+ <filter>
+ <filter-name>OpenIDPortalFilter</filter-name>
+ <filter-class>org.apache.jetspeed.openid.filter.OpenIDPortalFilter</filter-class>
+ </filter>
+ -->
+
<filter-mapping>
<filter-name>XXSUrlAttackFilter</filter-name>
<url-pattern>/*</url-pattern>
@@ -58,12 +65,19 @@
<filter-name>staticResourceCachingFilter</filter-name>
<servlet-name>default</servlet-name>
</filter-mapping>
-<!--
+ <!--
<filter-mapping>
<filter-name>PortalFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
--->
+ -->
+ <!--
+ <filter-mapping>
+ <filter-name>OpenIDPortalFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ -->
+
<listener>
<listener-class>org.apache.jetspeed.engine.JetspeedServlet</listener-class>
</listener>
@@ -149,6 +163,76 @@
<jsp-file>/server-diag.jsp</jsp-file>
</servlet>
+ <!-- OpenID Relaying Party Servlet -->
+ <!--
+ <servlet>
+ <description>
+ OpenID Relaying Party, (RP), servlet used to return discovery
+ metadata at OpenID realm and to process authentication return
+ requests.
+ </description>
+ <display-name>OpenID Relaying Party Servlet</display-name>
+ <servlet-name>OpenIDRelayingPartyServlet</servlet-name>
+ <servlet-class>org.apache.jetspeed.openid.OpenIDRelayingPartyServlet</servlet-class>
+ <init-param>
+ <description>Discovery domain to URL mapping.</description>
+ <param-name>discovery.gmail.com</param-name>
+ <param-value>https://www.google.com/accounts/o8/id</param-value>
+ </init-param>
+ <init-param>
+ <description>Discovery domain to URL mapping.</description>
+ <param-name>discovery.yahoo.com</param-name>
+ <param-value>http://yahoo.com</param-value>
+ </init-param>
+ <init-param>
+ <description>Discovery domain to URL mapping.</description>
+ <param-name>discovery.myopenid.com</param-name>
+ <param-value>http://myopenid.com</param-value>
+ </init-param>
+ <init-param>
+ <description>Enable servlet init parameter registration configuration.</description>
+ <param-name>enableRegistrationConfig</param-name>
+ <param-value>false</param-value>
+ </init-param>
+ <init-param>
+ <description>Enable new user registration.</description>
+ <param-name>enableRegistration</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <description>Global new user template directory to be used for registration.</description>
+ <param-name>newUserTemplateDirectory</param-name>
+ <param-value>/_template/new-user/</param-value>
+ </init-param>
+ <init-param>
+ <description>Global subsite root folder to be used for registration.</description>
+ <param-name>subsiteRootFolder</param-name>
+ <param-value></param-value>
+ </init-param>
+ <init-param>
+ <description>Global roles to be assigned at registration.</description>
+ <param-name>roles</param-name>
+ <param-value>user</param-value>
+ </init-param>
+ <init-param>
+ <description>Global groups to be assigned at registration.</description>
+ <param-name>groups</param-name>
+ <param-value></param-value>
+ </init-param>
+ <init-param>
+ <description>Global profiling rule names to be assigned at registration.</description>
+ <param-name>rulesNames</param-name>
+ <param-value>page</param-value>
+ </init-param>
+ <init-param>
+ <description>Global profiling rule values to be assigned at registration.</description>
+ <param-name>rulesValues</param-name>
+ <param-value>j2</param-value>
+ </init-param>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+ -->
+
<servlet-mapping>
<servlet-name>DiagnosticsServlet</servlet-name>
<url-pattern>/diagnostics/*</url-pattern>
@@ -247,6 +331,15 @@
<url-pattern>/manager/*</url-pattern>
</servlet-mapping>
+ <!-- OpenID Relaying Party Servlet -->
+ <!--
+ <servlet-mapping>
+ <servlet-name>OpenIDRelayingPartyServlet</servlet-name>
+ <url-pattern>/openid</url-pattern>
+ <url-pattern>/openid/*</url-pattern>
+ </servlet-mapping>
+ -->
+
<!-- The Usual Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml?rev=907378&r1=907377&r2=907378&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/pom.xml Sun Feb 7 05:06:39 2010
@@ -184,6 +184,10 @@
<artifactId>jackson-xc</artifactId>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.openid4java</groupId>
+ <artifactId>openid4java-consumer</artifactId>
+ </dependency>
<!-- Test Dependencies -->
<dependency>
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/OpenIDRelayingPartyServlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/OpenIDRelayingPartyServlet.java?rev=907378&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/OpenIDRelayingPartyServlet.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/OpenIDRelayingPartyServlet.java Sun Feb 7 05:06:39 2010
@@ -0,0 +1,654 @@
+/*
+ * 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.openid;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.openid4java.OpenIDException;
+import org.openid4java.consumer.ConsumerManager;
+import org.openid4java.consumer.VerificationResult;
+import org.openid4java.discovery.DiscoveryInformation;
+import org.openid4java.discovery.Identifier;
+import org.openid4java.message.AuthRequest;
+import org.openid4java.message.AuthSuccess;
+import org.openid4java.message.ParameterList;
+import org.openid4java.message.ax.AxMessage;
+import org.openid4java.message.ax.FetchRequest;
+import org.openid4java.message.ax.FetchResponse;
+import org.openid4java.message.sreg.SRegMessage;
+import org.openid4java.message.sreg.SRegRequest;
+import org.openid4java.message.sreg.SRegResponse;
+
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.administration.PortalAdministration;
+import org.apache.jetspeed.administration.PortalAuthenticationConfiguration;
+import org.apache.jetspeed.audit.AuditActivity;
+import org.apache.jetspeed.cache.UserContentCacheManager;
+import org.apache.jetspeed.components.ComponentManager;
+import org.apache.jetspeed.openid.OpenIDRegistrationConfiguration;
+import org.apache.jetspeed.security.SecurityAttribute;
+import org.apache.jetspeed.security.SecurityAttributes;
+import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.UserManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Serves OpenID Relaying Party metadata and accepts
+ * authorization from OpenID provider.
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class OpenIDRelayingPartyServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger log = LoggerFactory.getLogger(OpenIDRelayingPartyServlet.class);
+
+ private static final String OPEN_ID_DISCOVERY_INIT_PARAM_NAME_PREFIX = "discovery.";
+
+ private static final String OPEN_ID_DISCOVERY_INFO_ATTR_NAME = "org.apache.jetspeed.openid.discoveryinfo";
+
+ private static final String USER_ATTRIBUTE_EMAIL = "user.business-info.online.email";
+ private static final String USER_ATTRIBUTE_NAME = "user.name";
+ private static final String USER_ATTRIBUTE_GIVEN_NAME = "user.name.given";
+ private static final String USER_ATTRIBUTE_FAMILY_NAME = "user.name.family";
+ private static final String USER_ATTRIBUTE_NICKNAME = "user.name.nickName";
+
+ private ConsumerManager openIDConsumerManager;
+ private UserManager portalUserManager;
+ private PortalAdministration portalAdministration;
+ private AuditActivity portalAudit;
+ private PortalAuthenticationConfiguration portalAuthenticationConfiguration;
+ private UserContentCacheManager portalUserContentCacheManager;
+ private OpenIDRegistrationConfiguration initRegistrationConfiguration;
+
+ /* (non-Javadoc)
+ * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
+ */
+ public void init(ServletConfig config) throws ServletException
+ {
+ super.init(config);
+
+ // setup OpenID
+ try
+ {
+ openIDConsumerManager = new ConsumerManager();
+ }
+ catch (OpenIDException oide)
+ {
+ throw new ServletException("Unexpected OpenID exception: "+oide, oide);
+ }
+
+ // configure portal components
+ ComponentManager cm = Jetspeed.getComponentManager();
+ portalUserManager = (UserManager)cm.getComponent("org.apache.jetspeed.security.UserManager");
+ portalAdministration = (PortalAdministration)cm.getComponent("PortalAdministration");
+ portalAudit = (AuditActivity)cm.getComponent("org.apache.jetspeed.audit.AuditActivity");
+ portalAuthenticationConfiguration = (PortalAuthenticationConfiguration)cm.getComponent("org.apache.jetspeed.administration.PortalAuthenticationConfiguration");
+ portalUserContentCacheManager = (UserContentCacheManager)cm.getComponent("userContentCacheManager");
+
+ // registration configuration parameters
+ if (Boolean.parseBoolean(config.getInitParameter(OpenIDConstants.ENABLE_REGISTRATION_CONFIG_INIT_PARAM_NAME)))
+ {
+ initRegistrationConfiguration = new OpenIDRegistrationConfiguration();
+ initRegistrationConfiguration.setEnableRegistration(config.getInitParameter(OpenIDConstants.ENABLE_REGISTRATION_INIT_PARAM_NAME));
+ initRegistrationConfiguration.setUserTemplateDirectory(config.getInitParameter(OpenIDConstants.REGISTRATION_USER_TEMPLATE_INIT_PARAM_NAME));
+ initRegistrationConfiguration.setSubsiteRootFolder(config.getInitParameter(OpenIDConstants.REGISTRATION_SUBSITE_ROOT_INIT_PARAM_NAME));
+ initRegistrationConfiguration.setRoles(config.getInitParameter(OpenIDConstants.REGISTRATION_ROLES_INIT_PARAM_NAME));
+ initRegistrationConfiguration.setGroups(config.getInitParameter(OpenIDConstants.REGISTRATION_GROUPS_INIT_PARAM_NAME));
+ initRegistrationConfiguration.setProfilerRules(config.getInitParameter(OpenIDConstants.REGISTRATION_PROFILER_RULE_NAMES_INIT_PARAM_NAME), config.getInitParameter(OpenIDConstants.REGISTRATION_PROFILER_RULE_VALUES_INIT_PARAM_NAME));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.GenericServlet#destroy()
+ */
+ public void destroy()
+ {
+ initRegistrationConfiguration = null;
+ portalUserContentCacheManager = null;
+ portalAuthenticationConfiguration = null;
+ portalAdministration = null;
+ portalUserManager = null;
+ openIDConsumerManager = null;
+ super.destroy();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ // compute absolute OpenID realm URL
+ String openIDRealmURL = openIDRealmURL(request);
+
+ // OpenID relaying party metadata request at servlet path
+ String requestPath = request.getRequestURI();
+ String servletPath = request.getContextPath()+request.getServletPath();
+ if (requestPath.equals(servletPath))
+ {
+ // return Relying Party service metadata if request matches OpenID realm
+ response.setHeader("Cache-Control", "no-cache,no-store,private");
+ response.setHeader("Pragma", "no-cache");
+ response.setHeader("Expires", "0");
+ response.setContentType("text/xml");
+ response.setStatus(HttpServletResponse.SC_OK);
+ PrintWriter out = response.getWriter();
+ out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ out.println("<Service xmlns=\"xri://$xrd*($v*2.0)\">");
+ out.println(" <Type>http://specs.openid.net/auth/2.0/return_to</Type>");
+ out.println(" <URI>"+openIDRealmURL+"</URI>");
+ out.println("</Service>");
+ out.flush();
+ out.close();
+
+ // log OpenID request
+ if (log.isDebugEnabled())
+ {
+ log.debug("OpenID realm request received, returned realm: "+openIDRealmURL);
+ }
+ }
+ else
+ {
+ // clear error state
+ request.getSession().removeAttribute(OpenIDConstants.OPEN_ID_ERROR);
+
+ // parse request from request path
+ String servletPathPrefix = servletPath+"/";
+ if (requestPath.startsWith(servletPathPrefix))
+ {
+ requestPath = requestPath.substring(servletPathPrefix.length());
+ }
+
+ // process OpenID requests
+ if (requestPath.equals(OpenIDConstants.OPEN_ID_LOGIN_REQUEST))
+ {
+ // request parameters
+ String discovery = request.getParameter(OpenIDConstants.OPEN_ID_DISCOVERY);
+ if ((discovery != null) && (discovery.length() == 0))
+ {
+ discovery = null;
+ }
+ String provider = request.getParameter(OpenIDConstants.OPEN_ID_PROVIDER);
+ if ((provider != null) && (provider.length() == 0))
+ {
+ provider = null;
+ }
+ String returnPath = request.getParameter(OpenIDConstants.OPEN_ID_RETURN);
+ if ((returnPath == null) || (returnPath.length() == 0))
+ {
+ returnPath = request.getContextPath()+"/";
+ }
+
+ boolean discoveredProvider = false;
+ try
+ {
+ // default user supplied discovery string
+ String userSuppliedDiscoveryString = discovery;
+ if ((provider == null) && (userSuppliedDiscoveryString != null) &&
+ !userSuppliedDiscoveryString.startsWith("http://") && !userSuppliedDiscoveryString.startsWith("https://") &&
+ !userSuppliedDiscoveryString.startsWith("xri://"))
+ {
+ int emailDomainSeparatorIndex = userSuppliedDiscoveryString.indexOf('@');
+ if (emailDomainSeparatorIndex != -1)
+ {
+ provider = userSuppliedDiscoveryString.substring(emailDomainSeparatorIndex+1);
+ }
+ else if (Character.isLetterOrDigit(userSuppliedDiscoveryString.charAt(0)))
+ {
+ provider = userSuppliedDiscoveryString;
+ }
+ }
+ if (provider != null)
+ {
+ String providerSuppliedDiscoveryString = getInitParameter(OPEN_ID_DISCOVERY_INIT_PARAM_NAME_PREFIX+provider);
+ if (providerSuppliedDiscoveryString != null)
+ {
+ userSuppliedDiscoveryString = providerSuppliedDiscoveryString;
+ }
+ }
+
+ // OpenID discovery
+ DiscoveryInformation discovered = null;
+ try
+ {
+ if (userSuppliedDiscoveryString != null)
+ {
+ List discoveries = openIDConsumerManager.discover(userSuppliedDiscoveryString);
+ if ((discoveries != null) && !discoveries.isEmpty())
+ {
+ discovered = openIDConsumerManager.associate(discoveries);
+ }
+ }
+ }
+ catch (OpenIDException oide)
+ {
+ throw new RuntimeException("Unexpected OpenID discovery exception: "+oide, oide);
+ }
+ if (discovered == null)
+ {
+ throw new RuntimeException("No OpenID provider discovered");
+ }
+ discoveredProvider = true;
+
+ // log OpenID provider
+ if (log.isDebugEnabled())
+ {
+ log.debug("Discovered OpenID provider endpoint: "+discovered.getOPEndpoint());
+ }
+
+ // save OpenID provider in session
+ request.getSession().setAttribute(OPEN_ID_DISCOVERY_INFO_ATTR_NAME, discovered);
+
+ // create OpenID authentication request and redirect
+ String authReturnToURL = openIDRealmURL+"/"+OpenIDConstants.OPEN_ID_AUTHENTICATED_REQUEST+"?"+OpenIDConstants.OPEN_ID_RETURN+"="+returnPath;
+ String authRedirectURL = null;
+ try
+ {
+ // authentication request
+ AuthRequest authRequest = openIDConsumerManager.authenticate(discovered, authReturnToURL, openIDRealmURL);
+ // request attribute exchange data
+ FetchRequest axRequest = FetchRequest.createFetchRequest();
+ axRequest.addAttribute("email", "http://axschema.org/contact/email", true);
+ axRequest.addAttribute("fullname", "http://axschema.org/namePerson", true);
+ axRequest.addAttribute("lastname", "http://axschema.org/namePerson/last", true);
+ axRequest.addAttribute("firstname", "http://axschema.org/namePerson/first", true);
+ axRequest.addAttribute("nickname", "http://axschema.org/namePerson/friendly", true);
+ authRequest.addExtension(axRequest);
+ // request simple registration data
+ SRegRequest sregRequest = SRegRequest.createFetchRequest();
+ sregRequest.addAttribute("email", true);
+ sregRequest.addAttribute("fullname", true);
+ sregRequest.addAttribute("nickname", true);
+ authRequest.addExtension(sregRequest);
+ // authentication redirect
+ authRedirectURL = authRequest.getDestinationUrl(true);
+ }
+ catch (OpenIDException oide)
+ {
+ throw new RuntimeException("Unexpected OpenID authentication request exception: "+oide, oide);
+ }
+ response.sendRedirect(authRedirectURL);
+
+ // log authentication redirect
+ if (log.isDebugEnabled())
+ {
+ log.debug("OpenID authentication redirect: "+authRedirectURL);
+ }
+ }
+ catch (Exception e)
+ {
+ // log error and redirect back to portal with error
+ // set as session attribute
+ log.error("OpenID login error: "+e, e);
+ request.getSession().setAttribute(OpenIDConstants.OPEN_ID_ERROR, (!discoveredProvider ? OpenIDConstants.OPEN_ID_ERROR_NO_PROVIDER : OpenIDConstants.OPEN_ID_ERROR_CANNOT_AUTH));
+ response.sendRedirect(returnPath);
+ }
+ }
+ else if (requestPath.equals(OpenIDConstants.OPEN_ID_AUTHENTICATED_REQUEST))
+ {
+ // request parameters
+ String returnPath = request.getParameter(OpenIDConstants.OPEN_ID_RETURN);
+ if ((returnPath == null) || (returnPath.length() == 0))
+ {
+ returnPath = request.getContextPath()+"/";
+ }
+
+ // session parameters
+ OpenIDRegistrationConfiguration portalRegistrationConfiguration = (OpenIDRegistrationConfiguration)request.getSession().getAttribute(OpenIDConstants.OPEN_ID_REGISTRATION_CONFIGURATION);
+ if (portalRegistrationConfiguration != null)
+ {
+ request.getSession().removeAttribute(OpenIDConstants.OPEN_ID_REGISTRATION_CONFIGURATION);
+ }
+
+ boolean authenticatedByProvider = false;
+ boolean portalUserExists = false;
+ try
+ {
+ // request parameters
+ ParameterList authParams = new ParameterList(request.getParameterMap());
+
+ // retrieve OpenID provider from session
+ DiscoveryInformation discovered = (DiscoveryInformation)request.getSession().getAttribute(OPEN_ID_DISCOVERY_INFO_ATTR_NAME);
+
+ // reconstruct the authenticated request URL
+ StringBuffer authRequestURLBuffer = request.getRequestURL();
+ String authRequestQueryString = request.getQueryString();
+ if ((authRequestQueryString != null) && (authRequestQueryString.length() > 0))
+ {
+ authRequestURLBuffer.append('?').append(authRequestQueryString);
+ }
+ String authRequestURL = authRequestURLBuffer.toString();
+
+ // verify the authenticated request
+ VerificationResult verification = null;
+ try
+ {
+ verification = openIDConsumerManager.verify(authRequestURL, authParams, discovered);
+ }
+ catch (OpenIDException oide)
+ {
+ throw new RuntimeException("Unexpected OpenID authenticated verification exception: "+oide, oide);
+ }
+
+ // extract identifier from verified authenticated request
+ Identifier verifiedIdentifier = verification.getVerifiedId();
+ if (verifiedIdentifier == null)
+ {
+ throw new RuntimeException("Verified identifier unavailable for authenticated OpenID login");
+ }
+ authenticatedByProvider = true;
+
+ String email = null;
+ String firstName = null;
+ String lastName = null;
+ String nickname = null;
+ String fullName = null;
+ // extract requested attribute exchange data
+ AuthSuccess authResponse = (AuthSuccess)verification.getAuthResponse();
+ if (authResponse.hasExtension(AxMessage.OPENID_NS_AX))
+ {
+ try
+ {
+ FetchResponse axResponse = (FetchResponse)authResponse.getExtension(AxMessage.OPENID_NS_AX);
+ email = axResponse.getAttributeValue("email");
+ fullName = axResponse.getAttributeValue("fullname");
+ firstName = axResponse.getAttributeValue("firstname");
+ lastName = axResponse.getAttributeValue("lastname");
+ nickname = axResponse.getAttributeValue("nickname");
+ }
+ catch (OpenIDException oide)
+ {
+ throw new RuntimeException("Unexpected OpenID authenticated attribute exchange fetch exception: "+oide, oide);
+ }
+ }
+ // extract requested simple registration data
+ if (authResponse.hasExtension(SRegMessage.OPENID_NS_SREG))
+ {
+ try
+ {
+ SRegResponse sregResponse = (SRegResponse)authResponse.getExtension(SRegMessage.OPENID_NS_SREG);
+ email = sregResponse.getAttributeValue("email");
+ fullName = sregResponse.getAttributeValue("fullname");
+ nickname = sregResponse.getAttributeValue("nickname");
+ }
+ catch (OpenIDException oide)
+ {
+ throw new RuntimeException("Unexpected OpenID authenticated simple registration fetch exception: "+oide, oide);
+ }
+ }
+
+ // log authenticated request
+ if (log.isDebugEnabled())
+ {
+ log.debug("Authenticated OpenID verified identifier: "+verifiedIdentifier.getIdentifier()+", email="+email+", fullname="+fullName+", firstname="+firstName+", lastname="+lastName+", nickname="+nickname);
+ }
+
+ // validate and default attributes
+ if (email == null)
+ {
+ throw new RuntimeException("OpenID email attribute required for portal login");
+ }
+ if (fullName != null)
+ {
+ String [] fullNames = fullName.split("\\s");
+ if ((firstName == null) && (fullNames.length > 1))
+ {
+ firstName = fullNames[0];
+ }
+ if (lastName == null)
+ {
+ lastName = ((fullNames.length > 1) ? fullNames[fullNames.length-1] : fullName);
+ }
+ }
+ if ((nickname == null) && (firstName != null))
+ {
+ nickname = firstName;
+ }
+ if (nickname == null)
+ {
+ int emailDomainIndex = email.indexOf('@');
+ if (emailDomainIndex != -1)
+ {
+ nickname = email.substring(0, emailDomainIndex);
+ }
+ }
+ // construct portal user attributes
+ Map<String,String> userAttributes = new HashMap<String,String>();
+ userAttributes.put(USER_ATTRIBUTE_EMAIL, email);
+ userAttributes.put(USER_ATTRIBUTE_NAME, email);
+ if (firstName != null)
+ {
+ userAttributes.put(USER_ATTRIBUTE_GIVEN_NAME, firstName);
+ }
+ if (lastName != null)
+ {
+ userAttributes.put(USER_ATTRIBUTE_FAMILY_NAME, lastName);
+ }
+ if (nickname != null)
+ {
+ userAttributes.put(USER_ATTRIBUTE_NICKNAME, nickname);
+ }
+
+ // login to portal using email, creating portal
+ // user if necessary
+ User portalUser = null;
+ try
+ {
+ portalUser = portalUserManager.getUser(email);
+ }
+ catch (Exception e)
+ {
+ }
+
+ // create portal user if not found
+ if (portalUser == null)
+ {
+ try
+ {
+ // select portal registration configuration and
+ // register portal user
+ String logConfiguration = "none";
+ if (portalRegistrationConfiguration != null)
+ {
+ portalRegistrationConfiguration.merge(initRegistrationConfiguration);
+ logConfiguration = "session, (from login)";
+ }
+ else if (initRegistrationConfiguration != null)
+ {
+ portalRegistrationConfiguration = initRegistrationConfiguration;
+ logConfiguration = "init params";
+ }
+ if ((portalRegistrationConfiguration == null) || portalRegistrationConfiguration.isEnableRegistration())
+ {
+ if (portalRegistrationConfiguration != null)
+ {
+ portalAdministration.registerUser(email, null,
+ portalRegistrationConfiguration.getRoles(),
+ portalRegistrationConfiguration.getGroups(),
+ userAttributes,
+ portalRegistrationConfiguration.getProfilerRules(),
+ portalRegistrationConfiguration.getUserTemplateDirectory(),
+ portalRegistrationConfiguration.getSubsiteRootFolder());
+ }
+ else
+ {
+ portalAdministration.registerUser(email, null, null, null, userAttributes, null, null, null);
+ }
+ portalUser = portalUserManager.getUser(email);
+
+ // log registered user
+ if (log.isDebugEnabled())
+ {
+ if (portalUser != null)
+ {
+ log.debug("OpenID login registered portal user: "+portalUser.getName()+", configuration: "+logConfiguration);
+ }
+ else
+ {
+ log.debug("OpenID login unregistered portal user, (registration failed): "+email+", configuration: "+logConfiguration);
+ }
+ }
+ }
+ else
+ {
+ // log unregistered user
+ if (log.isDebugEnabled())
+ {
+ log.debug("OpenID login unregistered portal user, (registration disabled): "+email+", configuration: "+logConfiguration);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to register portal user: "+email);
+ }
+ }
+
+ // login registered portal user
+ if (portalUser == null)
+ {
+ throw new RuntimeException("Missing registered portal user: "+email);
+ }
+ portalUserExists = true;
+
+ // update portal user attributes
+ boolean portalUserAttributesUpdated = false;
+ SecurityAttributes portalUserAttributes = portalUser.getSecurityAttributes();
+ for (Map.Entry<String,String> attribute : userAttributes.entrySet())
+ {
+ String name = attribute.getKey();
+ String value = attribute.getValue();
+ SecurityAttribute userAttribute = portalUserAttributes.getAttribute(name, true);
+ if (!value.equals(userAttribute.getStringValue()))
+ {
+ userAttribute.setStringValue(value);
+ portalUserAttributesUpdated = true;
+ }
+ }
+ if (portalUserAttributesUpdated)
+ {
+ try
+ {
+ portalUserManager.updateUser(portalUser);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to update attributes for user: "+portalUser.getName());
+ }
+ }
+
+ Subject subject = null;
+ try
+ {
+ // create subject for portal user
+ subject = portalUserManager.getSubject(portalUser);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to login portal user: "+portalUser.getName());
+ }
+ // create/reset portal session
+ if (portalAuthenticationConfiguration.isCreateNewSessionOnLogin())
+ {
+ request.getSession().invalidate();
+ request.getSession(true);
+ }
+ else
+ {
+ portalUserContentCacheManager.evictUserContentCache(portalUser.getName(), request.getSession().getId());
+ }
+ // configure portal session with logged in session
+ request.getSession().setAttribute(PortalReservedParameters.SESSION_KEY_SUBJECT, subject);
+
+ // log/audit portal user login
+ portalAudit.logUserActivity(portalUser.getName(), request.getRemoteAddr(), AuditActivity.AUTHENTICATION_SUCCESS, "OpenIDRelayingPartyServlet");
+
+ // redirect back to portal
+ response.sendRedirect(returnPath);
+ }
+ catch (Exception e)
+ {
+ // log error and redirect back to portal
+ log.error("OpenID login error: "+e, e);
+ request.getSession().setAttribute(OpenIDConstants.OPEN_ID_ERROR, (!authenticatedByProvider ? OpenIDConstants.OPEN_ID_ERROR_NOT_AUTH : (!portalUserExists ? OpenIDConstants.OPEN_ID_ERROR_NO_PORTAL_USER : OpenIDConstants.OPEN_ID_ERROR_CANNOT_LOGIN)));
+ response.sendRedirect(returnPath);
+ }
+ }
+ else if (requestPath.equals(OpenIDConstants.OPEN_ID_LOGOUT_REQUEST))
+ {
+ // request parameters
+ String returnPath = request.getParameter(OpenIDConstants.OPEN_ID_RETURN);
+ if ((returnPath == null) || (returnPath.length() == 0))
+ {
+ returnPath = request.getContextPath()+"/";
+ }
+
+ // clear portal session
+ request.getSession().invalidate();
+
+ // redirect back to portal
+ response.sendRedirect(returnPath);
+ }
+ else
+ {
+ throw new ServletException("Unexpected OpenID request: "+requestPath);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public final void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ doGet(request, response);
+ }
+
+ /**
+ * Compute OpenID realm URL from request.
+ *
+ * @param request servlet request
+ * @return OpenID realm URL
+ */
+ private String openIDRealmURL(HttpServletRequest request)
+ {
+ StringBuilder openIDRealmURLBuilder = new StringBuilder(request.isSecure() ? "https://" : "http://");
+ openIDRealmURLBuilder.append(request.getServerName());
+ if ((request.isSecure() && (request.getServerPort() != 443)) || (!request.isSecure() && (request.getServerPort() != 80)))
+ {
+ openIDRealmURLBuilder.append(':').append(request.getServerPort());
+ }
+ openIDRealmURLBuilder.append(request.getContextPath()+request.getServletPath());
+ return openIDRealmURLBuilder.toString();
+ }
+}
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/filter/OpenIDPortalFilter.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/filter/OpenIDPortalFilter.java?rev=907378&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/filter/OpenIDPortalFilter.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/openid/filter/OpenIDPortalFilter.java Sun Feb 7 05:06:39 2010
@@ -0,0 +1,98 @@
+/*
+ * 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.openid.filter;
+
+import java.io.IOException;
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.administration.PortalConfiguration;
+import org.apache.jetspeed.login.filter.PortalRequestWrapper;
+import org.apache.jetspeed.security.SubjectHelper;
+import org.apache.jetspeed.security.User;
+
+/**
+ * Propagates OpenID portal subject from session to request.
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class OpenIDPortalFilter implements Filter
+{
+ protected String guest = "guest";
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
+ */
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ PortalConfiguration config = Jetspeed.getConfiguration();
+ if (config != null)
+ {
+ guest = config.getString("default.user.principal");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#destroy()
+ */
+ public void destroy()
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException
+ {
+ // portal request filter
+ if (servletRequest instanceof HttpServletRequest)
+ {
+ // retrieve current subject from session and wrap portal
+ // request to support principal access
+ HttpServletRequest request = (HttpServletRequest)servletRequest;
+ Subject subject = (Subject)request.getSession().getAttribute(PortalReservedParameters.SESSION_KEY_SUBJECT);
+ if (subject != null)
+ {
+ Principal principal = SubjectHelper.getPrincipal(subject, User.class);
+ if ((principal == null) || !principal.getName().equals(guest))
+ {
+ servletRequest = new PortalRequestWrapper(request, subject, principal);
+ }
+ }
+
+ // tag request as filtered
+ servletRequest.setAttribute(PortalReservedParameters.PORTAL_FILTER_ATTRIBUTE, "true");
+ }
+
+ // continue request filter processing
+ if (filterChain != null)
+ {
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
+ }
+}
Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDConstants.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDConstants.java?rev=907378&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDConstants.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDConstants.java Sun Feb 7 05:06:39 2010
@@ -0,0 +1,51 @@
+/*
+ * 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.openid;
+
+/**
+ * OpenID login portlet and relaying party servlet constants.
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public final class OpenIDConstants
+{
+ public final static String OPEN_ID_DISCOVERY = "org.apache.jetspeed.openid.discovery";
+ public final static String OPEN_ID_PROVIDER = "org.apache.jetspeed.openid.provider";
+ public final static String OPEN_ID_RETURN = "org.apache.jetspeed.openid.return";
+ public final static String OPEN_ID_REQUEST = "org.apache.jetspeed.openid.request";
+ public final static String OPEN_ID_LOGIN_REQUEST = "login";
+ public final static String OPEN_ID_AUTHENTICATED_REQUEST = "authed";
+ public final static String OPEN_ID_LOGOUT_REQUEST = "logout";
+ public final static String OPEN_ID_ERROR = "org.apache.jetspeed.openid.error";
+ public final static String OPEN_ID_ERROR_NO_PROVIDER = "ErrorNoProvider";
+ public final static String OPEN_ID_ERROR_CANNOT_AUTH = "ErrorCannotAuthenticate";
+ public final static String OPEN_ID_ERROR_NOT_AUTH = "ErrorNotAuthenticated";
+ public final static String OPEN_ID_ERROR_NO_PORTAL_USER = "ErrorNoPortaUser";
+ public final static String OPEN_ID_ERROR_CANNOT_LOGIN = "ErrorCannotLogin";
+
+ public static final String OPEN_ID_REGISTRATION_CONFIGURATION = "org.apache.jetspeed.openid.registration.configuration";
+
+ public static final String ENABLE_REGISTRATION_CONFIG_INIT_PARAM_NAME = "enableRegistrationConfig";
+ public static final String ENABLE_REGISTRATION_INIT_PARAM_NAME = "enableRegistration";
+ public static final String REGISTRATION_USER_TEMPLATE_INIT_PARAM_NAME = "newUserTemplateDirectory";
+ public static final String REGISTRATION_SUBSITE_ROOT_INIT_PARAM_NAME = "subsiteRootFolder";
+ public static final String REGISTRATION_ROLES_INIT_PARAM_NAME = "roles";
+ public static final String REGISTRATION_GROUPS_INIT_PARAM_NAME = "groups";
+ public static final String REGISTRATION_PROFILER_RULE_NAMES_INIT_PARAM_NAME = "rulesNames";
+ public static final String REGISTRATION_PROFILER_RULE_VALUES_INIT_PARAM_NAME = "rulesValues";
+}
Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDRegistrationConfiguration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDRegistrationConfiguration.java?rev=907378&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDRegistrationConfiguration.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/openid/OpenIDRegistrationConfiguration.java Sun Feb 7 05:06:39 2010
@@ -0,0 +1,245 @@
+/*
+ * 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.openid;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * OpenID login registration configuration.
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class OpenIDRegistrationConfiguration implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ transient private boolean enableRegistration;
+ transient private String userTemplateDirectory;
+ transient private String subsiteRootFolder;
+ transient private List<String> roles;
+ transient private List<String> groups;
+ transient private Map<String,String> profilerRules;
+
+ /**
+ * Merge in default configuration.
+ *
+ * @param defaults default configuration
+ */
+ public void merge(OpenIDRegistrationConfiguration defaults)
+ {
+ if (defaults != null)
+ {
+ if (userTemplateDirectory == null)
+ {
+ userTemplateDirectory = defaults.userTemplateDirectory;
+ }
+ if (subsiteRootFolder == null)
+ {
+ subsiteRootFolder = defaults.subsiteRootFolder;
+ }
+ if (roles == null)
+ {
+ roles = defaults.roles;
+ }
+ if (groups == null)
+ {
+ groups = defaults.groups;
+ }
+ if (profilerRules == null)
+ {
+ profilerRules = defaults.profilerRules;
+ }
+ }
+ }
+
+ /**
+ * @return the enableRegistration
+ */
+ public boolean isEnableRegistration()
+ {
+ return enableRegistration;
+ }
+
+ /**
+ * @param enableRegistration the enableRegistration to set
+ */
+ public void setEnableRegistration(boolean enableRegistration)
+ {
+ this.enableRegistration = enableRegistration;
+ }
+
+ /**
+ * @param enableRegistration the enableRegistration to set
+ */
+ public void setEnableRegistration(String enableRegistration)
+ {
+ this.enableRegistration = Boolean.parseBoolean(enableRegistration);
+ }
+
+ /**
+ * @return the userTemplateDirectory
+ */
+ public String getUserTemplateDirectory()
+ {
+ return userTemplateDirectory;
+ }
+
+ /**
+ * @param userTemplateDirectory the userTemplateDirectory to set
+ */
+ public void setUserTemplateDirectory(String userTemplateDirectory)
+ {
+ this.userTemplateDirectory = userTemplateDirectory;
+ }
+
+ /**
+ * @return the subsiteRootFolder
+ */
+ public String getSubsiteRootFolder()
+ {
+ return subsiteRootFolder;
+ }
+
+ /**
+ * @param subsiteRootFolder the subsiteRootFolder to set
+ */
+ public void setSubsiteRootFolder(String subsiteRootFolder)
+ {
+ this.subsiteRootFolder = subsiteRootFolder;
+ }
+
+ /**
+ * @return the roles
+ */
+ public List<String> getRoles()
+ {
+ return roles;
+ }
+
+ /**
+ * @param roles the roles to set
+ */
+ public void setRoles(List<String> roles)
+ {
+ this.roles = roles;
+ }
+
+ /**
+ * @param roles the roles to set
+ */
+ public void setRoles(String roles)
+ {
+ this.roles = parseParameterList(roles);
+ }
+
+ /**
+ * @return the groups
+ */
+ public List<String> getGroups()
+ {
+ return groups;
+ }
+
+ /**
+ * @param groups the groups to set
+ */
+ public void setGroups(List<String> groups)
+ {
+ this.groups = groups;
+ }
+
+ /**
+ * @param groups the groups to set
+ */
+ public void setGroups(String groups)
+ {
+ this.groups = parseParameterList(groups);
+ }
+
+ /**
+ * @return the profilerRules
+ */
+ public Map<String, String> getProfilerRules()
+ {
+ return profilerRules;
+ }
+
+ /**
+ * @param profilerRules the profilerRules to set
+ */
+ public void setProfilerRules(Map<String, String> profilerRules)
+ {
+ this.profilerRules = profilerRules;
+ }
+
+ /**
+ * @param profilerRuleNames the profiler rule names to set
+ * @param profilerRuleValues the profiler rule values to set
+ */
+ public void setProfilerRules(List<String> profilerRuleNames, List<String> profilerRuleValues)
+ {
+ if ((profilerRuleNames != null) && (profilerRuleValues != null))
+ {
+ profilerRules = new HashMap<String,String>();
+ Iterator<String> namesIter = profilerRuleNames.iterator();
+ Iterator<String> valuesIter = profilerRuleValues.iterator();
+ while (namesIter.hasNext() && valuesIter.hasNext())
+ {
+ profilerRules.put(namesIter.next(), valuesIter.next());
+ }
+ }
+ else
+ {
+ profilerRules = null;
+ }
+ }
+
+ /**
+ * @param profilerRuleNames the profiler rule names to set
+ * @param profilerRuleValues the profiler rule values to set
+ */
+ public void setProfilerRules(String profilerRuleNames, String profilerRuleValues)
+ {
+ setProfilerRules(parseParameterList(profilerRuleNames), parseParameterList(profilerRuleValues));
+ }
+
+ /**
+ * Parse parameter list.
+ *
+ * @param parameterList parameter name
+ * @return parameter list
+ */
+ public static List<String> parseParameterList(String parameterList)
+ {
+ if (parameterList != null)
+ {
+ String [] params = parameterList.split("[,]");
+ for (int i = 0; (i < params.length); i++)
+ {
+ params[i] = params[i].trim();
+ }
+ return Arrays.asList(params);
+ }
+ return null;
+ }
+}
Modified: portals/jetspeed-2/portal/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/pom.xml?rev=907378&r1=907377&r2=907378&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/pom.xml Sun Feb 7 05:06:39 2010
@@ -291,7 +291,7 @@
<org.apache.portals.applications.apa-rss.version>1.0</org.apache.portals.applications.apa-rss.version>
<org.apache.portals.applications.apa-webcontent.version>1.1-SNAPSHOT</org.apache.portals.applications.apa-webcontent.version>
<org.apache.portals.applications.apa-dbbrowser.version>1.0</org.apache.portals.applications.apa-dbbrowser.version>
-
+ <org.openid4java.version>0.9.5</org.openid4java.version>
<oro.version>2.0.8</oro.version>
<portals.portlet2-api-spec.version>1.0</portals.portlet2-api-spec.version>
<regexp.version>1.2</regexp.version>
@@ -306,7 +306,7 @@
<velocity-tools.version>1.3</velocity-tools.version>
<velocity.version>1.6.3</velocity.version>
<xalan.version>2.4.1</xalan.version>
- <xerces.version>2.3.0</xerces.version>
+ <xerces.version>2.8.1</xerces.version>
<xml-apis.version>2.0.2</xml-apis.version>
<asm.version>2.2</asm.version>
<ccpp.version>1.0</ccpp.version>
@@ -1393,6 +1393,19 @@
<scope>provided</scope>
</dependency>
+ <!-- OpenID -->
+ <dependency>
+ <groupId>org.openid4java</groupId>
+ <artifactId>openid4java-consumer</artifactId>
+ <version>${org.openid4java.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
</dependencies>
</dependencyManagement>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org