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 */ 019package org.apache.shiro.mgt; 020 021import org.apache.shiro.subject.Subject; 022import org.apache.shiro.subject.SubjectContext; 023 024import java.util.Map; 025 026/** 027 * A {@code SubjectFactory} is responsible for constructing {@link Subject Subject} instances as needed. 028 * 029 * @since 1.0 030 */ 031public interface SubjectFactory { 032 033 /** 034 * Creates a new Subject instance reflecting the state of the specified contextual data. The data would be 035 * anything required to required to construct a {@code Subject} instance and its contents can vary based on 036 * environment. 037 * <p/> 038 * Any data supported by Shiro core will be accessible by one of the {@code SubjectContext}'s {@code get*} 039 * or {@code resolve*} methods. All other data is available as map {@link Map#get attribute}s. 040 * 041 * @param context the contextual data to be used by the implementation to construct an appropriate {@code Subject} 042 * instance. 043 * @return a {@code Subject} instance created based on the specified context. 044 * @see SubjectContext 045 */ 046 Subject createSubject(SubjectContext context); 047 048}