本文整理汇总了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());
}
}
示例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());
}
}
示例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());
}
}
示例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
}
});
}
示例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
}
});
}