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.authc;
020
021/**
022 * <p>An extension of the {@link AuthenticationInfo} interface to be implemented by
023 * classes that support merging with other {@link AuthenticationInfo} instances.</p>
024 *
025 * <p>This allows an instance of this class to be an <em>aggregation</em>, or <em>composition</em> of account data
026 * from across multiple <code>Realm</code>s <tt>Realm</tt>s, not just one realm.</p>
027 *
028 * <p>This is useful in a multi-realm authentication configuration - the individual <tt>AuthenticationInfo</tt>
029 * objects obtained from each realm can be {@link #merge merged} into a single instance.  This instance can then be
030 * returned at the end of the authentication process, giving the impression of a single underlying
031 * realm/data source.
032 *
033 * @since 0.9
034 */
035public interface MergableAuthenticationInfo extends AuthenticationInfo {
036
037    /**
038     * Merges the given {@link AuthenticationInfo} into this instance.  The specific way
039     * that the merge occurs is up to the implementation, but typically it involves combining
040     * the principals and credentials together in this instance.  The <code>info</code> argument should
041     * not be modified in any way.
042     *
043     * @param info the info that should be merged into this instance.
044     */
045    void merge(AuthenticationInfo info);
046
047}