本文整理汇总了Java中io.vertx.ext.web.sstore.LocalSessionStore类的典型用法代码示例。如果您正苦于以下问题:Java LocalSessionStore类的具体用法?Java LocalSessionStore怎么用?Java LocalSessionStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocalSessionStore类属于io.vertx.ext.web.sstore包,在下文中一共展示了LocalSessionStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
int serverPort = Config.getIntValue("serverPort");
router.route().handler(BodyHandler.create().setUploadsDirectory("files"));
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
Routing.route(router, "com.planb.restful");
router.route().handler(StaticHandler.create());
new Parser().start();
Log.info("Server Started At : " + serverPort);
vertx.createHttpServer().requestHandler(router::accept).listen(serverPort);
}
示例2: start
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
int serverPort = Config.getIntValue("serverPort");
router.route().handler(BodyHandler.create().setUploadsDirectory("files"));
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
router.route().handler(CORSHandler.create());
router.route().handler(LogHandler.create());
Routing.route(router, "com.planb.restful");
router.route().handler(StaticHandler.create());
Log.info("Server Started At : " + serverPort);
vertx.createHttpServer().requestHandler(router::accept).listen(serverPort);
}
示例3: start
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
public void start() throws Exception {
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create().setUploadsDirectory("upload-files"));
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)).setNagHttps(false));
router.route().handler(RequestSecurePreprocessor.create());
RouteRegister.registerRouters(router, "com.dms.secure", "com.dms.api", "com.dms.templates");
router.route("/js/*").handler(StaticHandler.create().setCachingEnabled(false).setWebRoot("WEB-INF/js/"));
/*
* @see com.dms.planb.support .TableDropper
*/
HttpServerOptions httpOpts = new HttpServerOptions();
/*System.out.println(SecureConfig.get("SSL_PATH"));
System.out.println(SecureConfig.get("SSL"));
httpOpts.setSsl(true)
.setKeyStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")))
.setTrustStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")));
*/
vertx.createHttpServer(httpOpts).requestHandler(router::accept).listen(Integer.parseInt(SecureConfig.get("SERVER_PORT")));
}
示例4: start
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
public void start() throws Exception {
Router router = Router.router(vertx);
int serverPort = Config.getIntValue("serverPort");
router.route().handler(BodyHandler.create().setUploadsDirectory("upload-files"));
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
router.route().handler(CORSHandler.create());
router.route().handler(LogHandler.create());
Routing.route(router, "com.planb.restful");
router.route().handler(StaticHandler.create());
// new ParserThread().start();
Log.info("Server Started");
vertx.createHttpServer().requestHandler(router::accept).listen(serverPort);
}
示例5: createRouter
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
private Router createRouter() {
Router router = Router.router(vertx);
router.route().failureHandler(ErrorHandler.create(true));
/* Static resources */
staticHandler(router);
/* Session / cookies for users */
router.route().handler(CookieHandler.create());
SessionStore sessionStore = LocalSessionStore.create(vertx);
SessionHandler sessionHandler = SessionHandler.create(sessionStore);
router.route().handler(sessionHandler);
userContextHandler = new UserContextHandler(mongo);
/* Dynamic pages */
dynamicPages(router);
/* API */
router.mountSubRouter("/api", apiRouter());
/* SockJS / EventBus */
router.route("/eventbus/*").handler(eventBusHandler());
return router;
}
示例6: start
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的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);
}
示例7: attachHandlersToRouter
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
public void attachHandlersToRouter(Router router) {
config.forEachGlobalHandler(handler -> router.route(httpMethod, path).handler(handler));
final Vertx vertx = config.getVertx();
if (authHandler != null) {
attachAuthHandler(router, vertx);
} else if (usesSession) {
router.route(httpMethod, path).handler(SessionHandler.create(LocalSessionStore.create(vertx)));
}
handlers.forEach(handler ->
router.route(httpMethod, path).handler(handler)
);
attachPreProcessingHandlers(router);
boolean hasPostProcessors = redirectRoute != null || postInterceptor != null || !afterFilters.isEmpty()|| !processors.isEmpty();
setHandler(router, mainHandler, hasPostProcessors);
if (redirectRoute != null) {
// intercepted -> redirected => do not call post processing handlers
router.route(httpMethod, path).handler(ctx ->
ctx.reroute(redirectRoute.method(), redirectRoute.path())
);
}
attachPostProcessingHandlers(router);
}
示例8: start
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的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);
}
示例9: testGetSessionById
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Test
public void testGetSessionById() throws Exception {
final Vertx vertx = Vertx.vertx();
// We need to create a pre-programmed vertx session so we can validate
final LocalSessionStore vertxSessionStore = LocalSessionStore.create(vertx);
final io.vertx.ext.web.Session vertxSession = vertxSessionStore.createSession(300000);
final CountDownLatch latch = new CountDownLatch(1);
vertxSessionStore.put(vertxSession, b -> latch.countDown());
latch.await(1, TimeUnit.SECONDS);
vertxSession.put(TEST_SESSION_KEY, TEST_SESSION_VALUE);
final String sessionId = vertxSession.id();
// Now let's wrap in a pac4j sessionStore
final ExtendedSessionStore<VertxWebContext> pac4jSessionStore = new VertxSessionStore(vertxSessionStore);
final org.pac4j.vertx.context.session.Session pac4jSession = pac4jSessionStore.getSession(sessionId);
assertThat(pac4jSession, is(notNullValue()));
assertThat(pac4jSession.get(TEST_SESSION_KEY), is(TEST_SESSION_VALUE));
}
示例10: setUp
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的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());
}
示例11: setUp
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
client = vertx.createHttpClient(new HttpClientOptions().setDefaultPort(8080));
router = Router.router(vertx);
router.route().handler(CookieHandler.create());
router.route()
.handler(SessionHandler.create(LocalSessionStore.create(vertx))
.setNagHttps(false)
.setSessionTimeout(60 * 60 * 1000));
addHandlersBeforeSockJSHandler(router);
SockJSHandlerOptions options = new SockJSHandlerOptions().setHeartbeatInterval(2000);
sockJSHandler = SockJSHandler.create(vertx, options);
router.route("/test/*").handler(sockJSHandler);
server = vertx.createHttpServer(new HttpServerOptions().setPort(8080).setHost("localhost"));
CountDownLatch latch = new CountDownLatch(1);
server.requestHandler(router::accept).listen(ar -> latch.countDown());
awaitLatch(latch);
}
示例12: addSessionHandler
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
private void addSessionHandler(Vertx vertx, Router router) {
SessionStore
sessionStore = clustered ? ClusteredSessionStore.create(vertx) : LocalSessionStore
.create(vertx);
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler
.create(sessionStore)
.setCookieHttpOnlyFlag(true)
.setCookieSecureFlag(true)
);
}
示例13: shouldAdaptLocalSessionStore
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Test
public void shouldAdaptLocalSessionStore() {
long before = Instant.now().toEpochMilli();
SessionStore adapted = SessionStoreAdapter.adapt(vertx, LocalSessionStore.create(vertx));
assertThat(adapted).isInstanceOf(LocalSessionStoreAdapter.class);
Session session = adapted.createSession(1000);
assertThat(session).isInstanceOf(ExtendedSession.class);
ExtendedSession extendedSession = (ExtendedSession) session;
assertThat(extendedSession.createdAt()).isBetween(before, Instant.now().toEpochMilli());
}
示例14: shouldFireSessionExpiredEventForLocalSessionStore
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
@Test(timeout = 5000L)
public void shouldFireSessionExpiredEventForLocalSessionStore(TestContext context) {
Async async = context.async();
SessionStore adapted = SessionStoreAdapter.adapt(vertx, LocalSessionStore.create(vertx));
Session session = adapted.createSession(1000);
sessionExpiredConsumer = SessionStoreAdapter.sessionExpiredHandler(vertx, event -> {
context.assertEquals(session.id(), event.body());
async.countDown();
});
adapted.put(session, Future.<Boolean>future().completer());
session.put("a", "b");
}
示例15: startWebApp
import io.vertx.ext.web.sstore.LocalSessionStore; //导入依赖的package包/类
private void startWebApp(int port){
SessionStore store = LocalSessionStore.create(vertx, appName + ".sessionmap");
SessionHandler sessionHandler = SessionHandler.create(store);
ServerVerticle serverVerticle = context.getBean(ServerVerticle.class);
serverVerticle.setPort(port);
serverVerticle.setSessionHandler(sessionHandler);
vertx.deployVerticle(serverVerticle);
}