I'm not quite sure this belongs in the Shiro API proper, that is, not
at least until we would support async operations in a much more
fundamental way across the framework - which I'm not sure would work
or not without rewriting significant parts of Shiro :)
Why not just wrap the call in a Callable and use an ExecutorService?, i.e.
final AuthenticationToken token = //create or get from somewhere
Future<AuthenticationInfo> future = executorService.submit(new
Callable<AuthenticationInfo>() {
public AuthenticationInfo call() {
return authenticator.authenticate(token);
}
});
This seems like a good/clean solution to me. Thoughts?
--
Les Hazlewood | @lhazlewood
CTO, Stormpath | http://stormpath.com | @goStormpath | 888.391.5282
On Tue, Jan 14, 2014 at 10:38 PM, gcollins <[email protected]> wrote:
> Hello,
>
> I was wondering - any thoughts of extending the Shiro API to support
> asynchronous authentication/authorization e.g.:
>
> interface Authenticator {
> ListenableFuture<AuthenticationInfo> authenticate(AuthenticationToken
> authenticationToken)
> throws AuthenticationException;
> }
>
> I ask because I am working with an authentication backend which may have
> significant latency (thus blocking a lot of threads). I am thinking of how
> to fit it best in with Shiro. I am also using Shiro via ServletFilters so I
> would be looking to see if I can take advantage of Servlet 3 asynchronous
> features as well to minimize thread usage.
>
> Just seeing if anyone may have thought about this.
>
> thanks in advance,
> Gareth Collins
>
>
>
> --
> View this message in context:
> http://shiro-user.582556.n2.nabble.com/Asynchronous-Authentication-tp7579507.html
> Sent from the Shiro User mailing list archive at Nabble.com.