本文整理汇总了Java中io.vertx.ext.web.handler.CookieHandler类的典型用法代码示例。如果您正苦于以下问题:Java CookieHandler类的具体用法?Java CookieHandler怎么用?Java CookieHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CookieHandler类属于io.vertx.ext.web.handler包,在下文中一共展示了CookieHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的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.CookieHandler; //导入依赖的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: configure
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的package包/类
@Override
public SockJSHandler configure(VertxContext vertxContext, ServerConfiguration<JsonObject, JsonObject[]> config) {
JsonObject sockJsConfig=config.getJsonObject(CONFIG_KEY, makeDefaultConfig());
BridgeOptions bridgeOptions = configureBridgeOptions(sockJsConfig);
SockJSHandler sockJSHandler = configureSockJsHandler(vertxContext, bridgeOptions, sockJsConfig);
boolean CSRFProteceted=sockJsConfig.getBoolean(CSRF_PROTECTED, false);
if(CSRFProteceted) {
if(config.getString(CSRF_SECRET, EMPTY_CSRF_SECRET).isEmpty() || config.getString(CSRF_SECRET,
EMPTY_CSRF_SECRET).length()<12)
throw new CsrfProtectionEnabledBuInvalidSecretProvided();
vertxContext.router().route().path(VertxBusContext.DEFAULT_EVENTBUS_PATH).handler(CookieHandler.create());
vertxContext.router().route().path(VertxBusContext.DEFAULT_EVENTBUS_PATH).handler(
CSRFHandler.create(config.getString(CSRF_SECRET, EMPTY_CSRF_SECRET)));
}
return sockJSHandler;
}
示例4: start
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的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")));
}
示例5: start
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的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);
}
示例6: start
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的package包/类
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create());
router.route().handler(CookieHandler.create());
bootstrap.getInjector().getInstance(ApplicationVertxRoutes.class).init(router, vertx);
httpServer = vertx.createHttpServer();
httpServer.requestHandler(router::accept).listen(getPort(), res -> {
if (res.succeeded()) {
log.info("Server is now listening. Thread:" + Thread.currentThread());
} else {
log.info("Failed to bind. Thread:" + Thread.currentThread(), res.cause());
}
});
}
示例7: initAPIRouter
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的package包/类
/**
* Initialise the Root API router and add common handlers to the router. The API router is used to attach subrouters for routes like
* /api/v1/[groups|users|roles]
*/
private void initAPIRouter() {
Router router = getAPIRouter();
if (Mesh.mesh().getOptions().getHttpServerOptions().isCorsEnabled()) {
router.route().handler(corsHandler);
}
router.route().handler(rh -> {
// Connection upgrade requests never end and therefore the body
// handler will never
// pass through to the subsequent route handlers.
if ("websocket".equalsIgnoreCase(rh.request().getHeader("Upgrade"))) {
rh.next();
} else {
bodyHandler.handle(rh);
}
});
router.route().handler(CookieHandler.create());
}
示例8: start
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的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);
}
示例9: start
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的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);
}
示例10: setUp
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的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);
}
示例11: init
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的package包/类
@Override
public void init(Router router) {
String regex = "/api/([^\\\\/]+)/([^\\\\/]+)/(.*)";
router.routeWithRegex(regex).handler(CookieHandler.create());
router.routeWithRegex(regex).handler(createBodyHandler());
router.routeWithRegex(regex).failureHandler(this::onFailure).handler(this::onRequest);
}
示例12: mount
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的package包/类
@Override
public void mount(final Router router) {
// 1. Cookie, Body
router.route()
.order(Orders.COOKIE)
.handler(CookieHandler.create());
router.route()
.order(Orders.BODY)
.handler(BodyHandler.create());
// 2. Cors Template Solution
router.route()
.order(Orders.CORS)
.handler(CorsHandler.create("*")
.allowCredentials(false)
.allowedHeaders(new HashSet<String>() {
{
add(HttpHeaders.AUTHORIZATION);
add(HttpHeaders.CONTENT_LENGTH);
add(HttpHeaders.CONTENT_TYPE);
}
})
.allowedMethods(new HashSet<HttpMethod>() {
{
add(HttpMethod.DELETE);
add(HttpMethod.GET);
add(HttpMethod.POST);
add(HttpMethod.PUT);
}
}));
}
示例13: VertxNubes
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的package包/类
/**
* @param vertx the vertx instance
*/
public VertxNubes(Vertx vertx, JsonObject json) {
this.vertx = vertx;
config = Config.fromJsonObject(json, vertx);
deploymentIds = new ArrayList<>();
registry = new ParameterAdapterRegistry();
marshallers = new HashMap<>();
config.setMarshallers(marshallers);
config.createAnnotInjectors(registry);
// marshalling
TemplateEngineManager templManager = new TemplateEngineManager(config);
registerAnnotationProcessor(View.class, new ViewProcessorFactory(templManager));
registerAnnotationProcessor(File.class, new FileProcessorFactory());
registerMarshaller("text/plain", new PlainTextMarshaller());
registerMarshaller("application/json", new JacksonPayloadMarshaller());
String domainPackage = config.getDomainPackage();
if (domainPackage != null) {
try {
Reflections reflections = new Reflections(domainPackage, new SubTypesScanner(false));
registerMarshaller("application/xml", new JAXBPayloadMarshaller(reflections.getSubTypesOf(Object.class)));
} catch (JAXBException je) {
throw new VertxException(je);
}
}
failureHandler = new DefaultErrorHandler(config, templManager, marshallers);
// default processors/handlers
CookieHandler cookieHandler = CookieHandler.create();
registerAnnotationHandler(Cookies.class, cookieHandler);
registerAnnotationHandler(CookieValue.class, cookieHandler);
registerAnnotationHandler(Throttled.class, RateLimitationHandler.create(config));
registerTypeProcessor(PaginationContext.class, new PaginationProcessor());
registerTypeProcessor(Payload.class, new PayloadTypeProcessor(marshallers));
registerAnnotationProcessor(Redirect.class, new ClientRedirectProcessorFactory());
registerAnnotationProcessor(ContentType.class, new ContentTypeProcessorFactory());
registerAnnotationProcessor(Logout.class, new LogoutProcessor());
}
示例14: startWebServer
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的package包/类
/**
* Start a web server to define a standard set of endpoints for testing, and provide extension points for both
* decorating/configuring the auth handler, and also for configuring the router (for example adding additional
* endpoints)
* @param baseAuthUrl - the baseline authentication url
* @param options - SecurityHandler options for configuring the main security handler
* @param callbackHandlerOptions - CallbackHandlerOptions for configuring the callback handler
* @param requiredPermissions - list of required permissions to access the protected endpoint
* @param routerDecorator - modifications to the router (for example addition of custom endpoints for a test
* @throws Exception - any exception when running this code should trigger test failure
*/
protected void startWebServer(final String baseAuthUrl,
final SecurityHandlerOptions options,
final CallbackHandlerOptions callbackHandlerOptions,
final List<String> requiredPermissions,
final BiConsumer<Router, Config> routerDecorator) throws Exception {
final Router router = Router.router(vertx);
final Pac4jAuthProvider authProvider = new Pac4jAuthProvider();
final SessionStore sessionStore = sessionStore();
final Config config = config(clients(baseAuthUrl), requiredPermissions);
config.setHttpActionAdapter(new DefaultHttpActionAdapter());
router.route().handler(CookieHandler.create());
router.route().handler(sessionHandler(sessionStore));
router.route().handler(UserSessionHandler.create(authProvider));
CallbackDeployingPac4jAuthHandler pac4jAuthHandler = authHandler(router,
authProvider,
baseAuthUrl,
options,
callbackHandlerOptions,
requiredPermissions);
routerDecorator.accept(router, config);
startWebServer(router, pac4jAuthHandler);
}
示例15: init
import io.vertx.ext.web.handler.CookieHandler; //导入依赖的package包/类
@Override
public void init(Router router) {
router.route().handler(CookieHandler.create());
router.route().handler(createBodyHandler());
router.route().failureHandler(this::failureHandler).handler(this::onRequest);
}