List of usage examples for org.apache.wicket.protocol.http WebApplication getRequestCycleListeners
public RequestCycleListenerCollection getRequestCycleListeners()
From source file:de.alpharogroup.wicket.base.application.plugins.SecuritySettingsPlugin.java
License:Apache License
/** * Factory method for that can be used to add additional security configuration to this plugin. * <p>/*www. j a v a 2 s.c om*/ * Overrides should call {@code super.onConfigure()}. * * @param application * the application */ protected void onConfigure(final WebApplication application) { set(application, this); application.getRequestCycleListeners().add(new AbstractRequestCycleListener() { @Override public void onBeginRequest(final RequestCycle cycle) { super.onBeginRequest(cycle); final WebResponse response = (WebResponse) cycle.getResponse(); // Category: Framing WicketComponentExtensions.setSecurityFramingHeaders(response); // Category: Transport WicketComponentExtensions.setSecurityTransportHeaders(response); // Category: XSS WicketComponentExtensions.setSecurityXSSHeaders(response); // Category: Caching WicketComponentExtensions.setSecurityCachingHeaders(response); } }); }
From source file:fiftyfive.wicket.shiro.ShiroWicketPlugin.java
License:Apache License
/** * Installs this {@code ShiroWicketPlugin} by doing the following: * <ul>//from w w w . ja va 2 s. co m * <li>Sets itself as the {@link IAuthorizationStrategy}</li> * <li>And as the {@link IUnauthorizedComponentInstantiationListener}</li> * <li>And as an {@link IRequestCycleListener}</li> * <li>Mounts the login page</li> * <li>Mounts the logout page</li> * </ul> */ public void install(WebApplication app) { Args.notNull(app, "app"); ISecuritySettings settings = app.getSecuritySettings(); settings.setAuthorizationStrategy(this); settings.setUnauthorizedComponentInstantiationListener(this); app.getRequestCycleListeners().add(this); // Mount bookmarkable URLs if (this.loginPath != null) { app.mount(new MountedMapper(this.loginPath, this.loginPage)); } if (this.logoutPath != null) { app.mount(new MountedMapper(this.logoutPath, this.logoutPage)); } // Install self in app metadata so that static get() can work ShiroWicketPlugin.set(app, this); }
From source file:org.wicketstuff.jeeweb.ajax.JEEWebGlobalAjaxHandler.java
License:Apache License
/** * Configures the handler to the given application. * /*from ww w . ja v a2 s. co m*/ * @param application * the application to configure the handler to */ public static void configure(WebApplication application) { application.getRequestCycleListeners().add(new PageRequestHandlerTracker()); application.mountResource("/" + JEEWebGlobalAjaxHandler.class.getSimpleName(), new JEEWebGlobalAjaxHandler()); application.getHeaderContributorListeners().add(new IHeaderContributor() { private static final long serialVersionUID = 1644041155625458328L; @Override public void renderHead(IHeaderResponse response) { JavaScriptResourceReference forReference = new JavaScriptResourceReference( JEEWebGlobalAjaxHandler.class, JEEWebGlobalAjaxHandler.class.getSimpleName() + ".js") { private static final long serialVersionUID = -3649384632770480975L; @Override public List<HeaderItem> getDependencies() { return new ArrayList<HeaderItem>() { private static final long serialVersionUID = 1L; { add(JavaScriptHeaderItem.forReference(WicketAjaxJQueryResourceReference.get())); } }; } }; response.render(JavaScriptHeaderItem.forReference(forReference)); addAJaxBaseUrl(response); } private void addAJaxBaseUrl(IHeaderResponse response) { // render ajax base url. It's required by Wicket Ajax support. Url baseUrl = RequestCycle.get().getUrlRenderer().getBaseUrl(); CharSequence ajaxBaseUrl = Strings.escapeMarkup(baseUrl.toString()); response.render(JavaScriptHeaderItem.forScript("Wicket.Ajax.baseUrl=\"" + ajaxBaseUrl + "\";", "wicket-ajax-base-url")); } }); }