new F.Function<Option<Authenticator>, F.Promise<Result>>() {
@Override
public F.Promise<Result> apply(Option<Authenticator> authenticatorOption) throws Throwable {
if (authenticatorOption.isDefined() && authenticatorOption.get().isValid()) {
final Authenticator authenticator = authenticatorOption.get();
Object user = authenticator.user();
if (authorizationInstance.isAuthorized(user, configuration.params())) {
return F.Promise.wrap(authenticator.touch()).flatMap(new F.Function<Authenticator, F.Promise<Result>>() {
@Override
public F.Promise<Result> apply(Authenticator touched) throws Throwable {
ctx.args.put(SecureSocial.USER_KEY, touched.user());