1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.shiro.mgt; 20 21 import org.apache.shiro.subject.Subject; 22 import org.apache.shiro.subject.SubjectContext; 23 24 import java.util.Map; 25 26 /** 27 * A {@code SubjectFactory} is responsible for constructing {@link Subject Subject} instances as needed. 28 * 29 * @since 1.0 30 */ 31 public interface SubjectFactory { 32 33 /** 34 * Creates a new Subject instance reflecting the state of the specified contextual data. The data would be 35 * anything required to required to construct a {@code Subject} instance and its contents can vary based on 36 * environment. 37 * <p/> 38 * Any data supported by Shiro core will be accessible by one of the {@code SubjectContext}'s {@code get*} 39 * or {@code resolve*} methods. All other data is available as map {@link Map#get attribute}s. 40 * 41 * @param context the contextual data to be used by the implementation to construct an appropriate {@code Subject} 42 * instance. 43 * @return a {@code Subject} instance created based on the specified context. 44 * @see SubjectContext 45 */ 46 Subject createSubject(SubjectContext context); 47 48 }