001/*
002 * Licensed to DuraSpace under one or more contributor license agreements.
003 * See the NOTICE file distributed with this work for additional information
004 * regarding copyright ownership.
005 *
006 * DuraSpace licenses this file to you under the Apache License,
007 * Version 2.0 (the "License"); you may not use this file except in
008 * compliance with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.fcrepo.auth.common;
019
020import javax.servlet.Filter;
021import javax.servlet.http.HttpServletRequest;
022
023import java.security.Principal;
024import java.util.Set;
025
026/**
027 * This interface provides a way for authentication code to communicate generic
028 * credentials to authorization delegates. An implementation of this interface
029 * could perform a query to determine group membership, for example.
030 * <p>
031 * The ServletContainerAuthenticationProvider's principalProviders set may be
032 * configured with zero or more instances of implementations of this interface,
033 * which it will consult during authentication. The union of the results will be
034 * assigned to the FEDORA_ALL_PRINCIPALS session attribute.
035 * </p>
036 *
037 * @author Gregory Jansen
038 * @see HttpHeaderPrincipalProvider
039 */
040public interface PrincipalProvider extends Filter {
041
042    /**
043     * Extract principals from the provided HttpServletRequest.
044     * <p>
045     * If no principals can be extracted, implementations of this method
046     * should return the empty set rather than null.
047     * </p>
048     *
049     * @param request the request
050     * @return a set of security principals
051     */
052    Set<Principal> getPrincipals(HttpServletRequest request);
053
054}