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.crypto.hash;
020
021import org.apache.shiro.crypto.RandomNumberGenerator;
022import org.apache.shiro.util.ByteSource;
023
024/**
025 * A {@code HashService} that allows configuration of its strategy via JavaBeans-compatible setter methods.
026 *
027 * @since 1.2
028 */
029public interface ConfigurableHashService extends HashService {
030
031    /**
032     * Sets the 'private' (internal) salt to be paired with a 'public' (random or supplied) salt during hash computation.
033     *
034     * @param privateSalt the 'private' internal salt to be paired with a 'public' (random or supplied) salt during
035     *                    hash computation.
036     */
037    void setPrivateSalt(ByteSource privateSalt);
038
039    /**
040     * Sets the number of hash iterations that will be performed during hash computation.
041     *
042     * @param iterations the number of hash iterations that will be performed during hash computation.
043     */
044    void setHashIterations(int iterations);
045
046    /**
047     * Sets the name of the {@link java.security.MessageDigest MessageDigest} algorithm that will be used to compute
048     * hashes.
049     *
050     * @param name the name of the {@link java.security.MessageDigest MessageDigest} algorithm that will be used to
051     *             compute hashes.
052     */
053    void setHashAlgorithmName(String name);
054
055    /**
056     * Sets a source of randomness used to generate public salts that will in turn be used during hash computation.
057     *
058     * @param rng a source of randomness used to generate public salts that will in turn be used during hash computation.
059     */
060    void setRandomNumberGenerator(RandomNumberGenerator rng);
061}