@Override public CompletionStage<Optional<? extends Subject>> getSubject(final Http.Context context) { return CompletableFuture.supplyAsync(() -> { final Optional<CommonProfile> profile = getProfile(context); if (profile.isPresent()) { logger.debug("profile found: {} -> building a subject", profile); return Optional.of(new Pac4jSubject(profile.get())); } else { logger.debug("no profile found -> returning empty"); return Optional.empty(); } }, httpExecutionContext.current()); }
@Override public CompletionStage<Optional<? extends Subject>> getSubject(final Http.Context context) { return CompletableFuture.supplyAsync(() -> { final Optional<CommonProfile> profile = getProfile(context); if (profile.isPresent()) { logger.debug("profile found: {} -> building a subject", profile); return Optional.of(new Pac4jSubject(profile.get())); } else { logger.debug("no profile found -> returning empty"); return Optional.empty(); } }, httpExecutionContext.current()); }
@Override public CompletionStage<Result> onAuthFailure(final Http.Context context, final Optional<String> content) { return CompletableFuture.supplyAsync(() -> { final PlayWebContext playWebContext = new PlayWebContext(context, playSessionStore); final HttpActionAdapter<Result, PlayWebContext> httpActionAdapter = config.getHttpActionAdapter(); return httpActionAdapter.adapt(403, playWebContext); }, httpExecutionContext.current()); }
@Override public CompletionStage<Result> onAuthFailure(final Http.Context context, final Optional<String> content) { return CompletableFuture.supplyAsync(() -> { final PlayWebContext playWebContext = new PlayWebContext(context, playSessionStore); final HttpActionAdapter<Result, PlayWebContext> httpActionAdapter = config.getHttpActionAdapter(); return httpActionAdapter.adapt(403, playWebContext); }, httpExecutionContext.current()); }
@Override public CompletionStage<? extends Cart> doAction(final CheckoutPaymentFormData formData, final Cart cart) { final String selectedPaymentMethod = formData.getPayment(); return getPaymentMethodInfos() .thenComposeAsync(paymentMethods -> findSelectedPaymentMethod(paymentMethods, selectedPaymentMethod) .map(paymentMethod -> setPaymentToCart(cart, paymentMethod)) .orElseThrow(() -> new RuntimeException("No valid payment method found")), // Should not happen after validation httpExecutionContext.current()); }
public CompletionStage<Result> logout() { assertNotNull("logoutLogic", logoutLogic); assertNotNull("config", config); final PlayWebContext playWebContext = new PlayWebContext(ctx(), playSessionStore); return CompletableFuture.supplyAsync(() -> logoutLogic.perform(playWebContext, config, config.getHttpActionAdapter(), this.defaultUrl, this.logoutUrlPattern, this.localLogout, this.destroySession, this.centralLogout), ec.current()); }
public CompletionStage<Result> callback() { assertNotNull("callbackLogic", callbackLogic); assertNotNull("config", config); final PlayWebContext playWebContext = new PlayWebContext(ctx(), playSessionStore); return CompletableFuture.supplyAsync(() -> callbackLogic.perform(playWebContext, config, config.getHttpActionAdapter(), this.defaultUrl, this.saveInSession, this.multiProfile, this.renewSession, this.defaultClient), ec.current()); }
public CompletionStage<Result> logout() { assertNotNull("logoutLogic", logoutLogic); assertNotNull("config", config); final PlayWebContext playWebContext = new PlayWebContext(ctx(), playSessionStore); return CompletableFuture.supplyAsync(() -> logoutLogic.perform(playWebContext, config, config.getHttpActionAdapter(), this.defaultUrl, this.logoutUrlPattern, this.localLogout, this.destroySession, this.centralLogout), ec.current()); }
public CompletionStage<Result> callback() { assertNotNull("callbackLogic", callbackLogic); assertNotNull("config", config); final PlayWebContext playWebContext = new PlayWebContext(ctx(), playSessionStore); return CompletableFuture.supplyAsync(() -> callbackLogic.perform(playWebContext, config, config.getHttpActionAdapter(), this.defaultUrl, this.saveInSession, this.multiProfile, this.renewSession, this.defaultClient), ec.current()); }
}, httpExecutionContext.current());
}, httpExecutionContext.current());
public CompletionStage<Result> http() { return CompletableFuture.supplyAsync(() -> Results.ok().chunked(new PlayAsyncIOWriter(request(), convertedSession(), response()).internal()).as("text/event-stream"), httpExecutionContext.current()); }