use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class ContextRelativeResourceCachingTest method mapRequest.
/**
*/
@Test
public void mapRequest() {
ContextRelativeResource resource = new ContextRelativeResource("/style.css");
init(resource, "/test/resource");
IRequestHandler handler = new ResourceReferenceRequestHandler(new SharedResourceReference(SHARED_NAME));
Url url = tester.getApplication().getRootRequestMapper().mapHandler(handler);
assertNotNull(url);
assertEquals(url, Url.parse("test/resource-version-123"));
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class CryptoMapper method mapRequest.
@Override
public IRequestHandler mapRequest(final Request request) {
Url url = decryptUrl(request, request.getUrl());
if (url == null) {
return null;
}
Request decryptedRequest = request.cloneWithUrl(url);
IRequestHandler handler = wrappedMapper.mapRequest(decryptedRequest);
if (handler != null) {
handler = new RequestSettingRequestHandler(decryptedRequest, handler);
}
return handler;
}
use of org.apache.wicket.request.IRequestHandler in project hale by halestudio.
the class BaseWebApplication method init.
@Override
public void init() {
super.init();
BootstrapSettings settings = new BootstrapSettings();
final ThemeProvider themeProvider = new BootswatchThemeProvider() {
{
add(new MetroTheme());
add(new GoogleTheme());
add(new WicketTheme());
add(new Bootstrap3Theme());
defaultTheme("bootstrap-responsive");
// defaultTheme("bootstrap");
}
};
settings.setThemeProvider(themeProvider);
Bootstrap.install(this, settings);
BootstrapLess.install(this);
configureResourceBundles();
IPackageResourceGuard packageResourceGuard = getResourceSettings().getPackageResourceGuard();
if (packageResourceGuard instanceof SecurePackageResourceGuard) {
SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard;
guard.addPattern("+org/apache/wicket/resource/jquery/*.map");
}
// enforce mounts so security interceptors based on URLs can't be fooled
getSecuritySettings().setEnforceMounts(true);
getSecuritySettings().setAuthorizationStrategy(new SimplePageAuthorizationStrategy(SecuredPage.class, getLoginPageClass()) {
@Override
protected boolean isAuthorized() {
SecurityContext securityContext = SecurityContextHolder.getContext();
if (securityContext != null) {
Authentication authentication = securityContext.getAuthentication();
if (authentication != null && authentication.isAuthenticated()) {
for (GrantedAuthority authority : authentication.getAuthorities()) {
if (authority.getAuthority().equals(UserConstants.ROLE_USER) || authority.getAuthority().equals(UserConstants.ROLE_ADMIN)) {
// allow access only for users/admins
return true;
}
}
}
}
return false;
}
});
getComponentInstantiationListeners().add(new SpringComponentInjector(this));
getRequestCycleListeners().add(new AbstractRequestCycleListener() {
@Override
public IRequestHandler onException(RequestCycle cycle, Exception ex) {
return new RenderPageRequestHandler(new PageProvider(new ExceptionPage(ex)));
}
});
// add login page to every application based on this one (if enabled)
Class<? extends BasePage> loginClass = getLoginPageClass();
if (loginClass != null) {
// login page
mountPage("/login", loginClass);
// user settings
mountPage("/settings", UserSettingsPage.class);
// about
mountPage("/about", AboutPage.class);
// contact
mountPage("/contact", ContactPage.class);
if (OpenIdLoginPage.class.equals(loginClass)) {
// for OpenID auth also add page for new users
mountPage("/new", NewUserPage.class);
}
}
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class BaseWicketTester method executeListener.
/**
* Simulates processing URL that invokes an {@link IRequestListener} on a component.
*
* After the listener is invoked the page containing the component will be rendered
* (with an optional redirect - depending on {@link RenderStrategy}).
*
* @param component
* @param listener
*/
public void executeListener(final Component component) {
Args.notNull(component, "component");
// there are two ways to do this. RequestCycle could be forced to call the handler
// directly but constructing and parsing the URL increases the chance of triggering bugs
Page page = component.getPage();
PageAndComponentProvider pageAndComponentProvider = new PageAndComponentProvider(page, component);
IRequestHandler handler = null;
if (page.isPageStateless() || (page.isBookmarkable() && page.wasCreatedBookmarkable())) {
handler = new BookmarkableListenerRequestHandler(pageAndComponentProvider);
} else {
handler = new ListenerRequestHandler(pageAndComponentProvider);
}
Url url = urlFor(handler);
request.setUrl(url);
// Process the request
processRequest(request, null);
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class BaseWicketTester method startResourceReference.
/**
* Simulates a request to a mounted {@link ResourceReference}
*
* @param reference
* the resource reference to test
* @param pageParameters
* the parameters passed to the resource reference
* @return the tested resource reference
*/
public ResourceReference startResourceReference(final ResourceReference reference, final PageParameters pageParameters) {
// prepare request
request.setURL(request.getContextPath() + request.getServletPath() + "/");
IRequestHandler handler = new ResourceReferenceRequestHandler(reference, pageParameters);
// execute request
processRequest(request, handler);
// the reference processed
return reference;
}
Aggregations