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
021import org.apache.shiro.util.ByteSource;
022
023/**
024 * Interface representing account information that may use a salt when hashing credentials.  This interface
025 * exists primarily to support environments that hash user credentials (e.g. passwords).
026 * <p/>
027 * Salts should typically be generated from a secure pseudo-random number generator so they are effectively
028 * impossible to guess.  The salt value should be safely stored along side the account information to ensure
029 * it is maintained along with the account's credentials.
030 * <p/>
031 * This interface exists as a way for Shiro to acquire that salt so it can correctly perform
032 * {@link org.apache.shiro.authc.credential.CredentialsMatcher credentials matching} during login attempts.
033 * See the {@link org.apache.shiro.authc.credential.HashedCredentialsMatcher HashedCredentialsMatcher} JavaDoc for
034 * more information on hashing credentials with salts.
035 *
036 * @see org.apache.shiro.authc.credential.HashedCredentialsMatcher
037 *
038 * @since 1.1
039 */
040public interface SaltedAuthenticationInfo extends AuthenticationInfo {
041
042    /**
043     * Returns the salt used to salt the account's credentials or {@code null} if no salt was used.
044     *
045     * @return the salt used to salt the account's credentials or {@code null} if no salt was used.
046     */
047    ByteSource getCredentialsSalt();
048}