当前位置: 首页>>代码示例>>Java>>正文


Java LocalSessionStore.create方法代码示例

本文整理汇总了Java中io.vertx.ext.web.sstore.LocalSessionStore.create方法的典型用法代码示例。如果您正苦于以下问题:Java LocalSessionStore.create方法的具体用法?Java LocalSessionStore.create怎么用?Java LocalSessionStore.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.ext.web.sstore.LocalSessionStore的用法示例。


在下文中一共展示了LocalSessionStore.create方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:aesteve,项目名称:vertx-feeds,代码行数:26,代码来源:WebServer.java

示例2: 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));
}
 
开发者ID:pac4j,项目名称:vertx-pac4j,代码行数:21,代码来源:VertxSessionStoreTest.java

示例3: 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)
    );
}
 
开发者ID:GwtDomino,项目名称:domino,代码行数:12,代码来源:RouterConfigurator.java

示例4: 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);
}
 
开发者ID:quebic-source,项目名称:puppy-io,代码行数:11,代码来源:PuppyAppLauncher.java

示例5: example31

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的package包/类
public void example31(Vertx vertx) {

    // Create a local session store using defaults
    SessionStore store1 = LocalSessionStore.create(vertx);

    // Create a local session store specifying the local shared map name to use
    // This might be useful if you have more than one application in the same
    // Vert.x instance and want to use different maps for different applications
    SessionStore store2 = LocalSessionStore.create(vertx, "myapp3.sessionmap");

    // Create a local session store specifying the local shared map name to use and
    // setting the reaper interval for expired sessions to 10 seconds
    SessionStore store3 = LocalSessionStore.create(vertx, "myapp3.sessionmap", 10000);

  }
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:16,代码来源:WebExamples.java

示例6: doLoginCommon

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的package包/类
private void doLoginCommon(Handler<RoutingContext> handler, Set<String> authorities) throws Exception {
  router.route().handler(BodyHandler.create());
  router.route().handler(CookieHandler.create());
  SessionStore store = LocalSessionStore.create(vertx);
  router.route().handler(SessionHandler.create(store));
  router.route().handler(UserSessionHandler.create(authProvider));
  AuthHandler authHandler = RedirectAuthHandler.create(authProvider);
  if (authorities != null) {
    authHandler.addAuthorities(authorities);
  }
  router.route("/protected/*").handler(authHandler);
  router.route("/protected/somepage").handler(handler);
  String loginHTML = createloginHTML();
  router.route("/loginpage").handler(rc -> rc.response().putHeader("content-type", "text/html").end(loginHTML));
  if (formLoginHandler == null) {
    formLoginHandler = FormLoginHandler.create(authProvider);
  }
  router.route("/login").handler(formLoginHandler);
  testRequest(HttpMethod.GET, "/protected/somepage", null, resp -> {
    String location = resp.headers().get("location");
    assertNotNull(location);
    assertEquals("/loginpage", location);
    String setCookie = resp.headers().get("set-cookie");
    assertNotNull(setCookie);
    sessionCookie.set(setCookie);
  }, 302, "Found", null);
  testRequest(HttpMethod.GET, "/loginpage", req -> req.putHeader("cookie", sessionCookie.get()), resp -> {
  }, 200, "OK", loginHTML);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:30,代码来源:RedirectAuthHandlerTest.java

示例7: testSendRequiresAuthorityHasAuthority

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的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

示例8: testSendRequiresAuthorityHasnotAuthority

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的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

示例9: addBasicRoute

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的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);
	});

}
 
开发者ID:troopson,项目名称:etagate,代码行数:49,代码来源:OutServerVerticle.java

示例10: createRouter

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的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;
    }
 
开发者ID:codefacts,项目名称:Elastic-Components,代码行数:21,代码来源:TrackerServer.java

示例11: createSessionStore

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的package包/类
protected SessionStore createSessionStore() {
    if (vertx.isClustered()) {
        return ClusteredSessionStore.create(vertx);
    }
    return LocalSessionStore.create(vertx);
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:7,代码来源:VertxVaadin.java

示例12: setUp

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的package包/类
@Before
public void setUp(TestContext context) {
    vertx = Vertx.vertx();
    localSessionStore = LocalSessionStore.create(vertx);
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:6,代码来源:VertxWrappedSessionWithLocalSessionStoreUT.java

示例13: sessionStore

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的package包/类
private LocalSessionStore sessionStore() {
    return LocalSessionStore.create(vertx);
}
 
开发者ID:pac4j,项目名称:vertx-pac4j,代码行数:4,代码来源:StatefulPac4jAuthHandlerIntegrationTestBase.java

示例14: getSessionStore

import io.vertx.ext.web.sstore.LocalSessionStore; //导入方法依赖的package包/类
protected SessionStore getSessionStore() {
  return LocalSessionStore.create(vertx);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:4,代码来源:AuthHandlerTestBase.java


注:本文中的io.vertx.ext.web.sstore.LocalSessionStore.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。