DefaultHashFormatFactory

This default {@code HashFormatFactory} implementation heuristically determines a {@code HashFormat} class to instantiate based on the input argument and returns a new instance of the discovered class. The heuristics are detailed in the {@link #getInstance(string) getInstance} method documentation.

Constructors

this
this()
Undocumented in source.

Members

Functions

assertHashFormatImpl
void assertHashFormatImpl(TypeInfo_Class clazz)

Heuristically determine the fully qualified {@code HashFormat} implementation class name in the specified package based on the provided token. <p/> The token is expected to be a relevant fragment of an unqualified class name in the specified package. A 'relevant fragment' can be one of the following: <ul> <li>The {@code HashFormat} implementation unqualified class name</li> <li>The prefix of an unqualified class name ending with the text {@code Format}. The first character of this prefix can be upper or lower case and both options will be tried.</li> <li>The prefix of an unqualified class name ending with the text {@code HashFormat}. The first character of this prefix can be upper or lower case and both options will be tried.</li> <li>The prefix of an unqualified class name ending with the text {@code CryptoFormat}. The first character of this prefix can be upper or lower case and both options will be tried.</li> </ul> <p/> Some examples: <table> <tr> <th>Package Name</th> <th>Token</th> <th>Expected Output Class</th> <th>Notes</th> </tr> <tr> <td>{@code com.foo.whatever}</td> <td>{@code MyBarFormat}</td> <td>{@code com.foo.whatever.MyBarFormat}</td> <td>Token is a complete unqualified class name</td> </tr> <tr> <td>{@code com.foo.whatever}</td> <td>{@code Bar}</td> <td>{@code com.foo.whatever.BarFormat} <em>or</em> {@code com.foo.whatever.BarHashFormat} <em>or</em> {@code com.foo.whatever.BarCryptFormat}</td> <td>The token is only part of the unqualified class name - i.e. all characters in front of the {@code *Format} {@code *HashFormat} or {@code *CryptFormat} suffix. Note that the {@code *Format} variant will be tried before {@code *HashFormat} and then finally {@code *CryptFormat}</td> </tr> <tr> <td>{@code com.foo.whatever}</td> <td>{@code bar}</td> <td>{@code com.foo.whatever.BarFormat} <em>or</em> {@code com.foo.whatever.BarHashFormat} <em>or</em> {@code com.foo.whatever.BarCryptFormat}</td> <td>Exact same output as the above {@code Bar} input example. (The token differs only by the first character)</td> </tr> </table>

getFormatClassNames
Map!(string, string) getFormatClassNames()

Returns a {@code hashFormatAlias}-to-<code>fullyQualifiedHashFormatClassNameImplementation</code> map. <p/> This map will be used by the {@link #getInstance(string) getInstance} implementation: that method's argument will be used as a lookup key to this map. If the map returns a value, that value will be used to instantiate and return a new {@code HashFormat} instance. <h3>Defaults</h3> Shiro's default HashFormat implementations (as listed by the {@link ProvidedHashFormat} enum) will be searched automatically independently of this map. You only need to populate this map with custom {@code HashFormat} implementations that are <em>not</em> already represented by a {@code ProvidedHashFormat}. <h3>Efficiency</h3> Populating this map will be more efficient than configuring {@link #getSearchPackages() searchPackages}, but search packages may be more convenient depending on the number of {@code HashFormat} implementations that need to be supported by this factory.

getHashFormatClass
TypeInfo_Class getHashFormatClass(string token)

Heuristically determine the fully qualified HashFormat implementation class name based on the specified token. <p/> This implementation functions as follows (in order): <ol> <li>See if the argument can be used as a lookup key in the {@link #getFormatClassNames() formatClassNames} map. If a value (a fully qualified class name {@link HashFormat HashFormat} implementation) is found, {@link ClassUtils#forName(string) lookup} the class and return it.</li> <li> Check to see if the token argument is a {@link ProvidedHashFormat} enum value. If so, acquire the corresponding {@code HashFormat} class and return it. </li> <li> Check to see if the token argument is itself a fully qualified class name. If so, try to load the class and return it. </li> <li>If the above options do not result in a discovered class, search all all configured {@link #getSearchPackages() searchPackages} using heuristics defined in the {@link #getHashFormatClass(string, string) getHashFormatClass(packageName, token)} method documentation (relaying the {@code token} argument to that method for each configured package). </li> </ol> <p/> If a class is not discovered via any of the above means, {@code null} is returned to indicate the class could not be found.

getInstance
HashFormat getInstance(string in1)
Undocumented in source. Be warned that the author may not have intended to support it.
getSearchPackages
Set!(string) getSearchPackages()

Returns a set of package names that can be searched for {@link HashFormat} implementations according to heuristics defined in the {@link #getHashFormatClass(string, string) getHashFormat(packageName, token)} JavaDoc. <h3>Efficiency</h3> Configuring this property is not as efficient as configuring a {@link #getFormatClassNames() formatClassNames} map, but it may be more convenient depending on the number of {@code HashFormat} implementations that need to be supported by this factory.

newHashFormatInstance
HashFormat newHashFormatInstance(TypeInfo_Class clazz)
Undocumented in source. Be warned that the author may not have intended to support it.
setFormatClassNames
void setFormatClassNames(Map!(string, string) formatClassNames)

Sets the {@code hash-format-alias}-to-{@code fullyQualifiedHashFormatClassNameImplementation} map to be used in the {@link #getInstance(string)} implementation. See the {@link #getFormatClassNames()} JavaDoc for more information. <h3>Efficiency</h3> Populating this map will be more efficient than configuring {@link #getSearchPackages() searchPackages}, but search packages may be more convenient depending on the number of {@code HashFormat} implementations that need to be supported by this factory.

setSearchPackages
void setSearchPackages(Set!(string) searchPackages)

Sets a set of package names that can be searched for {@link HashFormat} implementations according to heuristics defined in the {@link #getHashFormatClass(string, string) getHashFormat(packageName, token)} JavaDoc. <h3>Efficiency</h3> Configuring this property is not as efficient as configuring a {@link #getFormatClassNames() formatClassNames} map, but it may be more convenient depending on the number of {@code HashFormat} implementations that need to be supported by this factory.

Inherited Members

From HashFormatFactory

getInstance
HashFormat getInstance(string token)
Undocumented in source.

Meta