Java Code Examples for play.libs.F.Promise#pure()
The following examples show how to use
play.libs.F.Promise#pure() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyDeadboltHandler.java From thunderbit with GNU Affero General Public License v3.0 | 5 votes |
@Override public Promise<Optional<Result>> beforeAuthCheck(final Http.Context context) { if (context.session().get("username") != null && !context.session().get("username").isEmpty()) { // user is logged in return Promise.pure(Optional.empty()); } else { // user is not logged in return Promise.promise(() -> Optional.of(redirect(routes.Authentication.login()))); } }
Example 2
Source File: MyDeadboltHandler.java From thunderbit with GNU Affero General Public License v3.0 | 5 votes |
@Override public Promise<Optional<Subject>> getSubject(final Http.Context context) { if (context.session().get("username") != null && !context.session().get("username").isEmpty()) { // return an anonymous user return Promise.pure(Optional.of(new Subject() { @Override public List<? extends Role> getRoles() { return Collections.emptyList(); } @Override public List<? extends Permission> getPermissions() { return Collections.emptyList(); } @Override public String getIdentifier() { return context.session().get("username"); } })); } else { return Promise.pure(Optional.empty()); } }
Example 3
Source File: MyDeadboltHandler.java From thunderbit with GNU Affero General Public License v3.0 | 4 votes |
@Override public Promise<Optional<DynamicResourceHandler>> getDynamicResourceHandler(final Http.Context context) { return Promise.pure(Optional.empty()); }