You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/10/21 22:36:34 UTC
[17/24] usergrid git commit: Merge branch 'master' into
usergrid-1007-shiro-cache
Merge branch 'master' into usergrid-1007-shiro-cache
Conflicts:
stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/c02df0be
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/c02df0be
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/c02df0be
Branch: refs/heads/master
Commit: c02df0be2cf72831383d12d213464706f9b89fee
Parents: 513eae4 91fa489
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Oct 14 11:03:31 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Oct 14 11:03:31 2015 -0400
----------------------------------------------------------------------
stack/awscluster/gatling-cluster-cf.json | 2 +-
stack/build-tools/pom.xml | 2 +-
stack/config/pom.xml | 2 +-
stack/core/pom.xml | 14 +-
.../batch/service/JobSchedulerService.java | 2 +-
.../corepersistence/CpManagerCache.java | 12 +-
.../usergrid/corepersistence/ManagerCache.java | 7 +
.../asyncevents/AmazonAsyncEventService.java | 151 +++++++++++++------
.../asyncevents/AsyncIndexProvider.java | 12 +-
.../asyncevents/InMemoryAsyncEventService.java | 26 +++-
.../corepersistence/index/IndexServiceImpl.java | 22 +--
.../read/search/CandidateEntityFilter.java | 21 +--
.../pipeline/read/search/CandidateIdFilter.java | 15 +-
.../index/AmazonAsyncEventServiceTest.java | 5 +-
.../index/InMemoryAsycIndexServiceTest.java | 5 +-
.../corepersistence/index/IndexServiceTest.java | 18 ++-
stack/corepersistence/collection/pom.xml | 2 +-
stack/corepersistence/common/pom.xml | 2 +-
stack/corepersistence/graph/pom.xml | 2 +-
stack/corepersistence/map/pom.xml | 2 +-
stack/corepersistence/model/pom.xml | 2 +-
stack/corepersistence/pom.xml | 2 +-
stack/corepersistence/queryindex/pom.xml | 2 +-
.../persistence/index/EntityIndexBatch.java | 8 +-
.../index/impl/EsEntityIndexBatchImpl.java | 6 +-
.../index/impl/EsEntityIndexFactoryImpl.java | 4 -
.../index/impl/EsEntityIndexImpl.java | 5 +-
.../index/impl/EsIndexProducerImpl.java | 41 +++--
.../index/impl/IndexOperationMessage.java | 7 +
.../index/impl/IndexRefreshCommandImpl.java | 2 +-
.../persistence/index/impl/EntityIndexTest.java | 54 +++----
.../persistence/index/impl/GeoPagingTest.java | 3 +-
.../index/impl/IndexLoadTestsIT.java | 9 +-
stack/corepersistence/queue/pom.xml | 2 +-
.../persistence/queue/DefaultQueueManager.java | 5 +
.../persistence/queue/QueueManager.java | 5 +
.../queue/impl/SNSQueueManagerImpl.java | 9 ++
.../queue/impl/SQSQueueManagerImpl.java | 7 +
.../persistence/queue/QueueManagerTest.java | 37 ++++-
stack/pom.xml | 4 +-
stack/rest/pom.xml | 2 +-
.../exceptions/AbstractExceptionMapper.java | 2 +-
.../rest/security/shiro/ShiroCacheManager.java | 3 -
.../users/ConnectionResourceTest.java | 3 -
stack/rest_integration_tests/config/default.js | 1 +
stack/rest_integration_tests/lib/entities.js | 41 +++++
.../test/entities/create.js | 26 +++-
stack/services/pom.xml | 2 +-
.../management/AppInfoMigrationPlugin.java | 11 ++
.../assets/data/AwsSdkS3BinaryStore.java | 37 ++---
.../services/queues/ImportQueueManager.java | 5 +
stack/test-utils/pom.xml | 2 +-
52 files changed, 445 insertions(+), 228 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c02df0be/stack/core/pom.xml
----------------------------------------------------------------------
diff --cc stack/core/pom.xml
index 7944d96,15470ad..4905a75
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@@ -464,16 -463,10 +464,16 @@@
<type>jar</type>
</dependency>
- <dependency>
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>cache</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>queue</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>2.1.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c02df0be/stack/corepersistence/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c02df0be/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCacheManager.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCacheManager.java
index 3f768ed,0000000..416dcd2
mode 100644,000000..100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCacheManager.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCacheManager.java
@@@ -1,119 -1,0 +1,116 @@@
+/*
+ * 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.usergrid.rest.security.shiro;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
- import org.apache.shiro.authc.SimpleAuthenticationInfo;
+import org.apache.shiro.cache.Cache;
+import org.apache.shiro.cache.CacheException;
+import org.apache.shiro.cache.CacheManager;
+import org.apache.usergrid.persistence.cache.CacheFactory;
+import org.apache.usergrid.security.shiro.UsergridAuthenticationInfo;
+import org.apache.usergrid.security.shiro.UsergridAuthorizationInfo;
- import org.python.antlr.ast.Num;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
- import java.util.UUID;
+
+
+/**
+ * Plugin Usergrid cache for Shiro.
+ */
+public class ShiroCacheManager implements CacheManager {
+
+ private static final Logger logger = LoggerFactory.getLogger(ShiroCacheManager.class);
+
+ @Autowired
+ private Injector injector;
+
+ private Map<String, ShiroCache> caches = new HashMap<>();
+
+ private Properties properties;
+
+ private Integer cacheTtl = null; // specified in seconds
+
+ private static final String CACHE_TTL_PROPERTY_NAME = "usergrid.auth.cache.time-to-live";
+
+
+ public ShiroCacheManager() {}
+
+
+ @Override
+ public <K, V> Cache<K, V> getCache(String name) throws CacheException {
+ ShiroCache shiroCache = caches.get(name);
+
+ if (shiroCache == null) {
+
+ if ("realm.authorizationCache".equals(name)) {
+
+ TypeLiteral typeLit = new TypeLiteral<CacheFactory<String, UsergridAuthorizationInfo>>() {};
+
+ shiroCache = new ShiroCache(
+ new TypeReference<UsergridAuthorizationInfo>() {},
+ (CacheFactory)injector.getInstance( Key.get(typeLit) ),
+ getCacheTtl());
+
+ } else if ("realm.authenticationCache".equals(name)) {
+
+ TypeLiteral typeLit = new TypeLiteral<CacheFactory<String, UsergridAuthenticationInfo>>() {};
+
+ shiroCache = new ShiroCache(
+ new TypeReference<UsergridAuthenticationInfo>() {},
+ (CacheFactory)injector.getInstance( Key.get(typeLit) ),
+ getCacheTtl());
+
+ } else {
+ logger.error("Unknown Shiro Cache name: " + name);
+ throw new RuntimeException("Unknown Shiro Cache name: " + name);
+ }
+
+ caches.put(name, shiroCache);
+ }
+ return shiroCache;
+ }
+
+ private Integer getCacheTtl() {
+ if ( cacheTtl == null ) {
+ String cacheTtlString = properties.getProperty(CACHE_TTL_PROPERTY_NAME);
+ try {
+ cacheTtl = Integer.parseInt(cacheTtlString);
+ } catch ( NumberFormatException nfe ) {
+ cacheTtl = 3600;
+ logger.error("Error reading property {}, setting cache TTL to {} seconds", CACHE_TTL_PROPERTY_NAME);
+ }
+ }
+ return cacheTtl;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ @Autowired
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c02df0be/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
----------------------------------------------------------------------