All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.bundles.apikey.RoleAuthorizer Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
package io.dropwizard.bundles.apikey;

import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import io.dropwizard.auth.Authorizer;
import java.security.Principal;

/**
 * Authorizes principals based upon a mapping between {@link Principal#getName()}
 * and enabled roles.
 */
public class RoleAuthorizer

implements Authorizer

{ private final SetMultimap roles; public RoleAuthorizer(Multimap roles) { this.roles = ImmutableSetMultimap.copyOf(roles); } @Override public boolean authorize(P principal, String role) { return roles.containsEntry(principal.getName(), role); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy