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.authc;
20  
21  /**
22   * <p>An extension of the {@link AuthenticationInfo} interface to be implemented by
23   * classes that support merging with other {@link AuthenticationInfo} instances.</p>
24   *
25   * <p>This allows an instance of this class to be an <em>aggregation</em>, or <em>composition</em> of account data
26   * from across multiple <code>Realm</code>s <tt>Realm</tt>s, not just one realm.</p>
27   *
28   * <p>This is useful in a multi-realm authentication configuration - the individual <tt>AuthenticationInfo</tt>
29   * objects obtained from each realm can be {@link #merge merged} into a single instance.  This instance can then be
30   * returned at the end of the authentication process, giving the impression of a single underlying
31   * realm/data source.
32   *
33   * @since 0.9
34   */
35  public interface MergableAuthenticationInfo extends AuthenticationInfo {
36  
37      /**
38       * Merges the given {@link AuthenticationInfo} into this instance.  The specific way
39       * that the merge occurs is up to the implementation, but typically it involves combining
40       * the principals and credentials together in this instance.  The <code>info</code> argument should
41       * not be modified in any way.
42       *
43       * @param info the info that should be merged into this instance.
44       */
45      void merge(AuthenticationInfo info);
46  
47  }