001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * 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,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    package org.apache.shiro.mgt;
020    
021    import org.apache.shiro.subject.Subject;
022    import org.apache.shiro.subject.SubjectContext;
023    
024    import java.util.Map;
025    
026    /**
027     * A {@code SubjectFactory} is responsible for returning {@link Subject Subject} instances as needed.
028     *
029     * @author Les Hazlewood
030     * @since 1.0
031     */
032    public interface SubjectFactory {
033    
034        /**
035         * Creates a new Subject instance reflecting the state of the specified contextual data.  The data would be
036         * anything required to required to construct a {@code Subject} instance and its contents can vary based on
037         * environment.  Any data supported by Shiro core will be accessible by one of the accessor methods.  All other
038         * data is available as map {@link Map#get attribute}s.
039         *
040         * @param context the contextual data to be used by the implementation to construct an appropriate {@code Subject}
041         *                instance.
042         * @return a {@code Subject} instance created based on the specified context.
043         */
044        Subject createSubject(SubjectContext context);
045    
046    }