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.realm;
020    
021    import java.util.Collection;
022    
023    /**
024     * Enables Shiro end-users to configure and initialize one or more {@link Realm Realm} instances
025     * in any manner desired.
026     * <p/>
027     * This interface exists to support environments where end-users may not wish to use Shiro's default
028     * text-based configuration to create and configure realms, and instead wish to retrieve a realm configured in a
029     * proprietary manner.  An implementation of this interface can access that proprietary mechanism to retrieve the
030     * already-created <tt>Realm</tt>s.
031     *
032     * <p>The <code>Realm</code> instances returned will used to construct the application's
033     * {@link org.apache.shiro.mgt.SecurityManager SecurityManager} instance.
034     *
035     * @since 0.9
036     */
037    public interface RealmFactory {
038    
039        /**
040         * Returns a collection of {@link Realm Realm} instances that will be used to construct
041         * the application's SecurityManager instance.
042         *
043         * <p>The order of the collection is important.  The {@link org.apache.shiro.mgt.SecurityManager SecurityManager}
044         * implementation will consult the Realms during authentication (log-in) and authorization (access control)
045         * operations in the collection's <b>iteration order</b>.  That is, the resulting collection's
046         * {@link java.util.Iterator Iterator} determines the order in which Realms are used.
047         *
048         * @return the <code>Collection</code> of Realms that the application's <code>SecurityManager</code> will use
049         *         for security data access.
050         */
051        Collection<Realm> getRealms();
052    
053    }