View Javadoc
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.realm;
20  
21  import java.util.Collection;
22  
23  /**
24   * Enables Shiro end-users to configure and initialize one or more {@link Realm Realm} instances
25   * in any manner desired.
26   * <p/>
27   * This interface exists to support environments where end-users may not wish to use Shiro's default
28   * text-based configuration to create and configure realms, and instead wish to retrieve a realm configured in a
29   * proprietary manner.  An implementation of this interface can access that proprietary mechanism to retrieve the
30   * already-created <tt>Realm</tt>s.
31   *
32   * <p>The <code>Realm</code> instances returned will used to construct the application's
33   * {@link org.apache.shiro.mgt.SecurityManager SecurityManager} instance.
34   *
35   * @since 0.9
36   */
37  public interface RealmFactory {
38  
39      /**
40       * Returns a collection of {@link Realm Realm} instances that will be used to construct
41       * the application's SecurityManager instance.
42       *
43       * <p>The order of the collection is important.  The {@link org.apache.shiro.mgt.SecurityManager SecurityManager}
44       * implementation will consult the Realms during authentication (log-in) and authorization (access control)
45       * operations in the collection's <b>iteration order</b>.  That is, the resulting collection's
46       * {@link java.util.Iterator Iterator} determines the order in which Realms are used.
47       *
48       * @return the <code>Collection</code> of Realms that the application's <code>SecurityManager</code> will use
49       *         for security data access.
50       */
51      Collection<Realm> getRealms();
52  
53  }