blob: 509ce0ba9bc3b2c21339b9a322329e84ebbf2d63 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Fri Mar 04 17:58:55 EST 2016 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
DefaultHashService (Apache Shiro 1.2.4 API)
</TITLE>
<META NAME="date" CONTENT="2016-03-04">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="DefaultHashService (Apache Shiro 1.2.4 API)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/DefaultHashService.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html" title="interface in org.apache.shiro.crypto.hash"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/apache/shiro/crypto/hash/Hash.html" title="interface in org.apache.shiro.crypto.hash"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/apache/shiro/crypto/hash/DefaultHashService.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="DefaultHashService.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.shiro.crypto.hash</FONT>
<BR>
Class DefaultHashService</H2>
<PRE>
<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A>
<IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.shiro.crypto.hash.DefaultHashService</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html" title="interface in org.apache.shiro.crypto.hash">ConfigurableHashService</A>, <A HREF="../../../../../org/apache/shiro/crypto/hash/HashService.html" title="interface in org.apache.shiro.crypto.hash">HashService</A></DD>
</DL>
<HR>
<DL>
<DT><PRE>public class <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.69"><B>DefaultHashService</B></A><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A><DT>implements <A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html" title="interface in org.apache.shiro.crypto.hash">ConfigurableHashService</A></DL>
</PRE>
<P>
Default implementation of the <A HREF="../../../../../org/apache/shiro/crypto/hash/HashService.html" title="interface in org.apache.shiro.crypto.hash"><CODE>HashService</CODE></A> interface, supporting a customizable hash algorithm name,
secure-random salt generation, multiple hash iterations and an optional internal
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setPrivateSalt(org.apache.shiro.util.ByteSource)"><CODE>privateSalt</CODE></A>.
<h2>Hash Algorithm</h2>
You may specify a hash algorithm via the <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashAlgorithmName(java.lang.String)"><CODE>setHashAlgorithmName(String)</CODE></A> property. Any algorithm name
understood by the JDK
<A HREF="http://java.sun.com/javase/6/docs/api/java/security/MessageDigest.html?is-external=true#getInstance(java.lang.String)" title="class or interface in java.security"><CODE>MessageDigest.getInstance(String algorithmName)</CODE></A> method
will work. The default is <code>SHA-512</code>.
<h2>Random Salts</h2>
When a salt is not specified in a request, this implementation generates secure random salts via its
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setRandomNumberGenerator(org.apache.shiro.crypto.RandomNumberGenerator)"><CODE>randomNumberGenerator</CODE></A> property.
Random salts (and potentially combined with the internal <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getPrivateSalt()"><CODE>privateSalt</CODE></A>) is a very strong
salting strategy, as salts should ideally never be based on known/guessable data. The default instance is a
<A HREF="../../../../../org/apache/shiro/crypto/SecureRandomNumberGenerator.html" title="class in org.apache.shiro.crypto"><CODE>SecureRandomNumberGenerator</CODE></A>.
<h2>Hash Iterations</h2>
Secure hashing strategies often employ multiple hash iterations to slow down the hashing process. This technique
is usually used for password hashing, since the longer it takes to compute a password hash, the longer it would
take for an attacker to compromise a password. This
<a href="http://www.katasoft.com/blog/2011/04/04/strong-password-hashing-apache-shiro">Katasoft blog article</a>
explains in greater detail why this is useful, as well as information on how many iterations is 'enough'.
<p/>
You may set the number of hash iterations via the <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashIterations(int)"><CODE>setHashIterations(int)</CODE></A> property. The default is
<code>1</code>, but should be increased significantly if the <code>HashService</code> is intended to be used for password
hashing. See the linked blog article for more info.
<h2>Private Salt</h2>
If using this implementation as part of a password hashing strategy, it might be desirable to configure a
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setPrivateSalt(org.apache.shiro.util.ByteSource)"><CODE>private salt</CODE></A>:
<p/>
A hash and the salt used to compute it are often stored together. If an attacker is ever able to access
the hash (e.g. during password cracking) and it has the full salt value, the attacker has all of the input necessary
to try to brute-force crack the hash (source + complete salt).
<p/>
However, if part of the salt is not available to the attacker (because it is not stored with the hash), it is
<em>much</em> harder to crack the hash value since the attacker does not have the complete inputs necessary.
<p/>
The <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getPrivateSalt()"><CODE>privateSalt</CODE></A> property exists to satisfy this private-and-not-shared part of the salt.
If you configure this attribute, you can obtain this additional very important safety feature.
<p/>
<b>*</b>By default, the <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getPrivateSalt()"><CODE>privateSalt</CODE></A> is null, since a sensible default cannot be used that
isn't easily compromised (because Shiro is an open-source project and any default could be easily seen and used).
<P>
<P>
<DL>
<DT><B>Since:</B></DT>
<DD>1.2</DD>
</DL>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#DefaultHashService()">DefaultHashService</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a new <code>DefaultHashService</code> instance with the following defaults:
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashAlgorithmName(java.lang.String)"><CODE>hashAlgorithmName</CODE></A> = <code>SHA-512</code>
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashIterations(int)"><CODE>hashIterations</CODE></A> = <code>1</code>
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setRandomNumberGenerator(org.apache.shiro.crypto.RandomNumberGenerator)"><CODE>randomNumberGenerator</CODE></A> =
new <A HREF="../../../../../org/apache/shiro/crypto/SecureRandomNumberGenerator.html" title="class in org.apache.shiro.crypto"><CODE>SecureRandomNumberGenerator</CODE></A>()
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setGeneratePublicSalt(boolean)"><CODE>generatePublicSalt</CODE></A> = <code>false</code>
<p/>
If this hashService will be used for password hashing it is recommended to set the
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setPrivateSalt(org.apache.shiro.util.ByteSource)"><CODE>privateSalt</CODE></A> and significantly increase the number of
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashIterations(int)"><CODE>hashIterations</CODE></A>.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#combine(org.apache.shiro.util.ByteSource, org.apache.shiro.util.ByteSource)">combine</A></B>(<A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A>&nbsp;privateSalt,
<A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A>&nbsp;publicSalt)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Combines the specified 'private' salt bytes with the specified additional extra bytes to use as the
total salt during hash computation.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../org/apache/shiro/crypto/hash/Hash.html" title="interface in org.apache.shiro.crypto.hash">Hash</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#computeHash(org.apache.shiro.crypto.hash.HashRequest)">computeHash</A></B>(<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash">HashRequest</A>&nbsp;request)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Computes and responds with a hash based on the specified request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getAlgorithmName(org.apache.shiro.crypto.hash.HashRequest)">getAlgorithmName</A></B>(<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash">HashRequest</A>&nbsp;request)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getHashAlgorithmName()">getHashAlgorithmName</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getHashIterations()">getHashIterations</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getIterations(org.apache.shiro.crypto.hash.HashRequest)">getIterations</A></B>(<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash">HashRequest</A>&nbsp;request)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getPrivateSalt()">getPrivateSalt</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getPublicSalt(org.apache.shiro.crypto.hash.HashRequest)">getPublicSalt</A></B>(<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash">HashRequest</A>&nbsp;request)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the public salt that should be used to compute a hash based on the specified request or
<code>null</code> if no public salt should be used.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../org/apache/shiro/crypto/RandomNumberGenerator.html" title="interface in org.apache.shiro.crypto">RandomNumberGenerator</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getRandomNumberGenerator()">getRandomNumberGenerator</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#isGeneratePublicSalt()">isGeneratePublicSalt</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns <code>true</code> if a public salt should be randomly generated and used to compute a hash if a
<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash"><CODE>HashRequest</CODE></A> does not specify a salt, <code>false</code> otherwise.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setGeneratePublicSalt(boolean)">setGeneratePublicSalt</A></B>(boolean&nbsp;generatePublicSalt)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets whether or not a public salt should be randomly generated and used to compute a hash if a
<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash"><CODE>HashRequest</CODE></A> does not specify a salt.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashAlgorithmName(java.lang.String)">setHashAlgorithmName</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;name)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the name of the <A HREF="http://java.sun.com/javase/6/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security"><CODE>MessageDigest</CODE></A> algorithm that will be used to compute
hashes.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashIterations(int)">setHashIterations</A></B>(int&nbsp;count)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the number of hash iterations that will be performed during hash computation.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setPrivateSalt(org.apache.shiro.util.ByteSource)">setPrivateSalt</A></B>(<A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A>&nbsp;privateSalt)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the 'private' (internal) salt to be paired with a 'public' (random or supplied) salt during hash computation.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setRandomNumberGenerator(org.apache.shiro.crypto.RandomNumberGenerator)">setRandomNumberGenerator</A></B>(<A HREF="../../../../../org/apache/shiro/crypto/RandomNumberGenerator.html" title="interface in org.apache.shiro.crypto">RandomNumberGenerator</A>&nbsp;rng)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets a source of randomness used to generate public salts that will in turn be used during hash computation.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="DefaultHashService()"><!-- --></A><H3>
DefaultHashService</H3>
<PRE>
public <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.110"><B>DefaultHashService</B></A>()</PRE>
<DL>
<DD>Constructs a new <code>DefaultHashService</code> instance with the following defaults:
<ul>
<li><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashAlgorithmName(java.lang.String)"><CODE>hashAlgorithmName</CODE></A> = <code>SHA-512</code></li>
<li><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashIterations(int)"><CODE>hashIterations</CODE></A> = <code>1</code></li>
<li><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setRandomNumberGenerator(org.apache.shiro.crypto.RandomNumberGenerator)"><CODE>randomNumberGenerator</CODE></A> =
new <A HREF="../../../../../org/apache/shiro/crypto/SecureRandomNumberGenerator.html" title="class in org.apache.shiro.crypto"><CODE>SecureRandomNumberGenerator</CODE></A>()</li>
<li><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setGeneratePublicSalt(boolean)"><CODE>generatePublicSalt</CODE></A> = <code>false</code></li>
</ul>
<p/>
If this hashService will be used for password hashing it is recommended to set the
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setPrivateSalt(org.apache.shiro.util.ByteSource)"><CODE>privateSalt</CODE></A> and significantly increase the number of
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#setHashIterations(int)"><CODE>hashIterations</CODE></A>. See the class-level JavaDoc for more information.
<P>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="computeHash(org.apache.shiro.crypto.hash.HashRequest)"><!-- --></A><H3>
computeHash</H3>
<PRE>
public <A HREF="../../../../../org/apache/shiro/crypto/hash/Hash.html" title="interface in org.apache.shiro.crypto.hash">Hash</A> <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.150"><B>computeHash</B></A>(<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash">HashRequest</A>&nbsp;request)</PRE>
<DL>
<DD>Computes and responds with a hash based on the specified request.
<p/>
This implementation functions as follows:
<ul>
<li>If the request's <A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html#getSalt()"><CODE>salt</CODE></A> is null:
<p/>
A salt will be generated and used to compute the hash. The salt is generated as follows:
<ol>
<li>Use the <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getRandomNumberGenerator()"><CODE>randomNumberGenerator</CODE></A> to generate a new random number.</li>
<li><A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#combine(org.apache.shiro.util.ByteSource, org.apache.shiro.util.ByteSource)"><CODE>combine</CODE></A> this random salt with any configured
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getPrivateSalt()"><CODE>privateSalt</CODE></A>
</li>
<li>Use the combined value as the salt used during hash computation</li>
</ol>
</li>
<li>
If the request salt is not null:
<p/>
This indicates that the hash computation is for comparison purposes (of a
previously computed hash). The request salt will be <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#combine(org.apache.shiro.util.ByteSource, org.apache.shiro.util.ByteSource)"><CODE>combined</CODE></A> with any
configured <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getPrivateSalt()"><CODE>privateSalt</CODE></A> and used as the complete salt during hash computation.
</li>
</ul>
<p/>
The returned <code>Hash</code>'s <A HREF="../../../../../org/apache/shiro/crypto/hash/Hash.html#getSalt()"><CODE>salt</CODE></A> property
will contain <em>only</em> the 'public' part of the salt and <em>NOT</em> the privateSalt. See the class-level
JavaDoc explanation for more info.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/HashService.html#computeHash(org.apache.shiro.crypto.hash.HashRequest)">computeHash</A></CODE> in interface <CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/HashService.html" title="interface in org.apache.shiro.crypto.hash">HashService</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>request</CODE> - the request to process
<DT><B>Returns:</B><DD>the response containing the result of the hash computation, as well as any hash salt used that should be
exposed to the caller.<DT><B>See Also:</B><DD><A HREF="../../../../../org/apache/shiro/crypto/hash/Hash.html#getSalt()"><CODE>Hash.getSalt()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getAlgorithmName(org.apache.shiro.crypto.hash.HashRequest)"><!-- --></A><H3>
getAlgorithmName</H3>
<PRE>
protected <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.174"><B>getAlgorithmName</B></A>(<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash">HashRequest</A>&nbsp;request)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getIterations(org.apache.shiro.crypto.hash.HashRequest)"><!-- --></A><H3>
getIterations</H3>
<PRE>
protected int <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.182"><B>getIterations</B></A>(<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash">HashRequest</A>&nbsp;request)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getPublicSalt(org.apache.shiro.crypto.hash.HashRequest)"><!-- --></A><H3>
getPublicSalt</H3>
<PRE>
protected <A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A> <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.212"><B>getPublicSalt</B></A>(<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash">HashRequest</A>&nbsp;request)</PRE>
<DL>
<DD>Returns the public salt that should be used to compute a hash based on the specified request or
<code>null</code> if no public salt should be used.
<p/>
This implementation functions as follows:
<ol>
<li>If the request salt is not null and non-empty, this will be used, return it.</li>
<li>If the request salt is null or empty:
<ol>
<li>If a private salt has been set <em>OR</em> <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#isGeneratePublicSalt()"><CODE>isGeneratePublicSalt()</CODE></A> is <code>true</code>,
auto generate a random public salt via the configured
<A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getRandomNumberGenerator()"><CODE>randomNumberGenerator</CODE></A>.</li>
<li>If a private salt has not been configured and <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#isGeneratePublicSalt()"><CODE>isGeneratePublicSalt()</CODE></A> is <code>false</code>,
do nothing - return <code>null</code> to indicate a salt should not be used during hash computation.</li>
</ol>
</li>
</ol>
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>request</CODE> - request the request to process
<DT><B>Returns:</B><DD>the public salt that should be used to compute a hash based on the specified request or
<code>null</code> if no public salt should be used.</DL>
</DD>
</DL>
<HR>
<A NAME="combine(org.apache.shiro.util.ByteSource, org.apache.shiro.util.ByteSource)"><!-- --></A><H3>
combine</H3>
<PRE>
protected <A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A> <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.246"><B>combine</B></A>(<A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A>&nbsp;privateSalt,
<A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A>&nbsp;publicSalt)</PRE>
<DL>
<DD>Combines the specified 'private' salt bytes with the specified additional extra bytes to use as the
total salt during hash computation. <code>privateSaltBytes</code> will be <code>null</code> }if no private salt has been
configured.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>privateSalt</CODE> - the (possibly <code>null</code>) 'private' salt to combine with the specified extra bytes<DD><CODE>publicSalt</CODE> - the extra bytes to use in addition to the given private salt.
<DT><B>Returns:</B><DD>a combination of the specified private salt bytes and extra bytes that will be used as the total
salt during hash computation.</DL>
</DD>
</DL>
<HR>
<A NAME="setHashAlgorithmName(java.lang.String)"><!-- --></A><H3>
setHashAlgorithmName</H3>
<PRE>
public void <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.275"><B>setHashAlgorithmName</B></A>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;name)</PRE>
<DL>
<DD><B>Description copied from interface: <CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html#setHashAlgorithmName(java.lang.String)">ConfigurableHashService</A></CODE></B></DD>
<DD>Sets the name of the <A HREF="http://java.sun.com/javase/6/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security"><CODE>MessageDigest</CODE></A> algorithm that will be used to compute
hashes.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html#setHashAlgorithmName(java.lang.String)">setHashAlgorithmName</A></CODE> in interface <CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html" title="interface in org.apache.shiro.crypto.hash">ConfigurableHashService</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the <A HREF="http://java.sun.com/javase/6/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security"><CODE>MessageDigest</CODE></A> algorithm that will be used to
compute hashes.</DL>
</DD>
</DL>
<HR>
<A NAME="getHashAlgorithmName()"><!-- --></A><H3>
getHashAlgorithmName</H3>
<PRE>
public <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.279"><B>getHashAlgorithmName</B></A>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="setPrivateSalt(org.apache.shiro.util.ByteSource)"><!-- --></A><H3>
setPrivateSalt</H3>
<PRE>
public void <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.283"><B>setPrivateSalt</B></A>(<A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A>&nbsp;privateSalt)</PRE>
<DL>
<DD><B>Description copied from interface: <CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html#setPrivateSalt(org.apache.shiro.util.ByteSource)">ConfigurableHashService</A></CODE></B></DD>
<DD>Sets the 'private' (internal) salt to be paired with a 'public' (random or supplied) salt during hash computation.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html#setPrivateSalt(org.apache.shiro.util.ByteSource)">setPrivateSalt</A></CODE> in interface <CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html" title="interface in org.apache.shiro.crypto.hash">ConfigurableHashService</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>privateSalt</CODE> - the 'private' internal salt to be paired with a 'public' (random or supplied) salt during
hash computation.</DL>
</DD>
</DL>
<HR>
<A NAME="getPrivateSalt()"><!-- --></A><H3>
getPrivateSalt</H3>
<PRE>
public <A HREF="../../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A> <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.287"><B>getPrivateSalt</B></A>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="setHashIterations(int)"><!-- --></A><H3>
setHashIterations</H3>
<PRE>
public void <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.291"><B>setHashIterations</B></A>(int&nbsp;count)</PRE>
<DL>
<DD><B>Description copied from interface: <CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html#setHashIterations(int)">ConfigurableHashService</A></CODE></B></DD>
<DD>Sets the number of hash iterations that will be performed during hash computation.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html#setHashIterations(int)">setHashIterations</A></CODE> in interface <CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html" title="interface in org.apache.shiro.crypto.hash">ConfigurableHashService</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>count</CODE> - the number of hash iterations that will be performed during hash computation.</DL>
</DD>
</DL>
<HR>
<A NAME="getHashIterations()"><!-- --></A><H3>
getHashIterations</H3>
<PRE>
public int <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.295"><B>getHashIterations</B></A>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="setRandomNumberGenerator(org.apache.shiro.crypto.RandomNumberGenerator)"><!-- --></A><H3>
setRandomNumberGenerator</H3>
<PRE>
public void <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.299"><B>setRandomNumberGenerator</B></A>(<A HREF="../../../../../org/apache/shiro/crypto/RandomNumberGenerator.html" title="interface in org.apache.shiro.crypto">RandomNumberGenerator</A>&nbsp;rng)</PRE>
<DL>
<DD><B>Description copied from interface: <CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html#setRandomNumberGenerator(org.apache.shiro.crypto.RandomNumberGenerator)">ConfigurableHashService</A></CODE></B></DD>
<DD>Sets a source of randomness used to generate public salts that will in turn be used during hash computation.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html#setRandomNumberGenerator(org.apache.shiro.crypto.RandomNumberGenerator)">setRandomNumberGenerator</A></CODE> in interface <CODE><A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html" title="interface in org.apache.shiro.crypto.hash">ConfigurableHashService</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>rng</CODE> - a source of randomness used to generate public salts that will in turn be used during hash computation.</DL>
</DD>
</DL>
<HR>
<A NAME="getRandomNumberGenerator()"><!-- --></A><H3>
getRandomNumberGenerator</H3>
<PRE>
public <A HREF="../../../../../org/apache/shiro/crypto/RandomNumberGenerator.html" title="interface in org.apache.shiro.crypto">RandomNumberGenerator</A> <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.303"><B>getRandomNumberGenerator</B></A>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="isGeneratePublicSalt()"><!-- --></A><H3>
isGeneratePublicSalt</H3>
<PRE>
public boolean <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.322"><B>isGeneratePublicSalt</B></A>()</PRE>
<DL>
<DD>Returns <code>true</code> if a public salt should be randomly generated and used to compute a hash if a
<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash"><CODE>HashRequest</CODE></A> does not specify a salt, <code>false</code> otherwise.
<p/>
The default value is <code>false</code> but should definitely be set to <code>true</code> if the
<code>HashService</code> instance is being used for password hashing.
<p/>
<b>NOTE:</b> this property only has an effect if a <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getPrivateSalt()"><CODE>privateSalt</CODE></A> is NOT configured. If a
private salt has been configured and a request does not provide a salt, a random salt will always be generated
to protect the integrity of the private salt (without a public salt, the private salt would be exposed as-is,
which is undesirable).
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD><code>true</code> if a public salt should be randomly generated and used to compute a hash if a
<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash"><CODE>HashRequest</CODE></A> does not specify a salt, <code>false</code> otherwise.</DL>
</DD>
</DL>
<HR>
<A NAME="setGeneratePublicSalt(boolean)"><!-- --></A><H3>
setGeneratePublicSalt</H3>
<PRE>
public void <A HREF="../../../../../src-html/org/apache/shiro/crypto/hash/DefaultHashService.html#line.341"><B>setGeneratePublicSalt</B></A>(boolean&nbsp;generatePublicSalt)</PRE>
<DL>
<DD>Sets whether or not a public salt should be randomly generated and used to compute a hash if a
<A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash"><CODE>HashRequest</CODE></A> does not specify a salt.
<p/>
The default value is <code>false</code> but should definitely be set to <code>true</code> if the
<code>HashService</code> instance is being used for password hashing.
<p/>
<b>NOTE:</b> this property only has an effect if a <A HREF="../../../../../org/apache/shiro/crypto/hash/DefaultHashService.html#getPrivateSalt()"><CODE>privateSalt</CODE></A> is NOT configured. If a
private salt has been configured and a request does not provide a salt, a random salt will always be generated
to protect the integrity of the private salt (without a public salt, the private salt would be exposed as-is,
which is undesirable).
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>generatePublicSalt</CODE> - whether or not a public salt should be randomly generated and used to compute a hash
if a <A HREF="../../../../../org/apache/shiro/crypto/hash/HashRequest.html" title="interface in org.apache.shiro.crypto.hash"><CODE>HashRequest</CODE></A> does not specify a salt.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/DefaultHashService.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../org/apache/shiro/crypto/hash/ConfigurableHashService.html" title="interface in org.apache.shiro.crypto.hash"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/apache/shiro/crypto/hash/Hash.html" title="interface in org.apache.shiro.crypto.hash"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/apache/shiro/crypto/hash/DefaultHashService.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="DefaultHashService.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
Copyright &#169; 2004-2016 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.
</BODY>
</HTML>