本文整理汇总了Java中io.vertx.ext.auth.mongo.MongoAuth类的典型用法代码示例。如果您正苦于以下问题:Java MongoAuth类的具体用法?Java MongoAuth怎么用?Java MongoAuth使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MongoAuth类属于io.vertx.ext.auth.mongo包,在下文中一共展示了MongoAuth类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: example2
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
public void example2(MongoAuth authProvider) {
JsonObject authInfo = new JsonObject()
.put("username", "tim")
.put("password", "sausages");
authProvider.authenticate(authInfo, res -> {
if (res.succeeded()) {
User user = res.result();
} else {
// Failed!
}
});
}
示例2: example4
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
public void example4(User user) {
user.isAuthorized(MongoAuth.ROLE_PREFIX + "manager", res -> {
if (res.succeeded()) {
boolean hasRole = res.result();
} else {
// Failed to
}
});
}
示例3: doIsPermitted
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
@Override
public void doIsPermitted(String permissionOrRole, Handler<AsyncResult<Boolean>> resultHandler) {
if (permissionOrRole != null && permissionOrRole.startsWith(MongoAuth.ROLE_PREFIX)) {
String roledef = permissionOrRole.substring(MongoAuth.ROLE_PREFIX.length());
doHasRole(roledef, resultHandler);
} else {
doHasPermission(permissionOrRole, resultHandler);
}
}
示例4: createProvider
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
@Override
protected MongoAuth createProvider() throws Exception {
JsonObject config = new JsonObject();
config.put(MongoAuth.PROPERTY_COLLECTION_NAME, createCollectionName(MongoAuth.DEFAULT_COLLECTION_NAME));
config.put(MongoAuth.PROPERTY_SALT_STYLE, HashSaltStyle.COLUMN);
MongoAuth mongoAuth = MongoAuth.create(getMongoClient(), config);
mongoAuth.getHashStrategy().setAlgorithm(HashAlgorithm.PBKDF2);
return mongoAuth;
}
示例5: createProvider
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
@Override
protected MongoAuth createProvider() throws Exception {
MongoAuthOptions options = new MongoAuthOptions();
options.setCollectionName(createCollectionName(MongoAuth.DEFAULT_COLLECTION_NAME));
options.setSaltStyle(HashSaltStyle.COLUMN);
options.setConfig(getConfig());
options.setShared(true);
return options.createProvider(vertx);
}
示例6: createProvider
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
@Override
protected MongoAuth createProvider() throws Exception {
JsonObject config = new JsonObject();
config.put(MongoAuth.PROPERTY_COLLECTION_NAME, createCollectionName(MongoAuth.DEFAULT_COLLECTION_NAME));
config.put(MongoAuth.PROPERTY_SALT_STYLE, HashSaltStyle.COLUMN);
return MongoAuth.create(getMongoClient(), config);
}
示例7: createProvider
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
@Override
protected MongoAuth createProvider() throws Exception {
JsonObject config = new JsonObject();
config.put(MongoAuth.PROPERTY_SALT_STYLE, HashSaltStyle.EXTERNAL);
config.put(MongoAuth.PROPERTY_COLLECTION_NAME, createCollectionName(MongoAuth.DEFAULT_COLLECTION_NAME));
return MongoAuth.create(getMongoClient(), config);
}
示例8: authenticate
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
@Authenticate
public AuthHandler authenticate(final JsonObject config) {
return BasicOstium.create(
MongoAuth.create(MongoInfix.getClient(), config)
);
}
示例9: example1
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
public void example1(Vertx vertx, JsonObject mongoClientConfig) {
MongoClient client = MongoClient.createShared(vertx, mongoClientConfig);
JsonObject authProperties = new JsonObject();
MongoAuth authProvider = MongoAuth.create(client, authProperties);
}
示例10: example5
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
public void example5(Vertx vertx, JsonObject mongoClientConfig) {
MongoClient client = MongoClient.createShared(vertx, mongoClientConfig);
JsonObject authProperties = new JsonObject();
MongoAuth authProvider = MongoAuth.create(client, authProperties);
authProvider.setHashAlgorithm(HashAlgorithm.PBKDF2);
}
示例11: MongoUser
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
public MongoUser(String username, MongoAuth mongoAuth) {
this.principal = new JsonObject().put(mongoAuth.getUsernameField(), username);
this.mongoAuth = mongoAuth;
}
示例12: setAuthProvider
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
@Override
public void setAuthProvider(AuthProvider authProvider) {
this.mongoAuth = (MongoAuth) authProvider;
}
示例13: createProvider
import io.vertx.ext.auth.mongo.MongoAuth; //导入依赖的package包/类
protected MongoAuth createProvider() throws Exception {
JsonObject config = new JsonObject();
config.put(MongoAuth.PROPERTY_COLLECTION_NAME, createCollectionName(MongoAuth.DEFAULT_COLLECTION_NAME));
return MongoAuth.create(getMongoClient(), config);
}