本文整理汇总了Java中io.vertx.ext.auth.shiro.ShiroAuthRealmType类的典型用法代码示例。如果您正苦于以下问题:Java ShiroAuthRealmType类的具体用法?Java ShiroAuthRealmType怎么用?Java ShiroAuthRealmType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShiroAuthRealmType类属于io.vertx.ext.auth.shiro包,在下文中一共展示了ShiroAuthRealmType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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());
}
示例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");
}
示例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());
}
示例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;
}
示例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);
});
}));
}
示例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());
}
}
示例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());
}
示例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;
}
示例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");
}
示例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");
}