本文整理汇总了Java中io.vertx.ext.web.handler.SessionHandler类的典型用法代码示例。如果您正苦于以下问题:Java SessionHandler类的具体用法?Java SessionHandler怎么用?Java SessionHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionHandler类属于io.vertx.ext.web.handler包,在下文中一共展示了SessionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的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.handler.SessionHandler; //导入依赖的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.handler.SessionHandler; //导入依赖的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.handler.SessionHandler; //导入依赖的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: start
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的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);
}
示例6: start
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的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);
}
示例7: setUp
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的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);
}
示例8: router
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
protected Router router() {
return RouterBuilder.create(vertx)
.scanClasspath(true)
.authHandler(this::authHandler)
.addHandler(SessionHandler.create(ClusteredSessionStore.create(vertx)))
.build();
}
示例9: router
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
protected Router router() {
// TODO retrieve plug and play routes to api
return RouterBuilder.create(vertx)
.scanClasspath(false)
.authHandler(this::authHandler)
.addHandler(TidHandler.create())
.addHandler(ResponseTimeHandler.create())
.addHandler(SessionHandler.create(ClusteredSessionStore.create(vertx)))
.addRoute(GatewayProxyRoute.class)
.addRoute(UAARoute.class)
.build();
}
示例10: startWebApp
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的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);
}
示例11: addBasicRoute
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
private void addBasicRoute(JsonObject conf) {
router.route().handler(CookieHandler.create());
BodyHandler bh = BodyHandler.create();
bh.setMergeFormAttributes(false);
bh.setUploadsDirectory(this.upload_dir);
// bh.setDeleteUploadedFilesOnEnd(false);
router.route().handler(bh);
String hasSession = conf.getString("session","true");
if("true".equals(hasSession)){
SessionStore sessionStore = null;
if (vertx.isClustered())
sessionStore = ClusteredSessionStore.create(vertx,SessionName);
else
sessionStore = LocalSessionStore.create(vertx,SessionName);
SessionHandler sessionHandler = SessionHandler.create(sessionStore);
sessionHandler.setNagHttps(false).setCookieHttpOnlyFlag(true);
Long sessionTimeount = conf.getLong("session.timeout");
if(sessionTimeount!=null && sessionTimeount>0)
sessionHandler.setSessionTimeout(sessionTimeount);
router.route().handler(sessionHandler);
if(gsetting.hasAuth() && !this.appContain.isEmpty()){
router.route().handler(UserSessionHandler.create(authMgr.authProvider));
GateAuthHandler authHandler = new GateAuthHandler(authMgr);
router.route().handler(authHandler::handle);
}
}
router.route().failureHandler(rc->{
HttpServerResponse response = rc.response();
if(response.ended())
return;
int statusCode = rc.statusCode() == -1 ? 500 : rc.statusCode();
log.error("Error,status code: {}. ",statusCode);
response.setStatusCode(statusCode).end("status code:"+statusCode);
});
}
示例12: preconfigureRouting
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
@Override
protected void preconfigureRouting(final Router router) {
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)).setSessionTimeout(SESSION_TTL));
}
示例13: createRouter
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
static Router createRouter() {
Router router = Router.router(vertx);
SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
sockJSHandler.bridge(eventBusBridgeOptions());
router.route("/eventbus/*").handler(sockJSHandler);
router.route().handler(CookieHandler.create());
SessionStore store = LocalSessionStore.create(vertx);
SessionHandler sessionHandler = SessionHandler.create(store);
router.route().handler(sessionHandler);
return router;
}
示例14: enableLocalSession
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
/**
* Enable local session storage in requests.
*
* @param router router instance
*/
protected void enableLocalSession(Router router) {
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(
LocalSessionStore.create(vertx, "shopping.user.session")));
}
示例15: enableClusteredSession
import io.vertx.ext.web.handler.SessionHandler; //导入依赖的package包/类
/**
* Enable clustered session storage in requests.
*
* @param router router instance
*/
protected void enableClusteredSession(Router router) {
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(
ClusteredSessionStore.create(vertx, "shopping.user.session")));
}