Quantcast

how can i define a custom Authentication token in shiro.ini?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how can i define a custom Authentication token in shiro.ini?

brainwash
This post has NOT been accepted by the mailing list yet.
my shiro.ini looks like as following -

#
# =============================================================================
# Quickstart INI Realm configuration
#
# For those that might not understand the references in this file, the
# definitions are all based on the classic Mel Brooks' film "Spaceballs". ;)
# =============================================================================

[main]
sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
sessionDAO = org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
sessionManager.sessionDAO = $sessionDAO
securityManager.sessionManager = $sessionManager

cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
securityManager.cacheManager = $cacheManager


credentialsMatcher = org.apache.shiro.authc.credential.Md5CredentialsMatcher
myCredentialsMatcher = com.test.myserver.auth.realm.MyCredentialsMatcher
myAuthenticationToken = com.test.myserver.auth.realm.MyAuthenticationToken

authcListener1 =  com.test.myserver.auth.MyAuthenticationListener
securityManager.authenticator.authenticationListeners = $authcListener1

# DataSource Setup
datasource = org.apache.shiro.jndi.JndiObjectFactory
datasource.resourceName = jdbc/mydatasource
datasource.resourceRef = true

# CUSTOM REALM
myRealm = com.test.myserver.auth.realm.MyRealm
myRealm.credentialsMatcher = $myCredentialsMatcher
myRealm.authenticationTokenClass = $myAuthenticationToken
 
securityManager.realms =  $myRealm


# cookie for single sign on is set to myServSessID and Root Path
cookie = org.apache.shiro.web.servlet.SimpleCookie
cookie.name = myServSessID
cookie.path = /
securityManager.sessionManager.sessionIdCookie = $cookie


# 3,600,000 milliseconds = 1 hour
securityManager.sessionManager.globalSessionTimeout = 36000000
##########################################################

during deployment of application, i am getting following exception

An error has occurred

Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.shiro.config.ConfigurationException: Unable to set property 'authenticationTokenClass' with value [com.test.myserver.auth.realm.MyAuthenticationToken - null, rememberMe=false] on object of type com.test.myserver.auth.realm.MyRealm. If 'com.test.myserver.auth.realm.MyAuthenticationToken - null, rememberMe=false' is a reference to another (previously defined) object, prefix it with '$' to indicate that the referenced object should be used as the actual value. For example, $com.test.myserver.auth.realm.MyAuthenticationToken - null, rememberMe=false. Please see server.log for more details.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how can i define a custom Authentication token in shiro.ini?

wangneng100
In "MyRealm", you need setCredentialsMatcher(new AllowAllCredentialsMatcher()); in constructor
JPL
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how can i define a custom Authentication token in shiro.ini?

JPL
This post has NOT been accepted by the mailing list yet.
In reply to this post by brainwash
By default, Realm sets authenticationTokenClass to UsernamePasswordToken, so if you would want to use a custom token, you have to set it in your realm using setAuthenticationTokenClass(<your impl>)
Loading...