本文整理汇总了Java中org.tuckey.web.filters.urlrewrite.UrlRewriteFilter类的典型用法代码示例。如果您正苦于以下问题:Java UrlRewriteFilter类的具体用法?Java UrlRewriteFilter怎么用?Java UrlRewriteFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UrlRewriteFilter类属于org.tuckey.web.filters.urlrewrite包,在下文中一共展示了UrlRewriteFilter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rewriteFilterConfig
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; //导入依赖的package包/类
@Bean
public FilterRegistrationBean rewriteFilterConfig() {
FilterRegistrationBean reg = new FilterRegistrationBean();
reg.setName(REWRITE_FILTER_NAME);
reg.setFilter(new UrlRewriteFilter());
reg.addInitParameter("confPath", REWRITE_FILTER_CONF_PATH);
reg.addInitParameter("confReloadCheckInterval", "-1");
reg.addInitParameter("statusPath", "/redirect");
reg.addInitParameter("statusEnabledOnHosts", "*");
reg.addInitParameter("logLevel", "WARN");
return reg;
}
示例2: beforeSpringSecurityFilterChain
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; //导入依赖的package包/类
@Override
protected void beforeSpringSecurityFilterChain(final ServletContext servletContext) {
// Be sure charsetFilters are registered before spring security, otherwise logins will fail in tomcat with non-ascii passwords
initCharacterSetFilter(servletContext);
insertFilters(servletContext,
new UncaughtExceptionFilter(),
new MDCInsertingServletFilter(),
new UrlRewriteFilter());
}
示例3: filterRegistrationBean
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; //导入依赖的package包/类
/**
* register filter bean.
*
* @return FilterRegistrationBean
*/
@Bean
public FilterRegistrationBean filterRegistrationBean() {
final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(new UrlRewriteFilter());
registrationBean.addUrlPatterns("*");
registrationBean.addInitParameter("confReloadCheckInterval", "5");
registrationBean.addInitParameter("logLevel", "INFO");
return registrationBean;
}
示例4: run
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; //导入依赖的package包/类
@Override
public void run(MappedJsonConfiguration metadictConfiguration, Environment environment) throws Exception {
// Define default mapping URL pattern for resources
environment.jersey().setUrlPattern("/api/*");
// Configure url rewrite filter
FilterRegistration.Dynamic rewrite = environment.servlets()
.addFilter("UrlRewriteFilter", new UrlRewriteFilter());
rewrite.setInitParameter("confPath", "urlrewrite.xml");
rewrite.addMappingForUrlPatterns(EnumSet.of(DispatcherType.FORWARD, DispatcherType.REQUEST), true, "/*");
}
示例5: beforeClass
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
ServletHelper.init();
httpUtil = new HttpTestUtil(new HttpTestUtil.ContextCustomizer() {
public void customize(WebAppContext ctx) throws Exception {
wac = mock(WebApplicationContext.class);
ctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
URL resource = getClass().getClassLoader().getResource("WEB-INF/urlrewrite.xml");
if (resource == null) {
throw new RuntimeException("Cannot load WEB-INF/urlrewrite.xml");
}
ctx.setBaseResource(Resource.newResource(new File(resource.getFile()).getParent()));
ctx.addFilter(UrlRewriteFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)).setInitParameter("confPath", "/urlrewrite.xml");
ctx.addServlet(HttpTestUtil.EchoServlet.class, "/*");
}
});
httpUtil.httpConnector(HTTP);
httpUtil.httpsConnector(HTTPS);
when(wac.getBean("serverConfigService")).thenReturn(new BaseUrlProvider() {
public boolean hasAnyUrlConfigured() {
return useConfiguredUrls;
}
public String siteUrlFor(String url, boolean forceSsl) throws URISyntaxException {
ServerSiteUrlConfig siteUrl = forceSsl ? new ServerSiteUrlConfig("https://127.2.2.2:" + 9071) : new ServerSiteUrlConfig("http://127.2.2.2:" + 5197);
return siteUrl.siteUrlFor(url);
}
});
httpUtil.start();
originalSslPort = System.getProperty(SystemEnvironment.CRUISE_SERVER_SSL_PORT);
System.setProperty(SystemEnvironment.CRUISE_SERVER_SSL_PORT, String.valueOf(9071));
}
示例6: setUp
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
UrlRewriteFilter filter =
createUrlFilter(SiteApplication.REWRITE_FILTER_NAME,
SiteApplication.REWRITE_FILTER_CONF_PATH);
filterChain = new PassThroughFilterChain(filter, new MockFilterChain());
}
示例7: createUrlFilter
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; //导入依赖的package包/类
private UrlRewriteFilter createUrlFilter(String filterName, String mappingsFile) throws ServletException {
UrlRewriteFilter newFilter = new UrlRewriteFilter();
MockFilterConfig filterConfig = new MockFilterConfig(filterName);
filterConfig.addInitParameter("confPath", mappingsFile);
filterConfig.addInitParameter("logLevel", "WARN");
newFilter.init(filterConfig);
return newFilter;
}
示例8: run
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; //导入依赖的package包/类
@Override
public void run(AppConfiguration configuration, Environment environment) {
// password encoder
final PasswordEncoder passwordEncoder = new PasswordEncoder();
// DAO
final CategoryDAO categoryDAO = new CategoryDAO(hibernate.getSessionFactory(), configuration);
final BudgetDAO budgetDAO = new BudgetDAO(hibernate.getSessionFactory(), configuration);
final BudgetTypeDAO budgetTypeDAO = new BudgetTypeDAO(hibernate.getSessionFactory());
final UserDAO userDAO = new UserDAO(hibernate.getSessionFactory());
final TransactionDAO transactionDAO = new TransactionDAO(hibernate.getSessionFactory());
final RecurringDAO recurringDAO = new RecurringDAO(hibernate.getSessionFactory());
final AuthTokenDAO authTokenDAO = new AuthTokenDAO(hibernate.getSessionFactory());
// service
final FinanceService financeService = new FinanceService(userDAO, budgetDAO, budgetTypeDAO, categoryDAO, transactionDAO, recurringDAO, authTokenDAO, passwordEncoder);
// jobs
final RecurringJob recurringJob = new UnitOfWorkAwareProxyFactory(hibernate).create(RecurringJob.class, FinanceService.class, financeService);
// resource
environment.jersey().register(new UserResource(financeService));
environment.jersey().register(new CategoryResource(financeService));
environment.jersey().register(new BudgetResource(financeService));
environment.jersey().register(new TransactionResource(financeService));
environment.jersey().register(new RecurringResource(financeService));
environment.jersey().register(new ReportResource(financeService));
// health check
environment.jersey().register(new HealthCheckResource(environment.healthChecks()));
// managed
environment.lifecycle().manage(new MigrationManaged(configuration));
environment.lifecycle().manage(new JobsManaged(recurringJob));
// auth
TokenAuthenticator tokenAuthenticator = new UnitOfWorkAwareProxyFactory(hibernate).create(TokenAuthenticator.class, FinanceService.class, financeService);
final OAuthCredentialAuthFilter<User> authFilter =
new OAuthCredentialAuthFilter.Builder<User>()
.setAuthenticator(tokenAuthenticator)
.setPrefix("Bearer")
.setAuthorizer(new DefaultAuthorizer())
.setUnauthorizedHandler(new DefaultUnauthorizedHandler())
.buildAuthFilter();
environment.jersey().register(RolesAllowedDynamicFeature.class);
environment.jersey().register(new AuthDynamicFeature(authFilter));
environment.jersey().register(new AuthValueFactoryProvider.Binder(User.class));
// filters
FilterRegistration.Dynamic urlRewriteFilter = environment.servlets().addFilter("rewriteFilter", UrlRewriteFilter.class);
urlRewriteFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, "/*");
urlRewriteFilter.setInitParameter("confPath", "urlrewrite.xml");
// only enable for dev
// FilterRegistration.Dynamic filterSlow = environment.servlets().addFilter("slowFilter", SlowNetworkFilter.class);
// filterSlow.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, "/*");
// exception mapper
environment.jersey().register(new NotFoundExceptionMapper());
environment.jersey().register(new DataConstraintExceptionMapper());
environment.jersey().register(new ConstraintViolationExceptionMapper());
environment.jersey().register(new SQLConstraintViolationExceptionMapper());
}
示例9: init
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; //导入依赖的package包/类
public void init(FilterConfig filterConfig) throws ServletException {
urlRewriteFilter = new UrlRewriteFilter();
urlRewriteFilter.init(new FilterConfigWrapper(filterConfig, getInitParameters()));
}