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.crypto.hash;
20  
21  import org.apache.shiro.crypto.RandomNumberGenerator;
22  import org.apache.shiro.util.ByteSource;
23  
24  /**
25   * A {@code HashService} that allows configuration of its strategy via JavaBeans-compatible setter methods.
26   *
27   * @since 1.2
28   */
29  public interface ConfigurableHashService extends HashService {
30  
31      /**
32       * Sets the 'private' (internal) salt to be paired with a 'public' (random or supplied) salt during hash computation.
33       *
34       * @param privateSalt the 'private' internal salt to be paired with a 'public' (random or supplied) salt during
35       *                    hash computation.
36       */
37      void setPrivateSalt(ByteSource privateSalt);
38  
39      /**
40       * Sets the number of hash iterations that will be performed during hash computation.
41       *
42       * @param iterations the number of hash iterations that will be performed during hash computation.
43       */
44      void setHashIterations(int iterations);
45  
46      /**
47       * Sets the name of the {@link java.security.MessageDigest MessageDigest} algorithm that will be used to compute
48       * hashes.
49       *
50       * @param name the name of the {@link java.security.MessageDigest MessageDigest} algorithm that will be used to
51       *             compute hashes.
52       */
53      void setHashAlgorithmName(String name);
54  
55      /**
56       * Sets a source of randomness used to generate public salts that will in turn be used during hash computation.
57       *
58       * @param rng a source of randomness used to generate public salts that will in turn be used during hash computation.
59       */
60      void setRandomNumberGenerator(RandomNumberGenerator rng);
61  }