usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [14/24] usergrid git commit: Add support for ApplicationGuestPrincipal; all tests now passing with Shiro Cache.
Date Wed, 21 Oct 2015 20:36:31 GMT
Add support for ApplicationGuestPrincipal; all tests now passing with Shiro Cache.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/0f979e9c
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/0f979e9c
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/0f979e9c

Branch: refs/heads/master
Commit: 0f979e9c433ea9753fa580d6ae000bfa97669ae7
Parents: b9a7ab1
Author: Dave Johnson <snoopdave@apache.org>
Authored: Tue Sep 29 12:19:32 2015 -0400
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Tue Sep 29 12:19:32 2015 -0400

----------------------------------------------------------------------
 .../apache/usergrid/persistence/cache/ScopedCacheTest.java  | 2 +-
 .../org/apache/usergrid/rest/security/shiro/ShiroCache.java | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0f979e9c/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
b/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
index c497141..73cffe1 100644
--- a/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
+++ b/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
@@ -47,7 +47,7 @@ public class ScopedCacheTest {
 
     @Inject protected CacheFactory<String, Map<String, Object>> cf;
 
-    TypeReference typeRef = new TypeReference<Map<String, Object>>() {};
+    TypeReference typeRef = new TypeReference<HashMap<String, Object>>() {};
 
 
     @Test

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0f979e9c/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java
index 1781885..db9fe1c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java
@@ -27,6 +27,7 @@ import org.apache.usergrid.persistence.cache.ScopedCache;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.security.shiro.UsergridAuthenticationInfo;
 import org.apache.usergrid.security.shiro.UsergridAuthorizationInfo;
+import org.apache.usergrid.security.shiro.principals.ApplicationGuestPrincipal;
 import org.apache.usergrid.security.shiro.principals.ApplicationPrincipal;
 import org.apache.usergrid.security.shiro.principals.OrganizationPrincipal;
 import org.apache.usergrid.security.shiro.principals.UserPrincipal;
@@ -151,6 +152,10 @@ public class ShiroCache<K, V> implements Cache<K,V> {
             } else  if ( spc.getPrimaryPrincipal() instanceof OrganizationPrincipal ) {
                 applicationId = CpNamingUtils.MANAGEMENT_APPLICATION_ID;
 
+            } else if ( spc.getPrimaryPrincipal() instanceof ApplicationGuestPrincipal) {
+                ApplicationGuestPrincipal p = (ApplicationGuestPrincipal)spc.getPrimaryPrincipal();
+                applicationId = p.getApplicationId();
+
             } else {
                 logger.error("Unknown principal type: " + spc.getPrimaryPrincipal().getClass().getSimpleName());
                 throw new RuntimeException("Unknown principal type: "
@@ -168,6 +173,10 @@ public class ShiroCache<K, V> implements Cache<K,V> {
         } else if ( key instanceof OrganizationPrincipal ) {
             applicationId = CpNamingUtils.MANAGEMENT_APPLICATION_ID;
 
+        } else if ( key instanceof ApplicationGuestPrincipal) {
+            ApplicationGuestPrincipal p = (ApplicationGuestPrincipal)key;
+            applicationId = p.getApplicationId();
+
         } else {
             logger.error("Unknown key type: " + key.getClass().getSimpleName());
             throw new RuntimeException("Unknown key type: " + key.getClass().getSimpleName());


Mime
View raw message