List of usage examples for org.apache.wicket.authorization Action Action
public Action(final String name)
From source file:org.artifactory.common.wicket.component.form.SecureForm.java
License:Open Source License
@Override protected void onValidate() { // Check the random id in the hidden field. This guards against CSRF attacks. StringValue requestToken = getRequest().getPostParameters().getParameterValue(TOKEN_NAME); if (!requestToken.equals(StringValue.valueOf(getToken()))) { String message = "Attempted unauthorized form submission"; log.warn(message);//from w ww . j av a 2s . c o m AccessLogger.unauthorizedFormSubmit(message); throw new UnauthorizedActionException(this, new Action("submit without CSRF token")); } super.onValidate(); }
From source file:org.obiba.onyx.webapp.administration.page.AdministrationPage.java
License:Open Source License
public AdministrationPage() { AjaxLink<?> userTab = new AdminTab("userTab") { @Override/* w ww .j a v a 2 s . co m*/ public Component getTabComponent() { return new UserSearchPanel(getContentId()); } }; add(userTab.setOutputMarkupId(true)); links.add(userTab); AjaxLink<?> dataTab = new AdminTab("dataTab") { @Override public Component getTabComponent() { return new DataManagementPanel(getContentId()); } }; add(dataTab.setOutputMarkupId(true)); links.add(dataTab); AjaxLink<?> editorTab = new EditorTab("editorTab") { @Override public Component getTabComponent() { for (Module module : moduleRegistry.getModules()) { Component editorComponent = module.getEditorPanel(getContentId()); if (editorComponent != null) return editorComponent; } return null; } }; add(editorTab.setOutputMarkupId(true)); links.add(editorTab); AjaxLink<?> devTab = new AdminTab("devTab") { @Override public Component getTabComponent() { return new DevelopersPanel(getContentId()); } @Override public boolean isVisible() { return ((OnyxApplication) WebApplication.get()).isDevelopmentMode(); } }; add(devTab.setOutputMarkupId(true)); links.add(devTab); // Display first permitted tab for (AjaxLink<?> link : links) { if (link.isActionAuthorized(new Action(Action.RENDER))) { Component tabComponent = ((Link) link).getTabComponent(); add(tabComponent.setOutputMarkupId(true)); link.add(new AttributeModifier("class", true, new Model<String>("obiba-button ui-corner-all selected"))); break; } } }
From source file:org.wicketstuff.security.swarm.actions.SwarmActionFactoryTest.java
License:Apache License
/** * @see SwarmActionFactory#getAction(Action) *//*from w w w . j a v a 2s . c om*/ public void testGetActionAction() { WaspAction action = factory.getAction(Component.RENDER); assertNotNull(action); assertEquals(factory.getAction(Render.class), action); assertEquals(factory.getAction("render"), action); Action wicketAction = new Action("inherit, render"); action = factory.getAction(wicketAction); assertNotNull(action); assertEquals(factory.getAction(wicketAction.getName()), action); assertNull(factory.getAction((Action) null)); assertNull(factory.getAction(new Action("foo"))); }