List of usage examples for org.apache.wicket.authroles.authorization.strategies.role.metadata MetaDataRoleAuthorizationStrategy authorize
public static void authorize(final Component component, final Action action, final String roles)
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);//from w w w . j a v a 2s . c o m 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 . ja va 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 w w.j av a2 s. c om 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:org.apache.syncope.client.console.approvals.Approval.java
License:Apache License
public Approval(final PageReference pageRef, final WorkflowFormTO formTO) { super(MultilevelPanel.FIRST_LEVEL_ID); IModel<List<WorkflowFormPropertyTO>> formProps = new LoadableDetachableModel<List<WorkflowFormPropertyTO>>() { private static final long serialVersionUID = 3169142472626817508L; @Override//from w ww .java 2 s . c om protected List<WorkflowFormPropertyTO> load() { return formTO.getProperties(); } }; final ListView<WorkflowFormPropertyTO> propView = new ListView<WorkflowFormPropertyTO>("propView", formProps) { private static final long serialVersionUID = 9101744072914090143L; @Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void populateItem(final ListItem<WorkflowFormPropertyTO> item) { final WorkflowFormPropertyTO prop = item.getModelObject(); String label = StringUtils.isBlank(prop.getName()) ? prop.getId() : prop.getName(); FieldPanel field; switch (prop.getType()) { case Boolean: field = new AjaxDropDownChoicePanel("value", label, new PropertyModel<String>(prop, "value") { private static final long serialVersionUID = -3743432456095828573L; @Override public String getObject() { return StringUtils.isBlank(prop.getValue()) ? null : prop.getValue().equals("true") ? "Yes" : "No"; } @Override public void setObject(final String object) { prop.setValue(String.valueOf(object.equalsIgnoreCase("yes"))); } }, false).setChoices(Arrays.asList(new String[] { "Yes", "No" })); break; case Date: final FastDateFormat formatter = FastDateFormat.getInstance(prop.getDatePattern()); field = new DateTimeFieldPanel("value", label, new PropertyModel<Date>(prop, "value") { private static final long serialVersionUID = -3743432456095828573L; @Override public Date getObject() { try { if (StringUtils.isBlank(prop.getValue())) { return null; } else { return formatter.parse(prop.getValue()); } } catch (ParseException e) { LOG.error("Unparsable date: {}", prop.getValue(), e); return null; } } @Override public void setObject(final Date object) { prop.setValue(formatter.format(object)); } }, prop.getDatePattern()); break; case Enum: MapChoiceRenderer<String, String> enumCR = new MapChoiceRenderer<>(prop.getEnumValues()); field = new AjaxDropDownChoicePanel("value", label, new PropertyModel<String>(prop, "value"), false).setChoiceRenderer(enumCR).setChoices(new Model<ArrayList<String>>() { private static final long serialVersionUID = -858521070366432018L; @Override public ArrayList<String> getObject() { return new ArrayList<>(prop.getEnumValues().keySet()); } }); break; case Long: field = new AjaxSpinnerFieldPanel.Builder<Long>().build("value", label, Long.class, new PropertyModel<Long>(prop, "value") { private static final long serialVersionUID = -7688359318035249200L; @Override public Long getObject() { return StringUtils.isBlank(prop.getValue()) ? null : NumberUtils.toLong(prop.getValue()); } @Override public void setObject(final Long object) { prop.setValue(String.valueOf(object)); } }); break; case String: default: field = new AjaxTextFieldPanel("value", label, new PropertyModel<String>(prop, "value"), false); break; } field.setReadOnly(!prop.isWritable()); if (prop.isRequired()) { field.addRequiredLabel(); } item.add(field); } }; final AjaxLink<String> userDetails = new AjaxLink<String>("userDetails") { private static final long serialVersionUID = -4804368561204623354L; @Override public void onClick(final AjaxRequestTarget target) { viewDetails(formTO, target); } }; MetaDataRoleAuthorizationStrategy.authorize(userDetails, ENABLE, StandardEntitlement.USER_READ); add(propView); add(userDetails); }
From source file:org.apache.syncope.client.console.approvals.ApprovalDirectoryPanel.java
License:Apache License
public ApprovalDirectoryPanel(final String id, final PageReference pageReference) { super(id, pageReference, false); disableCheckBoxes();/*ww w . j a v a2 s . c o m*/ setFooterVisibility(true); modal.addSubmitButton(); modal.size(Modal.Size.Large); modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 8804221891699487139L; @Override public void onClose(final AjaxRequestTarget target) { updateResultTable(target); modal.show(false); } }); restClient = new UserWorkflowRestClient(); initResultTable(); MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, RENDER, StandardEntitlement.WORKFLOW_FORM_SUBMIT); }
From source file:org.apache.syncope.client.console.events.EventCategoryPanel.java
License:Apache License
private void authorizeList() { for (String role : getListAuthRoles()) { MetaDataRoleAuthorizationStrategy.authorize(selectedEventsPanel, RENDER, role); } }
From source file:org.apache.syncope.client.console.events.EventCategoryPanel.java
License:Apache License
private void authorizeChanges() { for (String role : getChangeAuthRoles()) { MetaDataRoleAuthorizationStrategy.authorize(categoryContainer, RENDER, role); MetaDataRoleAuthorizationStrategy.authorize(eventsContainer, RENDER, role); }//from ww w.j a va2s . c o m }
From source file:org.apache.syncope.client.console.notifications.MailTemplateDirectoryPanel.java
License:Apache License
public MailTemplateDirectoryPanel(final String id, final PageReference pageReference) { super(id, pageReference, true); disableCheckBoxes();//from w w w .j a v a2s.c o m modal.size(Modal.Size.Small); modal.addSubmitButton(); setFooterVisibility(true); modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 8804221891699487139L; @Override public void onClose(final AjaxRequestTarget target) { updateResultTable(target); modal.show(false); } }); addOuterObject(utilityModal); setWindowClosedReloadCallback(utilityModal); utilityModal.size(Modal.Size.Large); utilityModal.addSubmitButton(); restClient = new NotificationRestClient(); addNewItemPanelBuilder(new AbstractModalPanelBuilder<MailTemplateTO>(new MailTemplateTO(), pageRef) { private static final long serialVersionUID = 1995192603527154740L; @Override public WizardModalPanel<MailTemplateTO> build(final String id, final int index, final AjaxWizard.Mode mode) { return new TemplateModal<>(modal, restClient, new MailTemplateTO(), pageReference); } }, true); initResultTable(); MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, RENDER, StandardEntitlement.MAIL_TEMPLATE_CREATE); }
From source file:org.apache.syncope.client.console.notifications.NotificationDirectoryPanel.java
License:Apache License
public NotificationDirectoryPanel(final String id, final PageReference pageRef) { super(id, pageRef, true); disableCheckBoxes();/*from w w w . j av a2 s . c om*/ addOuterObject(utilityModal); setWindowClosedReloadCallback(utilityModal); utilityModal.size(Modal.Size.Large); modal.size(Modal.Size.Large); altDefaultModal.size(Modal.Size.Large); addNewItemPanelBuilder(new NotificationWizardBuilder(new NotificationTO(), pageRef), true); restClient = new NotificationRestClient(); initResultTable(); MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, RENDER, StandardEntitlement.NOTIFICATION_CREATE); }
From source file:org.apache.syncope.client.console.pages.AbstractSchedTaskModalPage.java
License:Apache License
public AbstractSchedTaskModalPage(final ModalWindow window, final SchedTaskTO taskTO, final PageReference pageRef) { super(taskTO); crontab = new CrontabContainer("crontab", new PropertyModel<String>(taskTO, "cronExpression"), taskTO.getCronExpression()); form.add(crontab);//from ww w . j a va 2 s . c om final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name", new PropertyModel<String>(taskTO, "name")); name.setEnabled(true); profile.add(name); final AjaxTextFieldPanel description = new AjaxTextFieldPanel("description", "description", new PropertyModel<String>(taskTO, "description")); description.setEnabled(true); profile.add(description); final AjaxTextFieldPanel lastExec = new AjaxTextFieldPanel("lastExec", getString("lastExec"), new DateFormatROModel(new PropertyModel<String>(taskTO, "lastExec"))); lastExec.setEnabled(false); profile.add(lastExec); final AjaxTextFieldPanel nextExec = new AjaxTextFieldPanel("nextExec", getString("nextExec"), new DateFormatROModel(new PropertyModel<String>(taskTO, "nextExec"))); nextExec.setEnabled(false); profile.add(nextExec); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(APPLY)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { SchedTaskTO taskTO = (SchedTaskTO) form.getModelObject(); taskTO.setCronExpression( StringUtils.hasText(taskTO.getCronExpression()) ? crontab.getCronExpression() : null); try { submitAction(taskTO); ((BasePage) pageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientException e) { LOG.error("While creating or updating task", e); error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); if (taskTO.getKey() > 0) { MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getEntitlement(TASKS, "update")); } else { MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getEntitlement(TASKS, "create")); } form.add(submit); form.add(cancel); }