|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shiro.crypto.hash.format.DefaultHashFormatFactory
public class DefaultHashFormatFactory
This default HashFormatFactory
implementation heuristically determines a HashFormat
class to
instantiate based on the input argument and returns a new instance of the discovered class. The heuristics are
detailed in the getInstance
method documentation.
Constructor Summary | |
---|---|
DefaultHashFormatFactory()
|
Method Summary | |
---|---|
protected void |
assertHashFormatImpl(Class clazz)
|
Map<String,String> |
getFormatClassNames()
Returns a hashFormatAlias -to-fullyQualifiedHashFormatClassNameImplementation map. |
protected Class |
getHashFormatClass(String token)
Heuristically determine the fully qualified HashFormat implementation class name based on the specified token. |
protected Class |
getHashFormatClass(String packageName,
String token)
Heuristically determine the fully qualified HashFormat implementation class name in the specified
package based on the provided token. |
HashFormat |
getInstance(String in)
|
Set<String> |
getSearchPackages()
Returns a set of package names that can be searched for HashFormat implementations according to
heuristics defined in the getHashFormat(packageName, token) JavaDoc. |
protected Class |
lookupHashFormatClass(String name)
|
protected HashFormat |
newHashFormatInstance(Class clazz)
|
void |
setFormatClassNames(Map<String,String> formatClassNames)
Sets the hash-format-alias -to-fullyQualifiedHashFormatClassNameImplementation map to be used in
the getInstance(String) implementation. |
void |
setSearchPackages(Set<String> searchPackages)
Sets a set of package names that can be searched for HashFormat implementations according to
heuristics defined in the getHashFormat(packageName, token) JavaDoc. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultHashFormatFactory()
Method Detail |
---|
public Map<String,String> getFormatClassNames()
hashFormatAlias
-to-fullyQualifiedHashFormatClassNameImplementation
map.
This map will be used by the 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 HashFormat
instance.
ProvidedHashFormat
enum) will
be searched automatically independently of this map. You only need to populate this map with custom
HashFormat
implementations that are not already represented by a ProvidedHashFormat
.
searchPackages
,
but search packages may be more convenient depending on the number of HashFormat
implementations that
need to be supported by this factory.
hashFormatAlias
-to-fullyQualifiedHashFormatClassNameImplementation
map.public void setFormatClassNames(Map<String,String> formatClassNames)
hash-format-alias
-to-fullyQualifiedHashFormatClassNameImplementation
map to be used in
the getInstance(String)
implementation. See the getFormatClassNames()
JavaDoc for more
information.
searchPackages
,
but search packages may be more convenient depending on the number of HashFormat
implementations that
need to be supported by this factory.
formatClassNames
- the hash-format-alias
-to-fullyQualifiedHashFormatClassNameImplementation
map to be used in the getInstance(String)
implementation.public Set<String> getSearchPackages()
HashFormat
implementations according to
heuristics defined in the getHashFormat(packageName, token)
JavaDoc.
formatClassNames
map, but it may be more convenient depending on the number of HashFormat
implementations that
need to be supported by this factory.
HashFormat
implementationsgetHashFormatClass(String, String)
public void setSearchPackages(Set<String> searchPackages)
HashFormat
implementations according to
heuristics defined in the getHashFormat(packageName, token)
JavaDoc.
formatClassNames
map, but it may be more convenient depending on the number of HashFormat
implementations that
need to be supported by this factory.
searchPackages
- a set of package names that can be searched for HashFormat
implementationspublic HashFormat getInstance(String in)
getInstance
in interface HashFormatFactory
protected Class getHashFormatClass(String token)
formatClassNames
map. If a value (a fully qualified class name HashFormat
implementation) is found,
lookup
the class and return it.ProvidedHashFormat
enum value. If so, acquire the corresponding HashFormat
class and
return it.
searchPackages
using heuristics defined in the
getHashFormatClass(packageName, token)
method documentation
(relaying the token
argument to that method for each configured package).
null
is returned to indicate the class
could not be found.
token
- the string token from which a class name will be heuristically determined.
null
if no class could be heuristically determined.protected Class getHashFormatClass(String packageName, String token)
HashFormat
implementation class name in the specified
package based on the provided token.
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:
HashFormat
implementation unqualified class nameFormat
. The first character of
this prefix can be upper or lower case and both options will be tried.HashFormat
. The first character of
this prefix can be upper or lower case and both options will be tried.CryptoFormat
. The first character
of this prefix can be upper or lower case and both options will be tried.Package Name | Token | Expected Output Class | Notes |
---|---|---|---|
com.foo.whatever |
MyBarFormat |
com.foo.whatever.MyBarFormat |
Token is a complete unqualified class name |
com.foo.whatever |
Bar |
com.foo.whatever.BarFormat or com.foo.whatever.BarHashFormat or
com.foo.whatever.BarCryptFormat |
The token is only part of the unqualified class name - i.e. all characters in front of the *Format
*HashFormat or *CryptFormat suffix. Note that the *Format variant will be tried before
*HashFormat and then finally *CryptFormat |
com.foo.whatever |
bar |
com.foo.whatever.BarFormat or com.foo.whatever.BarHashFormat or
com.foo.whatever.BarCryptFormat |
Exact same output as the above Bar input example. (The token differs only by the first character) |
packageName
- the package to search for matching HashFormat
implementations.token
- the string token from which a class name will be heuristically determined.
null
if no class could be heuristically determined.protected Class lookupHashFormatClass(String name)
protected final void assertHashFormatImpl(Class clazz)
protected final HashFormat newHashFormatInstance(Class clazz)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |