本文整理汇总了Java中io.vertx.ext.auth.shiro.ShiroAuthRealmType类的典型用法代码示例。如果您正苦于以下问题:Java ShiroAuthRealmType类的具体用法?Java ShiroAuthRealmType怎么用?Java ShiroAuthRealmType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShiroAuthRealmType类属于io.vertx.ext.auth.shiro包,在下文中一共展示了ShiroAuthRealmType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testDifferentCharset
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Test
public void testDifferentCharset(TestContext context) throws Exception {
termHandler = term -> {
term.write("\u20AC");
term.close();
};
startShell(new SSHTermOptions().setDefaultCharset("ISO_8859_1").setPort(5000).setHost("localhost").setKeyPairOptions(
new JksOptions().setPath("src/test/resources/server-keystore.jks").setPassword("wibble")).
setAuthOptions(new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(
new JsonObject().put("properties_path", "classpath:test-auth.properties"))));
Session session = createSession("paulo", "secret", false);
session.connect();
Channel channel = session.openChannel("shell");
channel.connect();
InputStream in = channel.getInputStream();
int b = in.read();
context.assertEquals(63, b);
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:19,代码来源:SSHServerTest.java
示例2: runSSHServiceWithShiro
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
public void runSSHServiceWithShiro(Vertx vertx) throws Exception {
ShellService service = ShellService.create(vertx,
new ShellServiceOptions().setSSHOptions(
new SSHTermOptions().
setHost("localhost").
setPort(5000).
setKeyPairOptions(new JksOptions().
setPath("server-keystore.jks").
setPassword("wibble")
).
setAuthOptions(new ShiroAuthOptions().
setType(ShiroAuthRealmType.PROPERTIES).
setConfig(new JsonObject().
put("properties_path", "file:/path/to/my/auth.properties"))
)
)
);
service.start();
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:20,代码来源:Examples.java
示例3: testKeymapFromFilesystem
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Test
public void testKeymapFromFilesystem() throws Exception {
URL url = TermServer.class.getResource(SSHTermOptions.DEFAULT_INPUTRC);
File f = new File(url.toURI());
termHandler = Term::close;
startShell(new SSHTermOptions().setIntputrc(f.getAbsolutePath()).setPort(5000).setHost("localhost").setKeyPairOptions(
new JksOptions().setPath("src/test/resources/server-keystore.jks").setPassword("wibble")).
setAuthOptions(new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(
new JsonObject().put("properties_path", "classpath:test-auth.properties"))));
Session session = createSession("paulo", "secret", false);
session.connect();
Channel channel = session.openChannel("shell");
channel.connect();
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:15,代码来源:SSHServerTest.java
示例4: start
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Override
public void start() {
Router router = Router.router(vertx);
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
AuthProvider authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, new JsonObject());
router.route().handler(UserSessionHandler.create(authProvider));
router.route("/private/*").handler(RedirectAuthHandler.create(authProvider, "/login.html"));
router.mountSubRouter("/tokens", tokenRouter(authProvider));
router.mountSubRouter("/api", auctionApiRouter());
router.route().failureHandler(ErrorHandler.create(true));
router.route("/private/*").handler(staticHandler("private"));
router.route().handler(staticHandler("public"));
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
}
开发者ID:mwarc,项目名称:atm8-realtime-auctions-example,代码行数:21,代码来源:AuctionFrontendVerticle.java
示例5: start
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Override
public void start() {
Router router = Router.router(vertx);
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
AuthProvider authProvider = ShiroAuth.create(
vertx,
new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(new JsonObject())
);
router.route().handler(UserSessionHandler.create(authProvider));
router.route("/private/*").handler(RedirectAuthHandler.create(authProvider, "/login.html"));
router.mountSubRouter("/tokens", tokenRouter(authProvider));
router.mountSubRouter("/api", auctionApiRouter());
router.route().failureHandler(ErrorHandler.create(true));
router.route("/private/*").handler(staticHandler("private"));
router.route().handler(staticHandler("public"));
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
}
开发者ID:mwarc,项目名称:realtime-auctions-vertx3-example,代码行数:24,代码来源:AuctionFrontendVerticle.java
示例6: setUp
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties");
AuthProvider authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, authConfig);
// create a chain
chain = ChainAuthHandler.create();
chain
.append(JWTAuthHandler.create(null))
.append(BasicAuthHandler.create(authProvider))
.append(RedirectAuthHandler.create(authProvider));
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
router.route().handler(chain);
router.route().handler(ctx -> ctx.response().end());
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:20,代码来源:ChainAuthHandlerTest.java
示例7: testSecurityBypass
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Test
public void testSecurityBypass() throws Exception {
Handler<RoutingContext> handler = rc -> {
fail("should not get here");
rc.response().end("Welcome to the protected resource!");
};
JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties");
AuthProvider authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, authConfig);
router.route().pathRegex("/api/.*").handler(BasicAuthHandler.create(authProvider));
router.route("/api/v1/standard-job-profiles").handler(handler);
testRequest(HttpMethod.GET, "//api/v1/standard-job-profiles", 401, "Unauthorized");
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:17,代码来源:BasicAuthHandlerTest.java
示例8: testResolve
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Test
public void testResolve() throws Exception {
ClassLoader loader = PropertiesShiroAuthProviderTest.class.getClassLoader();
File res = new File(loader.getResource("test-auth.properties").toURI());
try {
ShiroAuth.create(vertx,
ShiroAuthRealmType.PROPERTIES,
new JsonObject().put(PropertiesProviderConstants.PROPERTIES_PROPS_PATH_FIELD, res.getName()));
fail();
} catch (Exception ignore) {
}
assertResolve(res.getParentFile(), res.getName());
assertResolve(res.getParentFile(), "file:" + res.getName());
assertResolve(res.getParentFile().getParentFile(), "file:" + res.getParentFile().getName() + File.separatorChar + res.getName());
assertResolve(res.getParentFile().getParentFile(), "classpath:" + res.getName());
assertResolve(res.getParentFile().getParentFile(), "url:" + res.toURI().toURL());
}
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:18,代码来源:PropertiesShiroAuthProviderTest.java
示例9: setupAuthenticationRoutes
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Override
protected AuthProvider setupAuthenticationRoutes() {
AppGlobals globals = AppGlobals.get();
AuthProvider auth = ShiroAuth.create(globals.getVertx(), new ShiroAuthOptions()
.setType(ShiroAuthRealmType.PROPERTIES)
.setConfig(new JsonObject()
.put("properties_path", globals.getConfig().getString("security_definitions"))));
globals.getRouter().route().handler(UserSessionHandler.create(auth));
JsonObject keyStoreOptions = new JsonObject().put("keyStore", globals.getConfig().getJsonObject("keystore"));
// attempt to load a Key file
JWTAuth jwtAuth = JWTAuth.create(globals.getVertx(), new JWTAuthOptions(keyStoreOptions));
JWTAuthHandler jwtAuthHandler = JWTAuthHandler.create(jwtAuth);
globals.setGlobal(JWTAuth.class, jwtAuth);
globals.getRouter().route().handler(context -> {
// only filter if we have a header, otherwise it will try to force auth, regardless if whether
// we want auth
if(context.request().getHeader(HttpHeaders.AUTHORIZATION) != null)
jwtAuthHandler.handle(context);
else
context.next();
});
return auth;
}
开发者ID:FroMage,项目名称:redpipe,代码行数:30,代码来源:WikiServer.java
示例10: testSecure
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Test
public void testSecure(TestContext context) {
Async async = context.async();
server = createServer(context, new HttpTermOptions().setAuthOptions(
new ShiroAuthOptions().
setType(ShiroAuthRealmType.PROPERTIES).
setConfig(new JsonObject().put("properties_path", "classpath:test-auth.properties"))).setPort(8080));
server.termHandler(term -> {
term.write("hello");
});
server.listen(context.asyncAssertSuccess(server -> {
HttpClient client = vertx.createHttpClient();
client.websocket(8080, "localhost", basePath + "/shell/websocket", ws -> {
context.fail();
}, err -> {
// Retry now with auth
client.websocket(8080, "localhost", basePath + "/shell/websocket",
new CaseInsensitiveHeaders().add("Authorization", "Basic " + Base64.getEncoder().encodeToString("tim:sausages".getBytes())),
ws -> {
ws.handler(buf -> {
context.assertEquals("hello", buf.toString());
async.complete();
});
}, context::fail);
});
}));
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:28,代码来源:HttpTermServerBase.java
示例11: testNoKeyPairConfigured
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Test
public void testNoKeyPairConfigured() throws Exception {
try {
startShell(new SSHTermOptions().setPort(5000).setHost("localhost").
setAuthOptions(new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(
new JsonObject().put("properties_path", "classpath:test-auth.properties")))
);
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof VertxException);
assertEquals("No key pair store configured", e.getCause().getMessage());
}
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:13,代码来源:SSHTestBase.java
示例12: setUp
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Before
public void setUp(TestContext context) {
vertx = rule.vertx();
JsonObject config = new JsonObject().put("properties_path", "classpath:test-auth.properties");
AuthProvider provider = ShiroAuth.create(vertx, new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(config));
server = StompServer.create(vertx, new StompServerOptions().setSecured(true))
.handler(StompServerHandler.create(vertx).authProvider(provider))
.listen(context.asyncAssertSuccess());
}
开发者ID:vert-x3,项目名称:vertx-stomp,代码行数:10,代码来源:SecuredServerConnectionTest.java
示例13: setUp
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties");
authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, authConfig);
usernameParam = FormLoginHandler.DEFAULT_USERNAME_PARAM;
passwordParam = FormLoginHandler.DEFAULT_PASSWORD_PARAM;
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:9,代码来源:RedirectAuthHandlerTest.java
示例14: testAuthorisation
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
protected void testAuthorisation(String username, boolean fail, Set<String> authorities) throws Exception {
if (requiresSession()) {
router.route().handler(BodyHandler.create());
router.route().handler(CookieHandler.create());
SessionStore store = getSessionStore();
router.route().handler(SessionHandler.create(store));
}
JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties");
AuthProvider authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, authConfig);
AuthHandler authHandler = createAuthHandler(authProvider);
if (authorities != null) {
authHandler.addAuthorities(authorities);
}
router.route().handler(rc -> {
// we need to be logged in
if (rc.user() == null) {
JsonObject authInfo = new JsonObject().put("username", username).put("password", "delicious:sausages");
authProvider.authenticate(authInfo, res -> {
if (res.succeeded()) {
rc.setUser(res.result());
rc.next();
} else {
rc.fail(res.cause());
}
});
}
});
router.route().handler(authHandler);
router.route().handler(rc -> rc.response().end());
testRequest(HttpMethod.GET, "/", fail ? 403: 200, fail? "Forbidden": "OK");
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:33,代码来源:AuthHandlerTestBase.java
示例15: testSendRequiresAuthorityHasAuthority
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Test
public void testSendRequiresAuthorityHasAuthority() throws Exception {
sockJSHandler.bridge(defaultOptions.addInboundPermitted(new PermittedOptions().setAddress(addr).setRequiredAuthority("bang_sticks")));
router.clear();
router.route().handler(CookieHandler.create());
SessionStore store = LocalSessionStore.create(vertx);
router.route().handler(SessionHandler.create(store));
JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties");
AuthProvider authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, authConfig);
addLoginHandler(router, authProvider);
router.route("/eventbus/*").handler(sockJSHandler);
testSend("foo");
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:14,代码来源:EventbusBridgeTest.java
示例16: testSendRequiresAuthorityHasnotAuthority
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Test
public void testSendRequiresAuthorityHasnotAuthority() throws Exception {
sockJSHandler.bridge(defaultOptions.addInboundPermitted(new PermittedOptions().setAddress(addr).setRequiredAuthority("pick_nose")));
router.clear();
router.route().handler(CookieHandler.create());
SessionStore store = LocalSessionStore.create(vertx);
router.route().handler(SessionHandler.create(store));
JsonObject authConfig = new JsonObject().put("properties_path", "classpath:login/loginusers.properties");
AuthProvider authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, authConfig);
addLoginHandler(router, authProvider);
router.route("/eventbus/*").handler(sockJSHandler);
testError(new JsonObject().put("type", "send").put("address", addr).put("body", "foo"), "access_denied");
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:14,代码来源:EventbusBridgeTest.java
示例17: assertResolve
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
private void assertResolve(File cwd, String path) {
try {
System.setProperty("vertx.cwd", cwd.getAbsolutePath());
ShiroAuth.create(vertx,
ShiroAuthRealmType.PROPERTIES,
new JsonObject().put(PropertiesProviderConstants.PROPERTIES_PROPS_PATH_FIELD, path));
} finally {
System.clearProperty("vertx.cwd");
}
}
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:11,代码来源:PropertiesShiroAuthProviderTest.java
示例18: setUp
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
ldapServer = new EmbeddedADS(ldapWorkingDirectory.newFolder());
ldapServer.startServer();
insertTestUsers();
authProvider = ShiroAuth.create(vertx, ShiroAuthRealmType.LDAP, getConfig());
}
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:9,代码来源:LDAPShiroAuthProviderTest.java
示例19: testSomething
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
@Test
public void testSomething() {
ShiroAuthOptions options = new ShiroAuthOptions(
new JsonObject().put("provider", "shiro").
put("type", "PROPERTIES").
put("config", new JsonObject().put("foo", "bar")));
assertEquals(ShiroAuthRealmType.PROPERTIES, options.getType());
assertEquals(new JsonObject().put("foo", "bar"), options.getConfig());
}
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:10,代码来源:AuthOptionsTest.java
示例20: main
import io.vertx.ext.auth.shiro.ShiroAuthRealmType; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Vertx vertx = Vertx.vertx();
CommandRegistry mgr = CommandRegistry.getShared(vertx);
CommandBuilder echoKeyboardCmd = CommandBuilder.command("echo-keyboard");
echoKeyboardCmd.processHandler(process -> {
process.stdinHandler(line -> {
process.write("-> " + line + "\n");
});
process.interruptHandler(v -> process.end());
});
mgr.registerCommand(echoKeyboardCmd.build(vertx));
CommandBuilder windowCmd = CommandBuilder.command("window");
windowCmd.processHandler(process -> {
process.write("[" + process.width() + "," + process.height() + "]\n");
process.resizehandler(v -> {
process.write("[" + process.width() + "," + process.height() + "]\n");
});
process.interruptHandler(v -> {
process.end();
});
});
mgr.registerCommand(windowCmd.build(vertx));
CommandBuilder charsetTestCmd = CommandBuilder.command("charset-test");
charsetTestCmd.processHandler(process -> {
process.write("\u20AC").end();
});
mgr.registerCommand(charsetTestCmd.build(vertx));
// JS command
// vertx.deployVerticle("command.js");
// Expose the shell
ShiroAuthOptions authOptions = new ShiroAuthOptions().
setType(ShiroAuthRealmType.PROPERTIES).
setConfig(new JsonObject().put("properties_path", "file:src/test/resources/test-auth.properties"));
SSHTermOptions options = new SSHTermOptions().setPort(5001);
options.setKeyPairOptions(new JksOptions().
setPath("src/test/resources/server-keystore.jks").
setPassword("wibble")).
setAuthOptions(
authOptions
);
ShellService service = ShellService.create(vertx, new ShellServiceOptions().
setTelnetOptions(new TelnetTermOptions().setPort(5000)).
setSSHOptions(options).
setHttpOptions(new HttpTermOptions().
setPort(8080).
setAuthOptions(authOptions)
)
);
service.start();
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:59,代码来源:Main.java
注:本文中的io.vertx.ext.auth.shiro.ShiroAuthRealmType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论