You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by paulkmoore <pa...@gmail.com> on 2013/08/16 21:53:07 UTC
Setting realm.authenticationTokenClass from .ini file
Hi all,
First post here, so please feel free to redirect me if this is the wrong
forum.
I have created an AuthorizationHeaderToken that implements
AuthenticationToken, effectively as a worker for any (or at least some) of
the Authorization schemes. The idea here is that the tokens deal with the
decoding of principal / credential (as appropriate to the scheme).
I then promptly ran into:
"Realm [org.apache.shiro.realm.jdbc.JdbcRealm@33d11db1] does not support
authentication token
[com.example.authentication.AuthorizationHeaderToken@13f86c12]. Please
ensure that the appropriate Realm implementation is configured correctly or
that the realm accepts AuthenticationTokens of this type."
Some further digging revealed that Jdbc realm is indeed wired to use only
UsernamePasswordToken, but offers getter/setter methods to configure token.
However, the setter method requires a Class type as its argument, and I'm
not aware of any way to achieve this from the .ini file (i.e. I don't think
beanutils supports this).
Any pointers, or am I into custom realm territory as well...
Thanks
Paul
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Setting-realm-authenticationTokenClass-from-ini-file-tp7579043.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Setting realm.authenticationTokenClass from .ini file
Posted by versatec <ro...@versatec.de>.
I am not sure whether I understood you correectly, but maybe this pseudo-code
answers your question:
[main]
jdbcRealm = org.apache.shiro.realm.JdbcRealm
token = org.apache.shiro.something.Token
jdbcRealm.token = $token // assign class 'org.apache.shiro.something.Token'
to attribute 'token' of JdbcRealm
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Setting-realm-authenticationTokenClass-from-ini-file-tp7579043p7579054.html
Sent from the Shiro User mailing list archive at Nabble.com.
Re: Setting realm.authenticationTokenClass from .ini file
Posted by "richard@localmed.com" <ri...@localmed.com>.
Hi, Paul.
I just had this same problem, and it took me almost a week to figure out
because of the lack of documentation, but the solution is actually quite
simple.
In my case, I had a UserToken that extends UsernamePasswordToken, but still
got the same "Realm...does not support..." error. I figured out that I
needed to replace the default "authc" filer (defined as
FormAuthenticationFilter in org.apache.shiro.web.filter.mgt.DefaultFilter)
with a custom filter that used my tokens instead of UsernamePasswordToken.
To do so, I extended FormAuthenticationFilter simply:
Then specify this filter in shiro.ini:
That's all! You can just set your "authc" filter to be your custom filter,
which should return your custom token. Good luck.
--
View this message in context: http://shiro-user.582556.n2.nabble.com/Setting-realm-authenticationTokenClass-from-ini-file-tp7579043p7579079.html
Sent from the Shiro User mailing list archive at Nabble.com.