List of usage examples for org.apache.wicket Component RENDER
Action RENDER
To view the source code for org.apache.wicket Component RENDER.
Click Source Link
From source file:com.googlecode.wicketelements.security.AnnotationAuthorizationStrategy.java
License:Apache License
public boolean isActionAuthorized(final Component componentParam, final Action actionParam) { PARAM_REQ.Object.requireNotNull(componentParam, "The component parameter must not be null."); PARAM_REQ.Object.requireNotNull(actionParam, "The action parameter must not be null."); final Class<? extends Component> componentClass = componentParam.getClass(); if (securityCheck.isSecurityAnnotatedComponent(componentClass)) { final IUser user = SecureSession.get().getUser(); if (user != null) { Class<? extends Annotation> securityAnnotationClass = null; List<Class<? extends SecurityConstraint>> constraints = null; if (Component.RENDER.equals(actionParam)) { securityAnnotationClass = RenderAction.class; constraints = securityCheck.findSecurityConstraintsForRender(componentParam); } else if (Component.ENABLE.equals(actionParam)) { securityAnnotationClass = EnableAction.class; if (!isActionAuthorized(componentParam.getParent(), actionParam)) { return false; } //else go on, check if the user has the permission constraints = securityCheck.findSecurityConstraintsForEnable(componentParam); }/*from ww w . j av a 2s.co m*/ if (securityAnnotationClass == null) { throw new IllegalStateException( "Action is unknown (Render or Enable expected).: " + actionParam); } final boolean constraintsSatisfied = securityCheck .isAllSecurityConstraintsSatisfiedForAction(componentParam, constraints); final Set<String> permissions = securityCheck.findImpliedPermissions(componentClass, securityAnnotationClass); final boolean userHasPermission = securityCheck.isAtLeastOnePermissionGivenToUser(permissions); return constraintsSatisfied && userHasPermission; } } else { LOGGER.debug("No security annotation on the component. Action is authorized."); return true; } return true; }
From source file:com.premiumminds.webapp.wicket.repeaters.AbstractRepeater2.java
License:Apache License
/** * Render a single child. This method can be overridden to modify how a single child component * is rendered./*from w ww .j a va 2s .c o m*/ * * @param child * Child component to be rendered */ protected void renderChild(final Component child) { child.render(); }
From source file:com.servoy.j2db.server.headlessclient.dataui.SortableCellViewHeaders.java
License:Open Source License
private void renderHeader(int headerIdx, final MarkupStream markupStream) { Component header = orderedHeaders.get(headerIdx); markupStream.setCurrentIndex(headerMarkupStartIdx); boolean found = false; MarkupElement element;/* w w w. j a v a2 s. co m*/ while (!found) { element = markupStream.next(); if ((element instanceof ComponentTag) && !markupStream.atCloseTag()) { // Get element as tag final ComponentTag tag = (ComponentTag) element; // Get component id final String id = tag.getId(); // Get the component for the id from the given container final Component component = get(id); // Failed to find it? if (component != null) { if (component.equals(header)) { component.render(markupStream); found = true; } } } } }
From source file:com.userweave.application.UserWeaveAuthorizationStrategy.java
License:Open Source License
public boolean isActionAuthorized(Component component, Action action) { if (action.equals(Component.RENDER)) { Class<? extends Component> c = component.getClass(); AdminOnly adminOnly = c.getAnnotation(AdminOnly.class); if (adminOnly != null) { return UserWeaveSession.get().isAdmin(); }//from ww w . ja va2 s .co m /** * To set the state of an AuthOnlyTextComponent * may be stupid here, but there is currently * no other option. */ if (component instanceof IAuthOnly) { IAuthOnly comp = (IAuthOnly) component; User user = UserWeaveSession.get().getUser(); AuthorizeAction authAction = comp.getClass().getAnnotation(AuthorizeAction.class); boolean auth = false; if (authAction == null) { // if no annotation is given, admins and participants // have access auth = user.hasRole(Role.PROJECT_ADMIN) || user.hasRole(Role.PROJECT_PARTICIPANT); } else { // evaluate annotation roles auth = user.hasAnyRole(new Roles(authAction.roles())); } comp.setIsAuthorized(auth || user.isAdmin()); return true; } } if (action.equals(Component.ENABLE)) { AuthorizeAction authAction = component.getClass().getAnnotation(AuthorizeAction.class); if (authAction != null) { User user = UserWeaveSession.get().getUser(); boolean isEnabled = user.hasAnyRole(new Roles(authAction.roles())); if (!isEnabled) { if (component instanceof IToolTipComponent) { ((IToolTipComponent) component).setToolTipType(ToolTipType.RIGHTS); } } return isEnabled && component.isEnabled(); } return true; } return true; }
From source file:com.visural.wicket.security.AuthorizationStrategy.java
License:Apache License
public boolean isActionAuthorized(Component com, Action action) { if (action.equals(Component.ENABLE) && ISecureEnableInstance.class.isAssignableFrom(com.getClass())) { if (!((ISecureEnableInstance) com).getEnablePrivilege() .isGrantedToClient(clientProvider.getCurrentClient())) { return false; }/*from w ww .j a v a2 s. c o m*/ } if (action.equals(Component.RENDER) && ISecureRenderInstance.class.isAssignableFrom(com.getClass())) { if (!((ISecureRenderInstance) com).getRenderPrivilege() .isGrantedToClient(clientProvider.getCurrentClient())) { return false; } } return true; }
From source file:de.tudarmstadt.ukp.clarin.webanno.project.page.ProjectPage.java
License:Apache License
public ProjectPage() { projectSelectionForm = new ProjectSelectionForm("projectSelectionForm"); projectDetailForm = new ProjectDetailForm("projectDetailForm"); projectDetailForm.setOutputMarkupPlaceholderTag(true); projectDetailForm.setVisible(false); importProjectForm = new ImportProjectForm("importProjectForm"); add(projectSelectionForm);/* w w w.j a v a2s .c om*/ add(importProjectForm); add(projectDetailForm); MetaDataRoleAuthorizationStrategy.authorize(importProjectForm, Component.RENDER, "ROLE_ADMIN"); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.page.welcome.WelcomePage.java
License:Apache License
public WelcomePage() { String username = SecurityContextHolder.getContext().getAuthentication().getName(); // if a user is logged recently, session will not expire, // This causes a problem, if the data base is re-created while user's session not expired OR // the user is deleted while the session is not expired User user = null;//from w ww .j a v a 2 s . co m try { user = userRepository.get(username); } // redirect to login page (if no usr is found, admin/admin will be created) catch (NoResultException e) { setResponsePage(LoginPage.class); } // Add Project Setting Link // Only Super Admin or Project admins can see this link projectSettings = new AjaxLink<Void>("projectSettings") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(ProjectPage.class); } }; add(projectSettings); projectSettings.setVisible(projectSettingsEnabeled(user)); // Add curation Link // Only project admins or curators can see this link curation = new AjaxLink<Void>("curation") { private static final long serialVersionUID = 3681686831639096179L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(CurationPage.class); } }; add(curation); curation.setVisible(curationEnabeled(user)); // Add annotation link // Only project admins and annotators can see this link annotation = new AjaxLink<Void>("annotation") { private static final long serialVersionUID = -845758775690774624L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(AnnotationPage.class); } }; add(annotation); annotation.setVisible(annotationEnabeled(user, Mode.ANNOTATION)); // if not either a curator or annotator, display warning message if (!annotation.isVisible() && !curation.isVisible()) { info("You are not member of any projects to annotate or curate"); } // Add monitoring link // Only project admins and curators can see this link monitoring = new AjaxLink<Void>("monitoring") { private static final long serialVersionUID = 545914367958126874L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(MonitoringPage.class); } }; add(monitoring); monitoring.setVisible(monitoringEnabeled(user)); userManagement = new AjaxLink<Void>("userManagement") { private static final long serialVersionUID = -4722275335074746935L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(ManageUsersPage.class); } }; MetaDataRoleAuthorizationStrategy.authorize(userManagement, Component.RENDER, "ROLE_ADMIN"); add(userManagement); // Add crowdsource link // Only project admins can see this link crowdSource = new AjaxLink<Void>("crowdSource") { private static final long serialVersionUID = -3083016378064313844L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(CrowdSourcePage.class); } }; add(crowdSource); crowdSource.setVisible(projectSettingsEnabeled(user) && repository.isCrowdSourceEnabled() != 0); // Add correction Link // Only project admins and annotators can see this link correction = new AjaxLink<Void>("correction") { private static final long serialVersionUID = -3113946217791583714L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(CorrectionPage.class); } }; add(correction); correction.setVisible(annotationEnabeled(user, Mode.CORRECTION)); // Add automation Link // Only project admins and annotators can see this link automation = new AjaxLink<Void>("automation") { private static final long serialVersionUID = -6527983833667707141L; @Override public void onClick(AjaxRequestTarget target) { setResponsePage(AutomationPage.class); } }; add(automation); automation.setVisible(annotationEnabeled(user, Mode.AUTOMATION)); }
From source file:de.tudarmstadt.ukp.csniper.webapp.page.welcome.WelcomePage.java
License:Apache License
public WelcomePage() { super();//from w ww. ja v a2 s . co m WebMarkupContainer users = new WebMarkupContainer("manageUsersLi"); MetaDataRoleAuthorizationStrategy.authorize(users, Component.RENDER, "ROLE_ADMIN"); add(users); WebMarkupContainer settings = new WebMarkupContainer("settingsLi"); MetaDataRoleAuthorizationStrategy.authorize(settings, Component.RENDER, "ROLE_ADMIN"); add(settings); }
From source file:dk.frankbille.scoreboard.security.ScoreBoardAuthorizationStrategy.java
License:Open Source License
@Override public boolean isActionAuthorized(Component component, Action action) { if (component instanceof RequiresLoginToRender && Component.RENDER.equals(action)) { return isAuthorized(); } else if (component instanceof RequiresLoginToBeEnabled && Component.ENABLE.equals(action)) { return isAuthorized(); }/*from w w w . j a v a 2 s.co m*/ return true; }
From source file:fiftyfive.wicket.shiro.ShiroWicketPlugin.java
License:Apache License
/** * Performs authorization checks for the {@link Component#RENDER RENDER} * action only. Other actions are always allowed. * <p>// w w w . ja v a2 s .com * If the action is {@code RENDER}, the component class <em>and its * superclasses</em> are checked for the presence of * {@link org.apache.shiro.authz.annotation Shiro annotations}. * <p> * The absence of any Shiro annotation means that the component may be * rendered, and {@code true} is returned. Otherwise, each annotation is * evaluated against the current Shiro Subject. If any of the requirements * dictated by the annotations fail, {@code false} is returned and * rendering for the component will be skipped. * <p> * For example, this link will be hidden if the user is already * authenticated: * <pre class="example"> * @RequiresGuest * public class LoginLink extends StatelessLink * { * ... * }</pre> */ public boolean isActionAuthorized(Component component, Action action) { if (Component.RENDER.equals(action)) { try { assertAuthorized(component.getClass()); } catch (AuthorizationException ae) { return false; } } return true; }