001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.auth.common;
007
008import javax.servlet.Filter;
009import javax.servlet.http.HttpServletRequest;
010
011import java.security.Principal;
012import java.util.Set;
013
014/**
015 * This interface provides a way for authentication code to communicate generic
016 * credentials to authorization delegates. An implementation of this interface
017 * could perform a query to determine group membership, for example.
018 * <p>
019 * The ServletContainerAuthenticationProvider's principalProviders set may be
020 * configured with zero or more instances of implementations of this interface,
021 * which it will consult during authentication. The union of the results will be
022 * assigned to the FEDORA_ALL_PRINCIPALS session attribute.
023 * </p>
024 *
025 * @author Gregory Jansen
026 * @see HttpHeaderPrincipalProvider
027 */
028public interface PrincipalProvider extends Filter {
029
030    /**
031     * Extract principals from the provided HttpServletRequest.
032     * <p>
033     * If no principals can be extracted, implementations of this method
034     * should return the empty set rather than null.
035     * </p>
036     *
037     * @param request the request
038     * @return a set of security principals
039     */
040    Set<Principal> getPrincipals(HttpServletRequest request);
041
042}