Examples of EhCacheBasedUserCache


Examples of org.springframework.security.core.userdetails.cache.EhCacheBasedUserCache

                AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
    }

    @Test
    public void cacheOperationsAreSuccessful() throws Exception {
        EhCacheBasedUserCache cache = new EhCacheBasedUserCache();
        cache.setCache(getCache());
        cache.afterPropertiesSet();

        // Check it gets stored in the cache
        cache.putUserInCache(getUser());
        assertEquals(getUser().getPassword(), cache.getUserFromCache(getUser().getUsername()).getPassword());

        // Check it gets removed from the cache
        cache.removeUserFromCache(getUser());
        assertNull(cache.getUserFromCache(getUser().getUsername()));

        // Check it doesn't return values for null or unknown users
        assertNull(cache.getUserFromCache(null));
        assertNull(cache.getUserFromCache("UNKNOWN_USER"));
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.cache.EhCacheBasedUserCache

        assertNull(cache.getUserFromCache("UNKNOWN_USER"));
    }

    @Test(expected = IllegalArgumentException.class)
    public void startupDetectsMissingCache() throws Exception {
        EhCacheBasedUserCache cache = new EhCacheBasedUserCache();

        cache.afterPropertiesSet();
        fail("Should have thrown IllegalArgumentException");

        Ehcache myCache = getCache();
        cache.setCache(myCache);
        assertEquals(myCache, cache.getCache());
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.cache.EhCacheBasedUserCache

        assertEquals(ShaPasswordEncoder.class, provider.getPasswordEncoder().getClass());

        provider.setSaltSource(new SystemWideSaltSource());
        assertEquals(SystemWideSaltSource.class, provider.getSaltSource().getClass());

        provider.setUserCache(new EhCacheBasedUserCache());
        assertEquals(EhCacheBasedUserCache.class, provider.getUserCache().getClass());

        assertFalse(provider.isForcePrincipalAsString());
        provider.setForcePrincipalAsString(true);
        assertTrue(provider.isForcePrincipalAsString());
View Full Code Here

Examples of org.springframework.security.core.userdetails.cache.EhCacheBasedUserCache

      @UserCacheAware
      CacheManager cm;

      @Override
      public UserCache get() {
        final EhCacheBasedUserCache uc = new EhCacheBasedUserCache();
        final Cache userDetailsCache = cm.getCache(USER_DETAILS_CACHE_NAME);
        if(userDetailsCache == null) throw new IllegalStateException("No user details cache found");
        uc.setCache(userDetailsCache);
        return uc;
      }

    }).in(Scopes.SINGLETON);
View Full Code Here

Examples of org.springframework.security.providers.dao.cache.EhCacheBasedUserCache

    bind(UserCache.class).toProvider(new Provider<UserCache>() {

      public UserCache get() {
        final Cache cache = CacheManager.getInstance().getCache(USER_DETAILS_CACHE_NAME);
        assert cache != null;
        final EhCacheBasedUserCache uc = new EhCacheBasedUserCache();
        uc.setCache(cache);
        return uc;
      }

    }).in(Scopes.SINGLETON);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.