本文整理匯總了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);
}