本文整理汇总了Java中io.vertx.ext.auth.User.isAuthorised方法的典型用法代码示例。如果您正苦于以下问题:Java User.isAuthorised方法的具体用法?Java User.isAuthorised怎么用?Java User.isAuthorised使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.auth.User
的用法示例。
在下文中一共展示了User.isAuthorised方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: example2
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example2(User user) {
user.isAuthorised("printers:printer1234", res -> {
if (res.succeeded()) {
boolean hasAuthority = res.result();
if (hasAuthority) {
System.out.println("User has the authority");
} else {
System.out.println("User does not have the authority");
}
} else {
res.cause().printStackTrace();
}
});
}
示例2: example3
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example3(User user) {
user.isAuthorised("role:admin", res -> {
if (res.succeeded()) {
boolean hasAuthority = res.result();
if (hasAuthority) {
System.out.println("User has the authority to the role of admin");
} else {
System.out.println("User does not have the authority");
}
} else {
res.cause().printStackTrace();
}
});
}
示例3: preHandle
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
@Override
public void preHandle(RoutingContext context) {
User user = context.user();
if (user == null) {
context.fail(401);
return;
}
user.isAuthorised(annotation.authority(), result -> {
if (!result.result()) {
context.fail(403);
} else {
context.next();
}
});
}
示例4: authorise
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
private void authorise(Match curMatch, User webUser,
Handler<AsyncResult<Boolean>> handler) {
if (curMatch.requiredAuthority != null) {
webUser.isAuthorised(curMatch.requiredAuthority, res -> {
if (res.succeeded()) {
handler.handle(Future.succeededFuture(res.result()));
} else {
log.error(res.cause());
}
});
}
}
示例5: example5
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example5(User user) {
user.isAuthorised("newsletter:edit:13", res -> {
if (res.succeeded()) {
boolean hasPermission = res.result();
} else {
// Failed to
}
});
}
示例6: example6
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example6(User user) {
user.isAuthorised("role:manager", res -> {
if (res.succeeded()) {
boolean hasRole = res.result();
} else {
// Failed to
}
});
}
示例7: example7
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example7(User user) {
user.isAuthorised("commit_code", res -> {
if (res.succeeded()) {
boolean hasPermission = res.result();
} else {
// Failed to
}
});
}
示例8: example8
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example8(User user) {
user.isAuthorised("role:manager", res -> {
if (res.succeeded()) {
boolean hasRole = res.result();
} else {
// Failed to
}
});
}
示例9: example4
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example4(User user) {
user.isAuthorised("anyAuthority", res -> {
if (res.succeeded()) {
boolean hasRole = res.result();
} else {
// Failed
}
});
}
示例10: example13
import io.vertx.ext.auth.User; //导入方法依赖的package包/类
public void example13(User user) {
user.isAuthorised("create-report", res -> {
if (res.succeeded() && res.result()) {
// Yes the user can create reports
}
});
}