You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by zh...@apache.org on 2011/04/01 02:29:38 UTC

svn commit: r1087520 [3/35] - in /incubator/rave/donations/ogce-gadget-container: ./ config/ config/shindig-1.1-BETA5/ config/shindig-2.0.0/ db-cleaner/ examples/ examples/src/ examples/src/main/ examples/src/main/java/ examples/src/main/java/cgl/ exam...

Added: incubator/rave/donations/ogce-gadget-container/config/shindig-2.0.0/shindig.properties
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/config/shindig-2.0.0/shindig.properties?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/config/shindig-2.0.0/shindig.properties (added)
+++ incubator/rave/donations/ogce-gadget-container/config/shindig-2.0.0/shindig.properties Fri Apr  1 00:29:22 2011
@@ -0,0 +1,149 @@
+# 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.
+
+# Location of feature manifests (comma separated)
+shindig.features.default=res://features/features.txt
+
+# Location of container configurations (comma separated)
+shindig.containers.default=res://containers/default/container.js
+
+# A file containing blacklisted gadgets.
+shindig.blacklist.file=
+
+### Inbound OAuth support
+# The URL base to use for full OAuth support (three-legged)
+shindig.oauth.base-url=/oauth/
+shindig.oauth.authorize-action=/WEB-INF/authorize.jsp
+
+### Outbound OAuth support
+shindig.signing.state-key=
+shindig.signing.key-name=
+shindig.signing.key-file=
+shindig.signing.global-callback-url=@gadget.server.base@/gadgets/oauthcallback
+shindig.signing.enable-signed-callbacks=true
+
+# Set to true if you want to allow the use of 3-legged OAuth tokens when viewer != owner.
+# This setting is not recommeneded for pages that allow user-controlled javascript, since
+# that javascript could be used to make unauthorized requests on behalf of the viewer of the page
+shindig.signing.viewer-access-tokens-enabled=false
+
+# If enabled here, configuration values can be found in container configuration files.
+shindig.locked-domain.enabled=false
+
+# TODO: This needs to be moved to container configuration.
+shindig.content-rewrite.only-allow-excludes=false
+shindig.content-rewrite.include-urls=.*
+shindig.content-rewrite.exclude-urls=
+shindig.content-rewrite.include-tags=body,embed,img,input,link,script,style
+shindig.content-rewrite.expires=86400
+shindig.content-rewrite.proxy-url=/gadgets/proxy?container=default&url=
+shindig.content-rewrite.concat-url=/gadgets/concat?container=default&
+shindig.content-rewrite.enable-split-js-concat=true
+
+#
+# Default set of forced libs to allow for better caching
+#
+# NOTE: setting this causes the EndToEnd test to fail the opensocial-templates test
+shindig.gadget-rewrite.default-forced-libs=core:rpc
+#shindig.gadget-rewrite.default-forced-libs=
+
+#
+# Allow supported JavaScript features required by a gadget to be externalized on demand
+shindig.gadget-rewrite.externalize-feature-libs=false
+
+# Configuration for image rewriter
+shindig.image-rewrite.max-inmem-bytes = 1048576
+shindig.image-rewrite.max-palette-size = 256
+shindig.image-rewrite.allow-jpeg-conversion = true
+shindig.image-rewrite.jpeg-compression = 0.75
+shindig.image-rewrite.min-threshold-bytes = 200
+
+# Configuration for the os:Flash tag
+shindig.flash.min-version = 9.0.115
+
+# Configuration for template rewriter
+shindig.template-rewrite.extension-tag-namespace=http://ns.opensocial.org/2009/extensions
+
+# These values provide default TTLs for HTTP responses that don't use caching headers.
+shindig.cache.http.defaultTtl=3600000
+shindig.cache.http.negativeCacheTtl=60000
+
+# A default refresh interval for XML files, since there is no natural way for developers to
+# specify this value, and most HTTP responses don't include good cache control headers.
+shindig.cache.xml.refreshInterval=300000
+
+# Add entries in the form shindig.cache.lru.<name>.capacity to specify capacities for different
+# caches when using the LruCacheProvider.
+# It is highly recommended that the EhCache implementation be used instead of the LRU cache.
+shindig.cache.lru.default.capacity=1000
+shindig.cache.lru.expressions.capacity=1000
+shindig.cache.lru.gadgetSpecs.capacity=1000
+shindig.cache.lru.messageBundles.capacity=1000
+shindig.cache.lru.httpResponses.capacity=10000
+
+# The location of the EhCache configuration file.
+shindig.cache.ehcache.config=res://org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml
+
+# True to enable JMX integration with cache stats
+shindig.cache.ehcache.jmx.enabled=true
+
+# true to enable JMX stats.
+shindig.cache.ehcache.jmx.stats=true
+
+# true to skip expensive encoding detection.
+# if true, will only attempt to validate utf-8. Assumes all other encodings are ISO-8859-1.
+shindig.http.fast-encoding-detection=true
+
+# Configuration for the HttpFetcher
+# Connection timeout, in milliseconds, for requests.
+shindig.http.client.connection-timeout-ms=5000
+
+# Maximum size, in bytes, of the object we fetched, 0 == no limit
+shindig.http.client.max-object-size-bytes=0
+
+# Strict-mode parsing for proxy and concat URIs ensures that the authority/host and path
+# for the URIs match precisely what is found in the container config for it. This is
+# useful where statistics and traffic routing patterns, typically in large installations,
+# key on hostname (and occasionally path). Enforcing this does come at the cost that
+# mismatches break, which in turn mandates that URI generation always happen in consistent
+# fashion, ie. by the class itself or tightly controlled code.
+shindig.uri.proxy.use-strict-parsing=false
+shindig.uri.concat.use-strict-parsing=false
+
+# Host:port of the proxy to use while fetching urls. Leave blank if proxy is
+# not to be used.
+org.apache.shindig.gadgets.http.basicHttpFetcherProxy=
+
+org.apache.shindig.serviceExpirationDurationMinutes=60
+
+#
+# Older versions of shindig used 'data' in the json-rpc response format
+# The spec calls for using 'result' instead, however to avoid breakage we
+# allow you to set it back to the old way here
+#
+# valid values are
+#  result  - new form
+#  data    - old broken form
+#  both    - return both fields for full compatibility
+#
+shindig.json-rpc.result-field=result
+
+# Remap "Internal server error"s received from the basicHttpFetcherProxy server to
+# "Bad Gateway error"s, so that it is clear to the user that the proxy server is
+# the one that threw the exception.
+shindig.accelerate.remapInternalServerError=true
+shindig.proxy.remapInternalServerError=true

Added: incubator/rave/donations/ogce-gadget-container/config/site.properties.template
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/config/site.properties.template?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/config/site.properties.template (added)
+++ incubator/rave/donations/ogce-gadget-container/config/site.properties.template Fri Apr  1 00:29:22 2011
@@ -0,0 +1 @@
+portal.server.ip=localhost

Added: incubator/rave/donations/ogce-gadget-container/db-cleaner/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/db-cleaner/pom.xml?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/db-cleaner/pom.xml (added)
+++ incubator/rave/donations/ogce-gadget-container/db-cleaner/pom.xml Fri Apr  1 00:29:22 2011
@@ -0,0 +1,44 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>cgl.shindig</groupId>
+  <artifactId>db-cleaner</artifactId>
+  <packaging>pom</packaging>
+  <version>1.0</version>
+  <name>third-party-gadgets</name>
+  <parent>
+    <groupId>cgl.shindig</groupId>
+    <artifactId>gadget-container-main-driver</artifactId>
+    <version>0.1</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <properties>
+    <main.basedir>${project.parent.basedir}</main.basedir>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>Clean</id>
+            <phase>clean</phase>
+            <configuration>
+              <tasks>
+					 <echo message="Cleaning database ${hibernate.h2.basedir}"/>
+                <delete failonerror="true">
+                  <fileset dir="${hibernate.h2.basedir}"/>
+                </delete>
+              </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>       
+      </plugin>
+    </plugins>
+  </build>
+</project>
+

Added: incubator/rave/donations/ogce-gadget-container/examples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/examples/pom.xml?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/examples/pom.xml (added)
+++ incubator/rave/donations/ogce-gadget-container/examples/pom.xml Fri Apr  1 00:29:22 2011
@@ -0,0 +1,48 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>cgl.shindig.webapp</groupId>
+  <artifactId>ishindig-examples</artifactId>
+  <packaging>jar</packaging>
+  <version>0.1</version>
+  <name>ishindig java examples</name>
+
+  <!--
+  <parent>
+    <groupId>cgl.shindig</groupId>
+    <artifactId>gadget-container-main-driver</artifactId>
+    <version>0.1</version>
+    <relativePath>..</relativePath>
+  </parent>
+  -->
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.json</groupId>
+      <artifactId>json</artifactId>
+      <version>20070829</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>1.4</version>
+    </dependency>
+  </dependencies>
+
+</project>

Added: incubator/rave/donations/ogce-gadget-container/examples/src/main/java/cgl/shindig/example/VerifyCallbackExample.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/examples/src/main/java/cgl/shindig/example/VerifyCallbackExample.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/examples/src/main/java/cgl/shindig/example/VerifyCallbackExample.java (added)
+++ incubator/rave/donations/ogce-gadget-container/examples/src/main/java/cgl/shindig/example/VerifyCallbackExample.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,81 @@
+package cgl.shindig.example;
+/*
+ *
+ * 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.
+ *
+ */
+
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.commons.io.IOUtils;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * 
+ * @author gerald
+ *
+ */
+/**
+ * Sample response from VerifyCallback.
+ * {"result":[{"valid":true,"cert":
+ * "-----BEGIN CERTIFICATE-----\ncontent\n-----END CERTIFICATE-----\n-----BEGIN RSA PRIVATE KEY-----\ncontent\n-----END RSA PRIVATE KEY-----\n"
+ * ,"email":"zhguo@indiana.edu","userid":"testuser2"},{"valid":false,"email":
+ * "testuser","userid":""}],"status":"succ"}
+ */
+public class VerifyCallbackExample {
+    
+    private String callbackResult = "";
+    
+    private void parse (String response) throws JSONException {
+        JSONObject jsonObj = new JSONObject(response);
+        String status = jsonObj.getString("status");
+        if (!status.equalsIgnoreCase("succ")) {
+            return;
+        }
+        
+        JSONArray results = jsonObj.getJSONArray("result");
+        for(int i = 0; i < results.length(); ++i) {
+            JSONObject result = (JSONObject)results.get(i);
+            if (result.has("cert")) {
+                String credStr = result.getString("cert");
+                String email = result.getString("email");
+                credStr = credStr.replaceAll("\\\\n", "\n");
+                
+                System.out.println("email:" + email + "\ncredential:\n" + credStr + "\n");
+            }
+        }
+    }
+    
+    public static void main (String []args) throws FileNotFoundException, IOException, JSONException {
+        if (args.length < 1) {
+            System.out.println("Missing argument");
+            return;
+        }
+        String inputFile = args[0];
+        System.out.println("Input file is " + inputFile);
+        String content = IOUtils.toString(new FileInputStream(inputFile));
+        
+        VerifyCallbackExample example = new VerifyCallbackExample();
+        example.parse(content);
+    }
+}

Added: incubator/rave/donations/ogce-gadget-container/gadget-migration/gadget-migration.js
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/gadget-migration/gadget-migration.js?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/gadget-migration/gadget-migration.js (added)
+++ incubator/rave/donations/ogce-gadget-container/gadget-migration/gadget-migration.js Fri Apr  1 00:29:22 2011
@@ -0,0 +1,83 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+
+function _IG_AdjustIFrameHeight() {
+    gadgets.window.adjustHeight();
+}
+
+function _IG_SetTitle(title) {
+    gadgets.window.setTitle(title);
+}
+
+_IG_Prefs = gadgets.Prefs;
+
+function _IG_FetchFeedAsJSON(url, func, num_entries, get_summaries) {
+    var params = {};
+    // var params = opt_params || {};
+    
+    params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.FEED;
+    if (num_entries != null)
+        params[gadgets.io.RequestParameters.NUM_ENTRIES] = num_entries;
+    if (get_summaries != null)
+        params[gadgets.io.RequestParameters.GET_SUMMARIES] = get_summaries;
+
+    function newfunc(obj) {
+        func(obj.data);
+    }
+    gadgets.io.makeRequest(url, newfunc, params);
+}
+
+function _IG_FetchXmlContent(url, func, opt_params) {
+    var params = {};
+    if (opt_params != null && opt_params.refreshInterval != null)
+        params[gadgets.io.RequestParameters.REFRESH_INTERVAL] = opt_params.refreshInterval;
+    params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.DOM;
+    function newfunc(obj) {
+        func(obj.data);
+    }
+    gadgets.io.makeRequest(url, newfunc, params);
+}
+
+function _IG_RegisterOnloadHandler(func) {
+    gadgets.util.registerOnLoadHandler.apply(this, arguments);
+}
+
+function _IG_GetCachedUrl(url, opt_params) {
+    var params = {};
+    if (opt_params != null && opt_params.refreshInterval != null)
+        params["REFRESH_INTERVAL"] = opt_params.refreshInterval;
+    return gadgets.io.getProxyUrl(url, params);
+}
+
+function _IG_GetImageUrl(url, opt_params) {
+    if (opt_params != null)
+        return _IG_GetCachedUrl(url, opt_params);
+    else
+        return _IG_GetCachedUrl(url);
+}
+
+function _IG_GetImage(url) {
+    var img = document.createElement("img");
+    img.src = gadgets.io.getProxyUrl(url);
+    return img;
+}
+

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/pom.xml?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/pom.xml (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/pom.xml Fri Apr  1 00:29:22 2011
@@ -0,0 +1,720 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <!-- the version of maven's project object model -->
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>cgl.shindig.webapp</groupId>
+  <artifactId>ishindig-webapp</artifactId>
+  <packaging>war</packaging>
+  <version>0.1</version>
+  <name>ishindig webapp</name>
+
+  <parent>
+    <groupId>cgl.shindig</groupId>
+    <artifactId>gadget-container-main-driver</artifactId>
+    <version>0.1</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <properties>
+    <main.basedir>${project.parent.basedir}</main.basedir>
+
+    <tomcat.bin.perm>755</tomcat.bin.perm>
+
+    <!-- specify the root path of your j2ee app. Note: trailing '/' must be included. -->
+
+    <site.ishindig.base>${site.baseurl}/${project.artifactId}</site.ishindig.base>
+    <site.ishindig.base.insecure>${site.baseurl.insecure}/${project.artifactId}</site.ishindig.base.insecure>
+
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+		  <!-- A Maven+JS testing framework.  However, we haven't implemented any real tests using this yet-->
+        <groupId>de.berlios.jsunit</groupId>
+        <artifactId>jsunit-maven2-plugin</artifactId>
+        <version>1.3</version>
+        <dependencies>
+          <dependency>
+            <groupId>rhino</groupId>
+            <artifactId>js</artifactId>
+            <version>1.7R1</version>
+          </dependency>
+        </dependencies>
+        <executions>
+          <execution>
+            <configuration>
+              <sourceDirectory>${basedir}/src/main/webapp/www/js</sourceDirectory>
+              <sources>
+                <source>../../../../test/webapp/www/js/mocks/env.js</source>
+                <source>../../../../test/webapp/www/js/mocks/window.js</source>
+                <source>../../../../test/webapp/www/js/mocks/xhr.js</source>
+                <source>../../../../test/webapp/www/js/lib/testutils.js</source>
+              </sources>
+              <testSourceDirectory>${basedir}/src/test/webapp/www/js</testSourceDirectory>
+              <testSuites>
+                <testSuite>
+                  <name>JsTests</name>
+                  <type>TESTCASES</type>
+                  <includes>
+                    <include>mocks/*.js</include>
+                    <include>dummytest.js</include>
+                  </includes>
+                </testSuite>
+              </testSuites>
+            </configuration>
+            <goals>
+              <goal>jsunit-test</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>Rename-related-files</id>
+            <phase>generate-resources</phase>
+            <configuration>
+              <tasks>
+                <copy overwrite="true" filtering="true" failonerror="true"
+                  tofile="${basedir}/src/main/webapp/WEB-INF/web.xml">
+                  <fileset
+                    file="${basedir}/src/main/webapp/WEB-INF/web.${hibernate.database}.xml"/>
+                </copy>
+                <copy overwrite="true" filtering="true" failonerror="false"
+                  tofile="${basedir}/src/main/resources/hibernate.cfg.xml">
+                  <fileset
+                    file="${basedir}/src/main/resources/hibernate.cfg.${hibernate.database}.xml"/>
+                </copy>
+              </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+          <!--
+          <execution>
+            <id>deleted-related-files</id>
+            <phase>package</phase>
+            <configuration>
+              <tasks>
+                <delete file="${basedir}/src/main/webapp/WEB-INF/web.xml"></delete>
+                <delete file="${basedir}/src/main/resources/hibernate.cfg.xml"></delete>
+              </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+          -->
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <webResources>
+				<!--
+					 These resources will be filtered so that ${} properties in the specified files
+					 will be replaced with appropriate values from the conf/ishindig.properties file.
+					 These property files ultimately are set in the ogce-all top level pom file.
+				  -->
+            <resource>
+              <!-- this is relative to the pom.xml directory -->
+              <directory>${basedir}/src/main/webapp/www</directory>
+              <!-- <directory>${basedir}/target/${pom.artifactId}-${pom.version}/www</directory> -->
+              <targetPath>www</targetPath>
+              <filtering>true</filtering>
+              <includes>
+                <include>sign.jsp</include>
+                <include>userinfo.jsp</include>
+                <!-- <include>layout-manage.opt.js</include> -->
+                <include>ishindig.html</include>
+                <!-- <include>js/tabui-components.opt.js</include> -->
+                <include>js/util.js</include>
+                <include>js/gadgetui-components.js</include>
+              </includes>
+            </resource>
+
+            <resource>
+              <!-- this is relative to the pom.xml directory -->
+              <directory>${basedir}/src/main/webapp/WEB-INF</directory>
+              <targetPath>WEB-INF</targetPath>
+              <filtering>true</filtering>
+              <includes>
+                <include>web.xml</include>
+                <include>web.h2.xml</include>
+                <include>web.mysql.xml</include>
+              </includes>
+            </resource>
+
+            <resource>
+              <directory>${basedir}/src/main/resources</directory>
+              <targetPath>WEB-INF/classes</targetPath>
+              <filtering>true</filtering>
+            </resource>
+
+            <resource>
+              <directory>${basedir}/src/main/java/cgl/shindig/usermanage/servlet</directory>
+              <targetPath>WEB-INF/classes/cgl/shindig/usermanage/servlet</targetPath>
+              <filtering>true</filtering>
+              <includes>
+                <include>defaultLayout.json</include>
+              </includes>
+            </resource>
+
+            <resource>
+              <directory>${basedir}/src/main/java/cgl/shindig/config</directory>
+              <targetPath>WEB-INF/classes</targetPath>
+              <filtering>false</filtering>
+              <includes>
+                <include>portal.xml</include>
+              </includes>
+            </resource>
+
+            <resource>
+              <directory>${basedir}/src/main/webapp/www</directory>
+              <targetPath>www</targetPath>
+              <filtering>true</filtering>
+              <includes>
+                <include>facebook_share.html</include>
+              </includes>
+            </resource>
+
+          </webResources>
+          <archiveClasses>true</archiveClasses>
+        </configuration>
+      </plugin>
+    </plugins>
+
+  </build>
+
+  <dependencies>
+
+    <!-- jars provided by gadget-sharedlib in run time -->
+    <dependency>
+      <groupId>proxymanager-api</groupId>
+      <artifactId>proxymanager-api</artifactId>
+      <version>4.2</version>
+      <scope>${scope.sharedlib}</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.portlet</groupId>
+      <artifactId>portlet-api</artifactId>
+      <version>1.0</version>
+      <scope>${scope.sharedlib}</scope>
+    </dependency>  
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.3</version>
+      <type>jar</type>
+      <scope>${scope.sharedlib}</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1.1</version>
+      <scope>${scope.sharedlib}</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-fileupload</groupId>
+      <artifactId>commons-fileupload</artifactId>
+      <version>1.1</version>
+      <type>jar</type>
+      <scope>${scope.sharedlib}</scope>
+    </dependency> 
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>3.1</version>
+      <scope>${scope.sharedlib}</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-digester</groupId>
+      <artifactId>commons-digester</artifactId>
+      <version>1.8</version>
+      <scope>${scope.sharedlib}</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-el</groupId>
+      <artifactId>commons-el</artifactId>
+      <version>1.0</version>
+      <scope>${scope.sharedlib}</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.4</version>
+      <scope>${scope.sharedlib}</scope>
+    </dependency>
+    <!-- end. jars provided by gadget-sharedlib -->
+
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>catalina</artifactId>
+      <version>${portal.tomcat.version}</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-server</artifactId>
+      <version>1.1.4.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.json</groupId>
+      <artifactId>json</artifactId>
+      <version>20070829</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.h2database</groupId>
+      <artifactId>h2</artifactId>
+      <version>1.1.119</version>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.collections</groupId>
+      <artifactId>google-collections</artifactId>
+      <version>0.8</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <!-- Endorsed packages -->
+    <dependency>
+      <groupId>xalan</groupId>
+      <artifactId>xalan</artifactId>
+      <version>2.6.0</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>dom3-xml-apis</artifactId>
+      <version>1.UNKNOWN</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>dom3-xercesImpl</artifactId>
+      <version>1.UNKNOWN</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.5</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit-addons</groupId>
+      <artifactId>junit-addons</artifactId>
+      <version>1.4</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- hibernate and its dependents-->
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <version>3.3.0.SP1</version>
+      <artifactId>hibernate</artifactId>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>c3p0</groupId>
+      <artifactId>c3p0</artifactId>
+      <version>0.9.1.2</version>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>dom4j</groupId>
+      <artifactId>dom4j</artifactId>
+      <version>1.6.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>antlr</groupId>
+      <artifactId>antlr</artifactId>
+      <version>2.7.6</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.transaction</groupId>
+      <artifactId>jta</artifactId>
+      <version>1.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>javassist</artifactId>
+      <version>3.4.ga</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <!-- following jars are needed to support servlet/jsp -->
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <version>${portal.tomcat.version}</version>
+      <artifactId>annotations-api</artifactId>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>${portal.tomcat.version}</version>
+      <scope>provided</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>jstl</groupId>
+      <version>1.2</version>
+      <artifactId>jstl</artifactId>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+      <version>5.1.6</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.activation</groupId>
+      <artifactId>activation</artifactId>
+      <version>1.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <!--
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.4</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+    -->
+
+    <dependency>
+      <groupId>commons-beanutils</groupId>
+      <artifactId>commons-beanutils</artifactId>
+      <version>1.7.0</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>1.4</version>
+    </dependency>
+
+    <!--
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.3</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+    -->
+
+    <!--
+    <dependency>
+      <groupId>commons-digester</groupId>
+      <artifactId>commons-digester</artifactId>
+      <version>1.8</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+    -->
+
+    <dependency>
+      <groupId>commons-discovery</groupId>
+      <artifactId>commons-discovery</artifactId>
+      <version>0.4</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-configuration</groupId>
+      <artifactId>commons-configuration</artifactId>
+      <version>1.6</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <version>3.0.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <!--
+    <dependency>
+      <groupId>commons-fileupload</groupId>
+      <version>1.2.1</version>
+      <artifactId>commons-fileupload</artifactId>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+    -->
+
+    <!--
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+    -->
+
+    <!-- openid4java and its dependent  -->
+    <dependency>
+      <groupId>org.openid4java</groupId>
+      <version>0.9.4</version>
+      <artifactId>openid4java</artifactId>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>com.ibm.icu</groupId>
+      <artifactId>icu4j</artifactId>
+      <version>4.0.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-api</artifactId>
+      <version>1.2.2</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+    <dependency>
+      <groupId>org.openxri</groupId>
+      <artifactId>openxri-client</artifactId>
+      <version>1.0.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+      <exclusions>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>xml-apis</groupId>
+          <artifactId>xml-apis</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <dependency>
+      <groupId>org.openxri</groupId>
+      <artifactId>openxri-syntax</artifactId>
+      <version>1.0.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <!--
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>xercesImpl</artifactId>
+      <version>2.8.1</version>
+    </dependency>
+    -->
+
+    <dependency>
+      <groupId>xml-security</groupId>
+      <artifactId>xmlsec</artifactId>
+      <version>1.3.0</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>org.htmlparser</groupId>
+      <artifactId>htmlparser</artifactId>
+      <version>1.6</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>org.eclipse.higgins</groupId>
+      <artifactId>higgins-configuration-api</artifactId>
+      <version>SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.higgins</groupId>
+      <artifactId>higgins-sts-api</artifactId>
+      <version>SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.higgins</groupId>
+      <artifactId>higgins-sts-common</artifactId>
+      <version>SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.higgins</groupId>
+      <artifactId>higgins-sts-server-token-handler</artifactId>
+      <version>SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.higgins</groupId>
+      <artifactId>higgins-sts-spi</artifactId>
+      <version>SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>jug</groupId>
+      <artifactId>jug</artifactId>
+      <version>1.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax-api</artifactId>
+      <version>1.0.1</version>
+      <scope>compile</scope>
+      <type>jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.code.guice</groupId>
+      <artifactId>guice</artifactId>
+      <version>2.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.shindig</groupId>
+      <artifactId>shindig</artifactId>
+      <version>2.0.0</version>
+      <type>pom</type>
+      <scope>provided</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-simple</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+
+  <profiles>
+    <!-- This is the default profile.  It builds everything into the OGCE deployment structure. -->
+    <profile>
+      <id>war.and.deploy</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>Clean ${project.artifactId} webapp</id>
+                <phase>clean</phase>
+                <configuration>
+                  <tasks>         
+                    <echo message="Clean up ${catalina.home}/webapps/${project.artifactId}"/>
+                    <delete failonerror="false"
+									 file="${catalina.home}/webapps/${project.artifactId}.${project.packaging}"/>
+                    <delete failonerror="false"
+									 file="${catalina.home}/webapps/${project.artifactId}"/>
+                  </tasks>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+
+              <execution>
+                <id>Install ${project.artifactId} webapp</id>
+                <phase>install</phase>
+                <configuration>
+                  <tasks>
+                    <echo message="Installing to ${catalina.home}/webapps/"/>
+                    <copy overwrite="true" filtering="false" failonerror="false"
+                      tofile="${catalina.home}/webapps/${project.artifactId}.${project.packaging}">
+                      <fileset file="${basedir}/target/${project.artifactId}-${project.version}.${project.packaging}"/>
+                    </copy>
+                  </tasks>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+            </executions>       
+          </plugin>
+
+        </plugins>
+      </build>
+    </profile>
+
+  </profiles>
+
+</project>

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/GuiceServletContextListener.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/GuiceServletContextListener.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/GuiceServletContextListener.java (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/GuiceServletContextListener.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,91 @@
+/*
+ * 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 cgl.shindig;
+
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextListener;
+
+import com.google.common.collect.Lists;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.Stage;
+import com.google.inject.tools.jmx.Manager;
+
+/**
+ * Creates a global guice injector and stores it in a servlet context parameter
+ * for injecting servlets.
+ */
+public class GuiceServletContextListener implements ServletContextListener {
+  public static final String INJECTOR_ATTRIBUTE = "guice-injector";
+  public static final String MODULES_ATTRIBUTE = "guice-modules";
+  private boolean jmxInitialized = false;
+
+  public static Injector injector = null;
+
+  public void contextInitialized(ServletContextEvent event) {
+    ServletContext context = event.getServletContext();
+    String moduleNames = context.getInitParameter(MODULES_ATTRIBUTE);
+    List<Module> modules = Lists.newLinkedList();
+    if (moduleNames != null) {
+      for (String moduleName : moduleNames.split(":")) {
+        try {
+          moduleName = moduleName.trim();
+          if (moduleName.length() > 0) {
+            modules.add((Module)Class.forName(moduleName).newInstance());
+          }
+        } catch (InstantiationException e) {
+          throw new RuntimeException(e);
+        } catch (ClassNotFoundException e) {
+          throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+          throw new RuntimeException(e);
+        }
+      }
+    }
+    Injector injector = Guice.createInjector(Stage.PRODUCTION, modules);
+
+    // This is an ugly workaround for the situation where servletContext
+    // cannot be obtained.
+    this.injector = injector;
+
+    context.setAttribute(INJECTOR_ATTRIBUTE, injector);
+
+    try {
+      if (!jmxInitialized) {
+        Manager.manage("ShindigGuiceContext", injector);
+        jmxInitialized = true;
+      }
+    } catch (Exception e) {
+      // Ignore errors
+    }
+  }
+
+  public void contextDestroyed(ServletContextEvent event) {
+    ServletContext context = event.getServletContext();
+    context.removeAttribute(INJECTOR_ATTRIBUTE);
+    this.injector = null;
+  }
+}
+

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/H2DbStarter.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/H2DbStarter.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/H2DbStarter.java (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/H2DbStarter.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2004-2008 H2 Group. Multiple-Licensed under the H2 License,
+ * Version 1.0, and under the Eclipse Public License, Version 1.0
+ * (http://h2database.com/html/license.html).
+ * Initial Developer: H2 Group
+ */
+package cgl.shindig;
+/*
+ *
+ * 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.
+ *
+ */
+
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.h2.tools.Server;
+import org.h2.util.StringUtils;
+
+/**
+ * This class can be used to start the H2 TCP server (or other H2 servers, for
+ * example the PG server) inside a web application container such as Tomcat or
+ * Jetty. It can also open a database connection.
+ */
+public class H2DbStarter implements ServletContextListener {
+
+    private Connection conn;
+    private Server server;
+
+    private void createAdminUserTable() throws SQLException {
+        String sqlstr = "" +
+            " CREATE TABLE IF NOT EXISTS adminuser" +
+            " (id 		INTEGER  NOT NULL AUTO_INCREMENT PRIMARY KEY," +
+            " screenname VARCHAR(128) NOT NULL UNIQUE," +
+            " password	VARCHAR(50) NOT NULL" +
+            " );";
+        if (conn != null) {
+            Statement stmt = conn.createStatement();
+            stmt.execute(sqlstr);
+        }
+    }
+
+    private void createUserTable() throws SQLException {
+        String sqlstr = "" +
+            " CREATE TABLE IF NOT EXISTS user" +
+            " (id 		INTEGER  NOT NULL AUTO_INCREMENT PRIMARY KEY," +
+            " firstname 	VARCHAR(50) NOT NULL," +
+            " lastname	VARCHAR(50) NOT NULL," +
+            " screenname VARCHAR(32) NOT NULL UNIQUE," +
+            " nickname   VARCHAR(32)," +
+            " openid     VARCHAR(128)," +
+            " password	VARCHAR(50) NOT NULL," +
+            " dateofbirth DATE," +
+            " language   VARCHAR(10)," +
+            " timezone   VARCHAR(10)," +
+            " email      VARCHAR(64)," +
+            " gender     CHAR(1)," +
+            " zipcode    VARCHAR(16)" +
+            " );";
+        if (conn != null) {
+            Statement stmt = conn.createStatement();
+            stmt.execute(sqlstr);
+        }
+    }
+    private void createLayoutTable() throws SQLException {
+        String sqlstr = "CREATE TABLE IF NOT EXISTS layout" +
+            " (id 		INTEGER  NOT NULL AUTO_INCREMENT PRIMARY KEY," +
+            " screenname CHAR(128) NOT NULL UNIQUE," +
+            " layout     TEXT(1024000)" +
+            ");";
+        if (conn != null) {
+            Statement stmt = conn.createStatement();
+            stmt.execute(sqlstr);
+        }
+    }
+
+    public void createUser() throws SQLException {
+        String userName = "portal_admin", password = "admin_pass";
+        String sqlstr = "create user if not exists " + userName +
+            " password '" + password + "'";
+        String sqlstr1 = "grant all on user to " + userName + ";";
+        String sqlstr2 = "grant all on layout to " + userName + ";";
+        String sqlstr3 = "grant all on adminuser to " + userName + ";";
+        if (conn != null) {
+            Statement stmt = conn.createStatement();
+            stmt.execute(sqlstr);
+            stmt = conn.createStatement();
+            stmt.execute(sqlstr1);
+            stmt = conn.createStatement();
+            stmt.execute(sqlstr2);
+            stmt = conn.createStatement();
+            stmt.execute(sqlstr3);
+        }
+    }
+
+    public void contextInitialized(ServletContextEvent servletContextEvent) {
+        try {
+            org.h2.Driver.load();
+
+            // This will get the setting from a context-param in web.xml if defined:
+            ServletContext servletContext = servletContextEvent.getServletContext();
+            String url = getParameter(servletContext, "db.url", "jdbc:h2:~/test");
+            String user = getParameter(servletContext, "db.user", "sa");
+            String password = getParameter(servletContext, "db.password", "sa");
+
+            conn = DriverManager.getConnection(url, user, password);
+            // servletContext.setAttribute("connection", conn);
+
+            createUserTable();
+            createAdminUserTable();
+            createLayoutTable();
+            createUser();
+            conn.close();
+
+            // Start the server if configured to do so
+            String serverParams = getParameter(servletContext, "db.tcpServer", null);
+            if (serverParams != null) {
+                String[] params = StringUtils.arraySplit(serverParams, ' ', true);
+                server = Server.createTcpServer(params);
+                server.start();
+            }
+            // To access the database in server mode, use the database URL:
+            // jdbc:h2:tcp://localhost/~/test
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private String getParameter(ServletContext servletContext, String key, String defaultValue) {
+        String value = servletContext.getInitParameter(key);
+        return value == null ? defaultValue : value;
+    }
+
+    /**
+     * Get the connection.
+     *
+     * @return the connection
+     */
+    public Connection getConnection() {
+        return conn;
+    }
+
+    public void contextDestroyed(ServletContextEvent servletContextEvent) {
+        if (server != null) {
+            server.stop();
+            server = null;
+        }
+        try {
+            conn.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
+

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/InjectedServlet.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/InjectedServlet.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/InjectedServlet.java (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/InjectedServlet.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,61 @@
+/*
+ * 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 cgl.shindig;
+
+import com.google.inject.Injector;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.UnavailableException;
+import javax.servlet.http.HttpServlet;
+
+/**
+ * Supports DI for servlets. Can't handle ctor injection since
+ * the servlet spec requires configuration being done in init().
+ */
+public abstract class InjectedServlet extends HttpServlet {
+    protected Injector injector;
+
+    @Override public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        ServletContext context = config.getServletContext();
+        injector = (Injector)
+            context.getAttribute(GuiceServletContextListener.INJECTOR_ATTRIBUTE);
+        if (injector == null) {
+            throw new UnavailableException(
+                    "Guice Injector not found! Make sure you registered " +
+                    GuiceServletContextListener.class.getName() + " as a listener");
+        }
+        injector.injectMembers(this);
+    }
+
+    public static <T> T getInstance (Class<T> clazz, ServletContext context)
+            throws ServletException {
+        Injector injector = (Injector)
+            context.getAttribute(GuiceServletContextListener.INJECTOR_ATTRIBUTE);
+        if (injector == null) {
+            throw new UnavailableException(
+                    "Guice Injector not found! Make sure you registered " +
+                    GuiceServletContextListener.class.getName() + " as a listener");
+        }
+        return injector.getInstance(clazz);
+    }
+}
+

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/Portal.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/Portal.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/Portal.java (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/Portal.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,104 @@
+package cgl.shindig;
+/*
+ *
+ * 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.
+ *
+ */
+
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.security.auth.Subject;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import cgl.shindig.config.ConfigurationException;
+import cgl.shindig.config.PortalConfig;
+import cgl.shindig.security.AuthContext;
+import cgl.shindig.security.Credentials;
+import cgl.shindig.security.DefaultSecurityManager;
+import cgl.shindig.usermanage.UserManager;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
+public class Portal {
+    private static final Logger log = LoggerFactory.getLogger(Portal.class);
+
+    public boolean initialized = false;
+
+    private PortalConfig portalConfig;
+    private DefaultSecurityManager securityManager;
+    private AuthContext authContext;
+    private UserManager userManager;
+
+    public void setSecurityManager(DefaultSecurityManager securityManager) {
+        this.securityManager=securityManager;
+    }
+
+    @Inject
+    public Portal () throws ConfigurationException, IOException, Exception {
+        String dir = new File(".").getCanonicalPath();
+        portalConfig = PortalConfig.install(new File(dir));
+
+        securityManager = new DefaultSecurityManager();
+        securityManager.init(this);
+
+        userManager = securityManager.getUserManager();
+    }
+
+    public PortalConfig getConfig () {
+        return portalConfig;
+    }
+
+    public DefaultSecurityManager getSecurityManager(){
+        return this.securityManager;
+    }
+
+    public boolean login (Credentials creds, Subject subject) {
+        try {
+            if (creds == null) {
+                log.error("Passed credentials is null.");
+                return false;
+            }
+            if (subject == null)
+            	subject = new Subject();
+
+            AuthContext authContext = securityManager.getAuthContext(creds, userManager, subject);
+            authContext.login();
+            return true;
+        } catch(Exception ex) {
+            return false;
+        }
+    }
+
+    /**
+     * get the value of authContext
+     * @return the value of authContext
+     */
+    public AuthContext getAuthContext(){
+        return this.authContext;
+    }
+    public UserManager getUserManager(){
+        return this.userManager;
+    }
+}
+

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/SSLOSGFilter.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/SSLOSGFilter.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/SSLOSGFilter.java (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/SSLOSGFilter.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,148 @@
+package cgl.shindig;
+/*
+ *
+ * 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.
+ *
+ */
+
+
+import java.io.IOException;
+import java.security.cert.X509Certificate;
+
+import javax.security.auth.x500.X500Principal;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+
+public final class SSLOSGFilter implements Filter {
+
+    private FilterConfig filterConfig = null;
+    private static String osgDNConfigAttr = "osgdn";
+    public static String osgDNAttr = null;
+    public static boolean enabled = false;
+
+    private void log(String msg) {
+        if (filterConfig != null)
+            filterConfig.getServletContext().log(msg);
+    }
+
+    public void init(FilterConfig filterConfig) 
+            throws ServletException {
+        this.filterConfig = filterConfig;
+
+        if (filterConfig.getInitParameter("enable") != null) {
+            enabled = Boolean.parseBoolean(filterConfig.getInitParameter("enable"));
+        }
+
+        log("Filter '" + this.getClass().getName() + " is " + 
+                (enabled ?"enabled.":"disabled."));
+
+        if (!enabled)
+            return;
+
+        if (filterConfig.getInitParameter(osgDNConfigAttr) == null ||
+            filterConfig.getInitParameter(osgDNConfigAttr).trim().length() == 0) {
+            throw new ServletException("Configuration parameter '" +
+                    osgDNConfigAttr + "' is not correctly specified for filter '" +
+                    this.getClass().getName() + "'");
+        } else {
+            osgDNAttr = filterConfig.getInitParameter(osgDNConfigAttr);
+            log("config value for '" + osgDNConfigAttr + "' is '" + osgDNAttr + "'");
+        }
+    }
+
+    public void destroy() {
+        this.filterConfig = null;
+    }
+
+    public void doFilter(ServletRequest request,
+            ServletResponse response, FilterChain chain) 
+            throws IOException, ServletException {
+        if (filterConfig == null) // TODO: should be more sophisticated?
+            return;
+
+        if (enabled) {
+            log("Entering OSG SSL Filter");
+            Object obj = request.getAttribute("javax.servlet.request.X509Certificate");
+            if (request.isSecure() && obj != null) {
+                log("Got a client cert");
+                X509Certificate certs[] = (X509Certificate[])obj;
+                log("Client cert chain length is " + certs.length);
+                if (certs.length > 0) {
+                    X509Certificate clientCert = certs[0];
+                    X500Principal principal = clientCert.getSubjectX500Principal();
+                    String dn = cvtDN2OSG(principal);
+                    request.setAttribute(osgDNAttr, dn);
+                    log("dn is:" + dn);
+                }
+            }
+
+            log("Leaving OSG SSL Filter");
+        }
+
+        chain.doFilter(request, response);
+    }
+
+    /**
+     * target format: /DC=org/DC=doegrids/OU=People/CN=Zhenhua Guo 917851
+     */
+    private String cvtDN2OSG (X500Principal principal) {
+        // RFC 2253 sample: CN=Zhenhua Guo 917851,OU=People,DC=doegrids,DC=org
+        // System.out.println("RFC 1779:" + principal.getName("RFC1779"));
+        // System.out.println("RFC 2253:" + principal.getName("RFC2253"));
+        // System.out.println("CANONICAL:" + principal.getName("CANONICAL"));
+        String rfc2253dn = principal.getName("RFC2253");
+        String parts[] = rfc2253dn.split(",");
+        String reverseParts[] = new String[parts.length];
+        for (int i = 0; i < parts.length; ++i) {
+            reverseParts[i] = parts[parts.length-1-i];
+        }
+
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < parts.length; ++i) {
+            sb.append("/" + reverseParts[i].trim());
+        }
+        return sb.toString();
+
+        /**
+        String ou=null, cn=null, dc1=null, dc2=null;
+        for (int i = 0; i < parts.length; ++i) {
+            String part = parts[i];
+            int idx = part.indexOf("=");
+            String key = part.substring(0, idx).trim();
+            String value = part.substring(idx+1).trim();
+            if (key.equalsIgnoreCase("CN"))
+                cn = value;
+            if (key.equalsIgnoreCase("OU"))
+                ou = value;
+            if (key.equalsIgnoreCase("DC")) {
+                if (dc1 == null)
+                    dc1 = value;
+                else
+                    dc2 = value;
+            }
+        }
+        return "/DC="+dc2+"/DC="+dc1+"/OU="+ou+"/CN="+cn;
+        */
+    }
+}
+

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/BaseHttpServlet.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/BaseHttpServlet.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/BaseHttpServlet.java (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/BaseHttpServlet.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,60 @@
+/**
+ * This class adds attributes to the request before redirection.
+ */
+package cgl.shindig.common;
+/*
+ *
+ * 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.
+ *
+ */
+
+
+import java.util.logging.Logger;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import cgl.shindig.usermanage.servlet.OpenIdAuth;
+
+/**
+ * @author gerald
+ *
+ */
+public class BaseHttpServlet extends HttpServlet {
+	protected Logger logger = Logger.getLogger(this.getClass().getSimpleName());
+	
+    
+    public static void markSigninState (HttpServletRequest request, int state) {
+    	request.setAttribute("action", "signin");
+    	request.setAttribute("state", new Integer(state));
+    }
+    
+    public static void markSignupState (HttpServletRequest request, int state) {
+    	request.setAttribute("action", "signup");
+    	request.setAttribute("state", new Integer(state));
+    }
+    
+    public static void markOpenID (HttpServletRequest request, String openid) {
+    	if (Util.isEmpty(openid))
+    		return;
+    	HttpSession session = request.getSession();
+        session.setAttribute(OpenIdAuth.OPENID_ID_SESSION, openid);
+        request.setAttribute(OpenIdAuth.OPENID_CLAIMED_ID_SESSION, openid);
+    }
+}

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/DefaultUriParser.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/DefaultUriParser.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/DefaultUriParser.java (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/DefaultUriParser.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,41 @@
+/*
+ * 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 cgl.shindig.common;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Uri parser using java.net.URI as its basis, enforcing RFC 2396 restrictions.
+ */
+public class DefaultUriParser implements UriParser {
+  /**
+   * Produces a new Uri from a text representation.
+   *
+   * @param text The text uri.
+   * @return A new Uri, parsed into components.
+   */
+  public Uri parse(String text) {
+    try {
+      return Uri.fromJavaUri(new URI(text));
+    } catch (URISyntaxException e) {
+      throw new IllegalArgumentException(e);
+    }
+  }
+}

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/JSONHelper.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/JSONHelper.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/JSONHelper.java (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/JSONHelper.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,55 @@
+package cgl.shindig.common;
+/*
+ *
+ * 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.
+ *
+ */
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class JSONHelper {
+    
+    /** 
+     * Convert a JSONObject to a Map. 
+     * Note: we don't carry out recursive conversion.
+     * 
+     * @param jsonObj 
+     * @return 
+     */
+    public static Map<String, Object> jsonObj2Map(JSONObject jsonObj) 
+            throws JSONException{
+        Iterator it = jsonObj.keys();
+        Map<String, Object> map = new HashMap<String, Object>();
+        while (it.hasNext()) {
+            Object keyObj = it.next();
+            if (jsonObj.isNull(keyObj.toString())) {
+                map.put(keyObj.toString(), null);
+            } else {
+                map.put(keyObj.toString(), jsonObj.get(keyObj.toString()));
+            }
+        }
+        return map;
+    }
+}
+

Added: incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/ServletUtil.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/ServletUtil.java?rev=1087520&view=auto
==============================================================================
--- incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/ServletUtil.java (added)
+++ incubator/rave/donations/ogce-gadget-container/ishindig-webapp/src/main/java/cgl/shindig/common/ServletUtil.java Fri Apr  1 00:29:22 2011
@@ -0,0 +1,65 @@
+/**
+ * 
+ */
+package cgl.shindig.common;
+/*
+ *
+ * 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.
+ *
+ */
+
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author gerald
+ *
+ */
+public class ServletUtil {
+	public static String getContextPath(ServletConfig config) {
+	    /* Generally, no easy way to get context path in Servlet.init method. However, a new function named
+	     * ServletContext.getContextPath() is added in servlet-2.5_MR2.
+	     * See this site for details:
+	     * http://jcp.org/aboutJava/communityprocess/maintenance/jsr154/servlet-2.5_MR2.html.
+	     *
+	     * To make it work with old tomcats (old servlet implementations), I use a workaround.
+	     * I use ServletContext.getRealPath("/") and retrieve the last part in the path.
+	     */
+		String contextPath = "";
+	    ServletContext context = config.getServletContext();
+	    String realpath = context.getRealPath("/");
+	    while( realpath.length() != 0 && realpath.charAt(realpath.length()-1) == '/' )
+	        realpath = realpath.substring(0, realpath.length()-1);
+	    int index = realpath.lastIndexOf("/");
+	    if( index != -1 ){
+	        contextPath = realpath.substring(index+1);
+	    }
+	    return contextPath;
+	}
+	
+	public static String getBaseURL(HttpServletRequest request) {
+		String addr = request.getScheme()+"://"+request.getServerName();
+		int port = request.getServerPort();
+		if( !(port == 80 && request.getScheme().compareTo("http") == 0) ){
+			addr += ":"+port;
+		}
+		return addr + "/";
+	}
+}