package examples;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.auth.AuthProvider;
import io.vertx.ext.auth.User;
import io.vertx.ext.auth.shiro.ShiroAuth;
import io.vertx.ext.auth.shiro.ShiroAuthOptions;
import io.vertx.ext.auth.shiro.ShiroAuthRealmType;
import org.apache.shiro.realm.Realm;
public class AuthShiroExamples {
public void example3(Vertx vertx) {
JsonObject config = new JsonObject().put("properties_path", "classpath:test-auth.properties");
AuthProvider provider = ShiroAuth.create(vertx, new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(config));
}
public void example4(AuthProvider authProvider) {
JsonObject authInfo = new JsonObject().put("username", "tim").put("password", "sausages");
authProvider.authenticate(authInfo, res -> {
if (res.succeeded()) {
User user = res.result();
} else {
}
});
}
public void example5(User user) {
user.isAuthorized("newsletter:edit:13", res -> {
if (res.succeeded()) {
boolean hasPermission = res.result();
} else {
}
});
}
public void example6(User user) {
user.isAuthorized("role:manager", res -> {
if (res.succeeded()) {
boolean hasRole = res.result();
} else {
}
});
}
public void example8(Vertx vertx, Realm realm) {
AuthProvider provider = ShiroAuth.create(vertx, realm);
}
}