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.credential;
20  
21  import org.apache.shiro.authc.AuthenticationInfo;
22  import org.apache.shiro.authc.AuthenticationToken;
23  
24  /**
25   * Interface implemented by classes that can determine if an AuthenticationToken's provided
26   * credentials matches a corresponding account's credentials stored in the system.
27   *
28   * <p>Simple direct comparisons are handled well by the
29   * {@link SimpleCredentialsMatcher SimpleCredentialsMatcher}.  If you
30   * hash user's credentials before storing them in a realm (a common practice), look at the
31   * {@link HashedCredentialsMatcher HashedCredentialsMatcher} implementations,
32   * as they support this scenario.
33   *
34   * @see SimpleCredentialsMatcher
35   * @see AllowAllCredentialsMatcher
36   * @see Md5CredentialsMatcher
37   * @see Sha1CredentialsMatcher
38   * @since 0.1
39   */
40  public interface CredentialsMatcher {
41  
42      /**
43       * Returns {@code true} if the provided token credentials match the stored account credentials,
44       * {@code false} otherwise.
45       *
46       * @param token the {@code AuthenticationToken} submitted during the authentication attempt
47       * @param info  the {@code AuthenticationInfo} stored in the system.
48       * @return {@code true} if the provided token credentials match the stored account credentials,
49       * {@code false} otherwise.
50       */
51      boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info);
52  
53  }