当前位置: 首页>>代码示例>>Java>>正文


Java User.isAuthorized方法代码示例

本文整理汇总了Java中io.vertx.ext.auth.User.isAuthorized方法的典型用法代码示例。如果您正苦于以下问题:Java User.isAuthorized方法的具体用法?Java User.isAuthorized怎么用?Java User.isAuthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.ext.auth.User的用法示例。


在下文中一共展示了User.isAuthorized方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authorize

import io.vertx.ext.auth.User; //导入方法依赖的package包/类
@Override
public void authorize(final User user, final Handler<AsyncResult<Void>> handler) {
    final int requiredcount = this.authorities.size();
    if (requiredcount > 0) {
        if (user == null) {
            handler.handle(Future.failedFuture(this.FORBIDDEN));
            return;
        }

        final AtomicInteger count = new AtomicInteger();
        final AtomicBoolean sentFailure = new AtomicBoolean();

        final Handler<AsyncResult<Boolean>> authHandler = res -> {
            if (res.succeeded()) {
                if (res.result()) {
                    if (count.incrementAndGet() == requiredcount) {
                        // Has all required authorities
                        handler.handle(Future.succeededFuture());
                    }
                } else {
                    if (sentFailure.compareAndSet(false, true)) {
                        handler.handle(Future.failedFuture(this.FORBIDDEN));
                    }
                }
            } else {
                handler.handle(Future.failedFuture(res.cause()));
            }
        };
        for (final String authority : this.authorities) {
            if (!sentFailure.get()) {
                user.isAuthorized(authority, authHandler);
            }
        }
    } else {
        // No auth required
        handler.handle(Future.succeededFuture());
    }
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:39,代码来源:AuthPhylum.java

示例2: authorize

import io.vertx.ext.auth.User; //导入方法依赖的package包/类
@Override
public void authorize(User user, Handler<AsyncResult<Void>> handler) {
    int requiredcount = authorities.size();
    if (requiredcount > 0) {
        if (user == null) {
            handler.handle(Future.failedFuture(FORBIDDEN));
            return;
        }

        AtomicInteger count = new AtomicInteger();
        AtomicBoolean sentFailure = new AtomicBoolean();

        Handler<AsyncResult<Boolean>> authHandler = res -> {
            if (res.succeeded()) {
                if (res.result()) {
                    if (count.incrementAndGet() == requiredcount) {
                        // Has all required authorities
                        handler.handle(Future.succeededFuture());
                    }
                } else {
                    if (sentFailure.compareAndSet(false, true)) {
                        handler.handle(Future.failedFuture(FORBIDDEN));
                    }
                }
            } else {
                handler.handle(Future.failedFuture(res.cause()));
            }
        };
        for (String authority : authorities) {
            if (!sentFailure.get()) {
                user.isAuthorized(authority, authHandler);
            }
        }
    } else {
        // No auth required
        handler.handle(Future.succeededFuture());
    }
}
 
开发者ID:eclipse,项目名称:hono,代码行数:39,代码来源:HonoAuthHandlerImpl.java

示例3: authorize

import io.vertx.ext.auth.User; //导入方法依赖的package包/类
@Override
public void authorize(User user, Handler<AsyncResult<Void>> handler) {
  int requiredcount = authorities.size();
  if (requiredcount > 0) {
    if (user == null) {
      handler.handle(Future.failedFuture(FORBIDDEN));
      return;
    }

    AtomicInteger count = new AtomicInteger();
    AtomicBoolean sentFailure = new AtomicBoolean();

    Handler<AsyncResult<Boolean>> authHandler = res -> {
      if (res.succeeded()) {
        if (res.result()) {
          if (count.incrementAndGet() == requiredcount) {
            // Has all required authorities
            handler.handle(Future.succeededFuture());
          }
        } else {
          if (sentFailure.compareAndSet(false, true)) {
            handler.handle(Future.failedFuture(FORBIDDEN));
          }
        }
      } else {
        handler.handle(Future.failedFuture(res.cause()));
      }
    };
    for (String authority : authorities) {
      if (!sentFailure.get()) {
        user.isAuthorized(authority, authHandler);
      }
    }
  } else {
    // No auth required
    handler.handle(Future.succeededFuture());
  }
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:39,代码来源:AuthHandlerImpl.java

示例4: example3

import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example3(User user) {

    user.isAuthorized("commit_code", res -> {
      if (res.succeeded()) {
        boolean hasPermission = res.result();
      } else {
        // Failed to
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:12,代码来源:AuthMongoExamples.java

示例5: example4

import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example4(User user) {

    user.isAuthorized(MongoAuth.ROLE_PREFIX + "manager", res -> {
      if (res.succeeded()) {
        boolean hasRole = res.result();
      } else {
        // Failed to
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:12,代码来源:AuthMongoExamples.java


注:本文中的io.vertx.ext.auth.User.isAuthorized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。