rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jc...@apache.org
Subject svn commit: r1156800 - in /incubator/rave/trunk: rave-portal/src/main/webapp/script/ rave-shindig/src/main/java/org/apache/shindig/auth/ rave-shindig/src/main/resources/ rave-shindig/src/main/webapp/WEB-INF/classes/containers/default/
Date Thu, 11 Aug 2011 20:12:20 GMT
Author: jcian
Date: Thu Aug 11 20:12:20 2011
New Revision: 1156800

URL: http://svn.apache.org/viewvc?rev=1156800&view=rev
Log:
Checking in code to complete RAVE-152 and also finish most of RAVE-150 (except for removing
the hacks put in place while we wait for Shindig patches to be applied/available in a formal
release).  Note that I've added a copy of the default container.js file from Shindig to our
Shindig overlay -- this was required because we need to be able add and override a few values
in it (compare it to the base revision I just checked in to see what we've changed).

https://issues.apache.org/jira/browse/RAVE-152
https://issues.apache.org/jira/browse/RAVE-150

Added:
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/auth/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/auth/ClasspathAwareDefaultSecurityTokenCodec.java
    incubator/rave/trunk/rave-shindig/src/main/resources/security_token_encryption_key.txt
      - copied unchanged from r1156293, incubator/rave/trunk/rave-portal/src/main/resources/security_token_encryption_key.txt
Modified:
    incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_opensocial.js
    incubator/rave/trunk/rave-shindig/src/main/resources/modules-context.xml
    incubator/rave/trunk/rave-shindig/src/main/webapp/WEB-INF/classes/containers/default/container.js

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_opensocial.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_opensocial.js?rev=1156800&r1=1156799&r2=1156800&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_opensocial.js (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_opensocial.js Thu Aug 11
20:12:20 2011
@@ -81,15 +81,31 @@ rave.opensocial = rave.opensocial || (fu
     function validateAndRenderGadget(gadget) {
         var validationResult = validateMetadata(gadget.metadata);
         if (validationResult.valid) {
-            //TODO: Submit a patch to Shindig common container to expose the backing service
or add a method to push cached items  into the container config
+            //Put our gadget metadata into the form that the common container is expecting
             var commonContainerMetadataWrapper = {};
             commonContainerMetadataWrapper[gadget.widgetUrl] = gadget.metadata;
-            container.service_.addGadgetMetadatas(commonContainerMetadataWrapper, null);
+
+            //Put our gadget security token data into the form that the common container
is expecting
+            var commonContainerTokenData = {};
+            commonContainerTokenData[osapi.container.TokenResponse.TOKEN] = gadget.securityToken;
+            commonContainerTokenData[osapi.container.MetadataResponse.RESPONSE_TIME_MS] =
new Date().getTime();
+            var commonContainerTokenWrapper = {};
+            commonContainerTokenWrapper[gadget.widgetUrl] = commonContainerTokenData;
+
+            //Setup the preloadConfig data with all our preload data
+            var preloadConfig = {};
+            preloadConfig[osapi.container.ContainerConfig.PRELOAD_METADATAS] = commonContainerMetadataWrapper;
+            preloadConfig[osapi.container.ContainerConfig.PRELOAD_TOKENS] = commonContainerTokenWrapper;
+            preloadConfig[osapi.container.ContainerConfig.PRELOAD_REF_TIME] = null;
+
+            //Preload our data into the common container
+            //TODO: Submit a patch to Shindig common container to make the preloadFromConfig_
method public so preloaded
+            //gadget metadata and security tokens can be incrementally be pushed into the
container cache.
+            container.preloadFromConfig_(preloadConfig);
             renderNewGadget(gadget);
         } else {
             rave.errorWidget(gadget.regionWidgetId, "Unable to render OpenSocial Gadget:
<br /><br />" + validationResult.error);
         }
-
     }
 
     /**

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/auth/ClasspathAwareDefaultSecurityTokenCodec.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/auth/ClasspathAwareDefaultSecurityTokenCodec.java?rev=1156800&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/auth/ClasspathAwareDefaultSecurityTokenCodec.java
(added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/auth/ClasspathAwareDefaultSecurityTokenCodec.java
Thu Aug 11 20:12:20 2011
@@ -0,0 +1,133 @@
+/*
+ * 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.shindig.auth;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.apache.shindig.config.ContainerConfig;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class will only be here temporarily until we get a patch applied to Shindig to enable
loading the token key
+ * file from the classpath (which is why it has no test coverage and the weird nested classes).
+ *
+ * TODO: Remove this class once we have patches in Shindig to load the key file from the
classpath.
+ */
+@Singleton
+public class ClasspathAwareDefaultSecurityTokenCodec extends DefaultSecurityTokenCodec {
+    public static final String RESOURCE_PREFIX = "classpath:";
+
+    @Inject
+    public ClasspathAwareDefaultSecurityTokenCodec(final ContainerConfig config) {
+        super(new ContainerConfigWrapper(config));
+    }
+
+    private static class ContainerConfigWrapper implements ContainerConfig {
+        private ContainerConfig wrappedConfig;
+
+        private ContainerConfigWrapper(ContainerConfig config) {
+            this.wrappedConfig = config;
+        }
+
+        @Override
+        public Collection<String> getContainers() {
+            return wrappedConfig.getContainers();
+        }
+
+        @Override
+        public Map<String, Object> getProperties(String container) {
+            return wrappedConfig.getProperties(container);
+        }
+
+        @Override
+        public Object getProperty(String container, String name) {
+            return wrappedConfig.getProperty(container, name);
+        }
+
+        @Override
+        public String getString(String container, String name) {
+            String value = wrappedConfig.getString(container, name);
+
+            //if this is a request for the encryption key file location, see if it should
be pulled from the classpath,
+            //and, if it should, locate it and convert the resource based reference to a
direct filesystem reference
+            //since the Shindig BlobCrypterSecurityTokenDecoder only supports loading directly
from the filesystem...
+            if (BlobCrypterSecurityTokenCodec.SECURITY_TOKEN_KEY_FILE.equalsIgnoreCase(name)
&& value != null
+                    && value.startsWith(RESOURCE_PREFIX)) {
+                String resourceName = value.substring(RESOURCE_PREFIX.length());
+                URL resource = this.getClass().getClassLoader().getResource(resourceName);
+                if (resource != null) {
+                    value = resource.getFile();
+                }
+            }
+
+            return value;
+        }
+
+        @Override
+        public int getInt(String container, String name) {
+            return wrappedConfig.getInt(container, name);
+        }
+
+        @Override
+        public boolean getBool(String container, String name) {
+            return wrappedConfig.getBool(container, name);
+        }
+
+        @Override
+        public <T> List<T> getList(String container, String name) {
+            return wrappedConfig.getList(container, name);
+        }
+
+        @Override
+        public <T> Map<String, T> getMap(String container, String name) {
+            return wrappedConfig.getMap(container, name);
+        }
+
+        @Override
+        public ContainerConfig.Transaction newTransaction() {
+            return wrappedConfig.newTransaction();
+        }
+
+        @Override
+        public void addConfigObserver(final ConfigObserver observer, boolean notifyNow) {
+            wrappedConfig.addConfigObserver(new ConfigObserver() {
+                @Override
+                public void containersChanged(ContainerConfig config, Collection<String>
changed, Collection<String> removed) {
+                    if (!(config instanceof ContainerConfigWrapper)) {
+                        config = new ContainerConfigWrapper(config);
+                    }
+                    observer.containersChanged(config, changed, removed);
+                }
+            }, notifyNow);
+        }
+    }
+
+    public static class TemporarySecurityTokenGuiceModule extends AbstractModule {
+        @Override
+        protected void configure() {
+            bind(SecurityTokenCodec.class).to(ClasspathAwareDefaultSecurityTokenCodec.class);
+        }
+    }
+}

Modified: incubator/rave/trunk/rave-shindig/src/main/resources/modules-context.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/resources/modules-context.xml?rev=1156800&r1=1156799&r2=1156800&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/resources/modules-context.xml (original)
+++ incubator/rave/trunk/rave-shindig/src/main/resources/modules-context.xml Thu Aug 11 20:12:20
2011
@@ -24,11 +24,11 @@
     <bean class="org.apache.rave.commoncontainer.ConfigurablePropertiesModule" />
     <bean class="org.apache.rave.os.JPAOpenSocialModule" />
     <bean class="org.apache.rave.os.SocialApiGuiceModule" />
+    <bean class="org.apache.shindig.auth.ClasspathAwareDefaultSecurityTokenCodec$TemporarySecurityTokenGuiceModule"
/>
     <bean class="org.apache.shindig.gadgets.oauth.OAuthModule" />
     <bean class="org.apache.shindig.gadgets.DefaultGuiceModule" />
     <bean class="org.apache.shindig.common.cache.ehcache.EhCacheModule" />
     <bean class="org.apache.shindig.sample.shiro.ShiroGuiceModule" />
     <bean class="org.apache.shindig.sample.container.SampleContainerGuiceModule" />
     <bean class="org.apache.shindig.extras.ShindigExtrasGuiceModule" />
-    <bean class="org.apache.shindig.sample.commoncontainer.auth.CommonContainerAuthGuiceModule"
/>
 </beans>
\ No newline at end of file

Modified: incubator/rave/trunk/rave-shindig/src/main/webapp/WEB-INF/classes/containers/default/container.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/webapp/WEB-INF/classes/containers/default/container.js?rev=1156800&r1=1156799&r2=1156800&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/webapp/WEB-INF/classes/containers/default/container.js
(original)
+++ incubator/rave/trunk/rave-shindig/src/main/webapp/WEB-INF/classes/containers/default/container.js
Thu Aug 11 20:12:20 2011
@@ -81,6 +81,7 @@
 "gadgets.uri.iframe.lockedDomainSuffix" :  "-a.example.com:8080",
 "gadgets.uri.iframe.unlockedDomain" : "www.example.com:8080",
 "gadgets.uri.iframe.basePath" : "${CONTEXT_ROOT}/gadgets/ifr",
+"gadgets.uri.iframe.alwaysAppendSecurityToken" : true,
 
 "gadgets.uri.js.host" : "http://www.example.com/",
 "gadgets.uri.js.path" : "${CONTEXT_ROOT}/gadgets/js",
@@ -90,7 +91,7 @@
 "gadgets.uri.oauth.callbackTemplate" : "//%host%${CONTEXT_ROOT}/gadgets/oauthcallback",
 
 // Use an insecure security token by default
-"gadgets.securityTokenType" : "insecure",
+//"gadgets.securityTokenType" : "insecure",
 
 // Config param to load Opensocial data for social
 // preloads in data pipelining.  %host% will be
@@ -98,9 +99,8 @@
 "gadgets.osDataUri" : "http://%host%${CONTEXT_ROOT}/rpc",
 
 // Uncomment these to switch to a secure version
-//
-//"gadgets.securityTokenType" : "secure",
-//"gadgets.securityTokenKeyFile" : "/path/to/key/file.txt",
+"gadgets.securityTokenType" : "secure",
+"gadgets.securityTokenKeyFile" : "classpath:security_token_encryption_key.txt",
 
 // URI for the default shindig test instance.
 //"defaultShindigTestHost": "http://${SERVER_HOST}:${SERVER_PORT}",



Mime
View raw message