Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
* Cache entries include both inclusion and exclusion of a principal
* within a given role.
*
* @param
the type of principals on which the authorizer operates
*/
public class CachingAuthorizer
implements Authorizer
{
private final Authorizer
underlying;
private final Meter cacheMisses;
private final Timer getsTimer;
// A cache which maps (principal, role, uriInfo) to boolean
// authorization states.
//
// A cached value of `true` indicates that the key's principal is
// authorized to assume the given role. False values indicate the
// principal is not authorized to assume the role.
//
// `null` cache values are interpreted as cache misses, and will
// thus result in read through to the underlying `Authorizer`.
//
// Field is package-private to be visible for unit tests
final LoadingCache, Boolean> cache;
/**
* Creates a new cached authorizer.
*
* @param metricRegistry the application's registry of metrics
* @param authorizer the underlying authorizer
* @param cacheSpec {@link CaffeineSpec}
*/
public CachingAuthorizer(
final MetricRegistry metricRegistry,
final Authorizer
authorizer,
final CaffeineSpec cacheSpec) {
this(metricRegistry, authorizer, Caffeine.from(cacheSpec));
}
/**
* Creates a new cached authorizer.
*
* @param metricRegistry the application's registry of metrics
* @param authorizer the underlying authorizer
* @param builder a {@link CaffeineSpec}
*/
public CachingAuthorizer(
final MetricRegistry metricRegistry,
final Authorizer