/*
 * 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.reactivex.ext.auth;

import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.vertx.core.json.JsonObject;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;

Represents an authenticates User and contains operations to authorise the user.

Please consult the documentation for a detailed explanation.

NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
/** * Represents an authenticates User and contains operations to authorise the user. * <p> * Please consult the documentation for a detailed explanation. * * <p/> * NOTE: This class has been automatically generated from the {@link io.vertx.ext.auth.User original} non RX-ified interface using Vert.x codegen. */
@io.vertx.lang.rx.RxGen(io.vertx.ext.auth.User.class) public class User { @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; User that = (User) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final io.vertx.lang.rx.TypeArg<User> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new User((io.vertx.ext.auth.User) obj), User::getDelegate ); private final io.vertx.ext.auth.User delegate; public User(io.vertx.ext.auth.User delegate) { this.delegate = delegate; } public io.vertx.ext.auth.User getDelegate() { return delegate; }
Is the user authorised to
Params:
  • authority – the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`.
  • resultHandler – handler that will be called with an AsyncResult containing the value `true` if the they has the authority or `false` otherwise.
Returns:the User to enable fluent use
/** * Is the user authorised to * @param authority the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`. * @param resultHandler handler that will be called with an {@link io.vertx.core.AsyncResult} containing the value `true` if the they has the authority or `false` otherwise. * @return the User to enable fluent use */
public io.vertx.reactivex.ext.auth.User isAuthorized(String authority, Handler<AsyncResult<Boolean>> resultHandler) { delegate.isAuthorized(authority, resultHandler); return this; }
Is the user authorised to
Params:
  • authority – the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`.
Returns:the User to enable fluent use
/** * Is the user authorised to * @param authority the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`. * @return the User to enable fluent use */
public Single<Boolean> rxIsAuthorized(String authority) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { isAuthorized(authority, handler); }); }
Params:
  • authority –
  • resultHandler –
Returns:
/** * @param authority * @param resultHandler * @return */
@Deprecated() public io.vertx.reactivex.ext.auth.User isAuthorised(String authority, Handler<AsyncResult<Boolean>> resultHandler) { delegate.isAuthorised(authority, resultHandler); return this; }
Params:
  • authority –
Returns:
/** * @param authority * @return */
@Deprecated() public Single<Boolean> rxIsAuthorised(String authority) { return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> { isAuthorised(authority, handler); }); }
The User object will cache any authorities that it knows it has to avoid hitting the underlying auth provider each time. Use this method if you want to clear this cache.
Returns:the User to enable fluent use
/** * The User object will cache any authorities that it knows it has to avoid hitting the * underlying auth provider each time. Use this method if you want to clear this cache. * @return the User to enable fluent use */
public io.vertx.reactivex.ext.auth.User clearCache() { delegate.clearCache(); return this; }
Get the underlying principal for the User. What this actually returns depends on the implementation. For a simple user/password based auth, it's likely to contain a JSON object with the following structure:
  {
    "username", "tim"
  }
Returns:JSON representation of the Principal
/** * Get the underlying principal for the User. What this actually returns depends on the implementation. * For a simple user/password based auth, it's likely to contain a JSON object with the following structure: * <pre> * { * "username", "tim" * } * </pre> * @return JSON representation of the Principal */
public JsonObject principal() { JsonObject ret = delegate.principal(); return ret; }
Set the auth provider for the User. This is typically used to reattach a detached User with an AuthProvider, e.g. after it has been deserialized.
Params:
  • authProvider – the AuthProvider - this must be the same type of AuthProvider that originally created the User
/** * Set the auth provider for the User. This is typically used to reattach a detached User with an AuthProvider, e.g. * after it has been deserialized. * @param authProvider the AuthProvider - this must be the same type of AuthProvider that originally created the User */
public void setAuthProvider(io.vertx.reactivex.ext.auth.AuthProvider authProvider) { delegate.setAuthProvider(authProvider.getDelegate()); } public static User newInstance(io.vertx.ext.auth.User arg) { return arg != null ? new User(arg) : null; } }