
com.yammer.dropwizard.auth.CachingAuthenticator Maven / Gradle / Ivy
package com.yammer.dropwizard.auth;
import com.google.common.base.Optional;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.CacheStats;
import com.google.common.cache.LoadingCache;
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Meter;
import com.yammer.metrics.core.Timer;
import com.yammer.metrics.core.TimerContext;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
/**
* An {@link Authenticator} decorator which uses a Guava cache to temporarily cache credentials and
* their corresponding principals.
*
* @param the type of credentials the authenticator can authenticate
* @param the type of principals the authenticator returns
*/
public class CachingAuthenticator implements Authenticator {
/**
* Wraps an underlying authenticator with a cache.
*
* @param authenticator the underlying authenticator
* @param builder a fully-configured {@link CacheBuilder}
* @param the type of credentials the authenticator can authenticate
* @param the type of principals the authenticator returns
* @return a cached version of {@code authenticator}
*/
public static CachingAuthenticator wrap(Authenticator authenticator,
CacheBuilder
© 2015 - 2025 Weber Informatics LLC | Privacy Policy