All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.rxjava.ext.web.UserContext Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR2
Show newest version
/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.rxjava.ext.web;

import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;

/**
 * A web user is extended user coupled to the context and is used to perform verifications
 * and actions on behalf of the user. Actions can be:
 *
 * 
    *
  • {@link io.vertx.rxjava.ext.web.UserContext#refresh} - Require a re-authentication to confirm the user is present
  • *
  • {@link io.vertx.rxjava.ext.web.UserContext#impersonate} - Require a re-authentication to switch user identities
  • *
  • {@link io.vertx.rxjava.ext.web.UserContext#restore} - De-escalate a previous impersonate call
  • *
  • {@link io.vertx.rxjava.ext.web.UserContext#logout} - Logout the user from this application and redirect to a uri
  • *
  • {@link io.vertx.rxjava.ext.web.UserContext#clear} - Same as logout, without requirind a redirect
  • *
* *

* NOTE: This class has been automatically generated from the {@link io.vertx.ext.web.UserContext original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.ext.web.UserContext.class) public class UserContext { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; UserContext that = (UserContext) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new UserContext((io.vertx.ext.web.UserContext) obj), UserContext::getDelegate ); private final io.vertx.ext.web.UserContext delegate; public UserContext(io.vertx.ext.web.UserContext delegate) { this.delegate = delegate; } public UserContext(Object delegate) { this.delegate = (io.vertx.ext.web.UserContext)delegate; } public io.vertx.ext.web.UserContext getDelegate() { return delegate; } /** * Get the authenticated user (if any). This will usually be injected by an auth handler if authentication if successful. * @return the user, or null if the current user is not authenticated. */ public io.vertx.rxjava.ext.auth.User get() { io.vertx.rxjava.ext.auth.User ret = io.vertx.rxjava.ext.auth.User.newInstance((io.vertx.ext.auth.User)delegate.get()); return ret; } public boolean authenticated() { boolean ret = delegate.authenticated(); return ret; } /** * When performing a web identity operation, hint if possible to the identity provider to use the given login. * @param loginHint the desired login name, for example: admin. * @return fluent self */ public io.vertx.rxjava.ext.web.UserContext loginHint(java.lang.String loginHint) { delegate.loginHint(loginHint); return this; } /** * Forces the current user to re-authenticate. The user will be redirected to the same origin where this call was * made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request. * @return future result of the operation. */ public io.vertx.core.Future refresh() { io.vertx.core.Future ret = delegate.refresh().map(val -> val); return ret; } /** * Forces the current user to re-authenticate. The user will be redirected to the same origin where this call was * made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request. * @return future result of the operation. */ public rx.Single rxRefresh() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.refresh().onComplete(fut); })); } /** * Forces the current user to re-authenticate. The user will be redirected to the given uri. It is important to * notice that the redirect will only allow targets using an HTTP GET request. * @param redirectUri the uri to redirect the user to after the re-authentication. * @return future result of the operation. */ public io.vertx.core.Future refresh(java.lang.String redirectUri) { io.vertx.core.Future ret = delegate.refresh(redirectUri).map(val -> val); return ret; } /** * Forces the current user to re-authenticate. The user will be redirected to the given uri. It is important to * notice that the redirect will only allow targets using an HTTP GET request. * @param redirectUri the uri to redirect the user to after the re-authentication. * @return future result of the operation. */ public rx.Single rxRefresh(java.lang.String redirectUri) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.refresh(redirectUri).onComplete(fut); })); } /** * Impersonates a second identity. The user will be redirected to the same origin where this call was * made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request. * @return future result of the operation. */ public io.vertx.core.Future impersonate() { io.vertx.core.Future ret = delegate.impersonate().map(val -> val); return ret; } /** * Impersonates a second identity. The user will be redirected to the same origin where this call was * made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request. * @return future result of the operation. */ public rx.Single rxImpersonate() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.impersonate().onComplete(fut); })); } /** * Impersonates a second identity. The user will be redirected to the given uri. It is important to * notice that the redirect will only allow targets using an HTTP GET request. * @param redirectUri the uri to redirect the user to after the authentication. * @return future result of the operation. */ public io.vertx.core.Future impersonate(java.lang.String redirectUri) { io.vertx.core.Future ret = delegate.impersonate(redirectUri).map(val -> val); return ret; } /** * Impersonates a second identity. The user will be redirected to the given uri. It is important to * notice that the redirect will only allow targets using an HTTP GET request. * @param redirectUri the uri to redirect the user to after the authentication. * @return future result of the operation. */ public rx.Single rxImpersonate(java.lang.String redirectUri) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.impersonate(redirectUri).onComplete(fut); })); } /** * Undo a previous call to a impersonation. The user will be redirected to the same origin where this call was * made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request. * @return future result of the operation. */ public io.vertx.core.Future restore() { io.vertx.core.Future ret = delegate.restore().map(val -> val); return ret; } /** * Undo a previous call to a impersonation. The user will be redirected to the same origin where this call was * made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request. * @return future result of the operation. */ public rx.Single rxRestore() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.restore().onComplete(fut); })); } /** * Undo a previous call to an impersonation. The user will be redirected to the given uri. It is important to * notice that the redirect will only allow targets using an HTTP GET request. * @param redirectUri the uri to redirect the user to after the re-authentication. * @return future result of the operation. */ public io.vertx.core.Future restore(java.lang.String redirectUri) { io.vertx.core.Future ret = delegate.restore(redirectUri).map(val -> val); return ret; } /** * Undo a previous call to an impersonation. The user will be redirected to the given uri. It is important to * notice that the redirect will only allow targets using an HTTP GET request. * @param redirectUri the uri to redirect the user to after the re-authentication. * @return future result of the operation. */ public rx.Single rxRestore(java.lang.String redirectUri) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.restore(redirectUri).onComplete(fut); })); } /** * Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove * the {@link io.vertx.rxjava.ext.auth.User} and clear the {@link io.vertx.rxjava.ext.web.Session} (if any) in the current context. Followed by a * redirect to the given uri. * @param redirectUri the uri to redirect the user to after the logout. * @return future result of the operation. */ public io.vertx.core.Future logout(java.lang.String redirectUri) { io.vertx.core.Future ret = delegate.logout(redirectUri).map(val -> val); return ret; } /** * Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove * the {@link io.vertx.rxjava.ext.auth.User} and clear the {@link io.vertx.rxjava.ext.web.Session} (if any) in the current context. Followed by a * redirect to the given uri. * @param redirectUri the uri to redirect the user to after the logout. * @return future result of the operation. */ public rx.Single rxLogout(java.lang.String redirectUri) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.logout(redirectUri).onComplete(fut); })); } /** * Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove * the {@link io.vertx.rxjava.ext.auth.User} and clear the {@link io.vertx.rxjava.ext.web.Session} (if any) in the current context. Followed by a * redirect to /. * @return future result of the operation. */ public io.vertx.core.Future logout() { io.vertx.core.Future ret = delegate.logout().map(val -> val); return ret; } /** * Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove * the {@link io.vertx.rxjava.ext.auth.User} and clear the {@link io.vertx.rxjava.ext.web.Session} (if any) in the current context. Followed by a * redirect to /. * @return future result of the operation. */ public rx.Single rxLogout() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.logout().onComplete(fut); })); } /** * Clear can be called from any route handler which needs to terminate a login session. Invoking logout will remove * the {@link io.vertx.rxjava.ext.auth.User} and clear the {@link io.vertx.rxjava.ext.web.Session} (if any) in the current context. Unlike * {@link io.vertx.rxjava.ext.web.UserContext#logout} no redirect will be performed. */ public void clear() { delegate.clear(); } public static UserContext newInstance(io.vertx.ext.web.UserContext arg) { return arg != null ? new UserContext(arg) : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy