Example usage for org.apache.wicket.authroles.authorization.strategies.role.metadata MetaDataRoleAuthorizationStrategy authorizeAll

List of usage examples for org.apache.wicket.authroles.authorization.strategies.role.metadata MetaDataRoleAuthorizationStrategy authorizeAll

Introduction

In this page you can find the example usage for org.apache.wicket.authroles.authorization.strategies.role.metadata MetaDataRoleAuthorizationStrategy authorizeAll.

Prototype

public static void authorizeAll(Component component, final Action action) 

Source Link

Document

Grants permission to all roles to perform the given action on the given component.

Usage

From source file:org.apache.syncope.client.console.wicket.markup.html.form.ActionPanel.java

License:Apache License

public ActionPanel(final String componentId, final IModel<T> model, final Action<T> action) {
    super(componentId);
    setOutputMarkupId(true);/*from  w w  w .  ja  v  a 2 s  .  c  o  m*/
    this.action = action;

    final T obj;
    if (model == null) {
        obj = null;
    } else {
        obj = model.getObject();
    }

    final boolean enabled;
    final AbstractLink actionLink;

    if (action.getLink() == null || action.getType() == ActionType.NOT_FOUND) {
        enabled = true;
        actionLink = new IndicatingAjaxLink<Void>("action") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public boolean isEnabled() {
                return false;
            }

            @Override
            public void onClick(final AjaxRequestTarget target) {
            }
        };
    } else if (action.getType() == ActionType.WORKFLOW_MODELER) {
        enabled = action.getLink().isEnabled(obj);
        actionLink = new BookmarkablePageLink<>("action", action.getLink().getPageClass(),
                action.getLink().getPageParameters())
                        .setPopupSettings(new VeilPopupSettings().setHeight(600).setWidth(800));
    } else {
        enabled = action.getLink().isEnabled(obj);

        actionLink = action.isOnConfirm() ? new IndicatingOnConfirmAjaxLink<Void>("action", enabled) {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                beforeOnClick(target);
                action.getLink().onClick(target, obj);
            }

            @Override
            public String getAjaxIndicatorMarkupId() {
                return disableIndicator || !action.getLink().isIndicatorEnabled() ? StringUtils.EMPTY
                        : Constants.VEIL_INDICATOR_MARKUP_ID;
            }
        } : new IndicatingAjaxLink<Void>("action") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                beforeOnClick(target);
                action.getLink().onClick(target, obj);
            }

            @Override
            public String getAjaxIndicatorMarkupId() {
                return disableIndicator || !action.getLink().isIndicatorEnabled() ? StringUtils.EMPTY
                        : Constants.VEIL_INDICATOR_MARKUP_ID;
            }
        };
    }

    if (SyncopeConsoleSession.get().owns(action.getEntitlements(), action.getRealm())) {
        MetaDataRoleAuthorizationStrategy.authorizeAll(actionLink, RENDER);
    } else {
        MetaDataRoleAuthorizationStrategy.unauthorizeAll(actionLink, RENDER);
    }

    actionLink.setVisible(enabled);

    actionIcon = new Label("actionIcon", "");
    actionLink.add(actionIcon);

    final String clazz = action.getType().name().toLowerCase() + ".class";
    actionIcon.add(new AttributeModifier("class", new ResourceModel(clazz, clazz)));

    final String title = action.getType().name().toLowerCase() + ".title";
    final IModel<String> titleModel = new ResourceModel(title, title);
    actionIcon.add(new AttributeModifier("title", titleModel));

    final String alt = action.getType().name().toLowerCase() + ".alt";
    actionIcon.add(new AttributeModifier("alt", new ResourceModel(alt, alt)));

    actionLabel = new Label("label", titleModel);
    actionLink.add(actionLabel);
    add(actionLink);

    // ---------------------------
    // Action configuration
    // ---------------------------
    actionLabel.setVisible(action.isVisibleLabel());

    if (action.getLabel() != null) {
        actionLabel.setDefaultModel(action.getLabel());
    }

    if (action.getTitle() != null) {
        actionIcon.add(new AttributeModifier("title", action.getTitle()));
    }

    if (action.getAlt() != null) {
        actionIcon.add(new AttributeModifier("alt", action.getAlt()));
    }

    if (action.getIcon() != null) {
        actionIcon.add(new AttributeModifier("class", action.getIcon()));
    }

    this.disableIndicator = !action.hasIndicator();
    // ---------------------------
}

From source file:org.syncope.console.SyncopeApplication.java

License:Apache License

public void setupNavigationPane(final WebPage page, final XMLRolesReader xmlRolesReader, final boolean notsel,
        final String version) {

    page.add(new Label("version", "Console: " + version + "; Core: " + SyncopeSession.get().getCoreVersion()));

    BookmarkablePageLink schemaLink = new BookmarkablePageLink("schema", Schema.class);
    MetaDataRoleAuthorizationStrategy.authorizeAll(schemaLink, WebPage.ENABLE);
    page.add(schemaLink);/*from  ww  w .j av a2s .  c om*/
    schemaLink.add(new Image("schemaIcon",
            new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "schema" + IMG_SUFFIX)));

    BookmarkablePageLink usersLink = new BookmarkablePageLink("users", Users.class);
    String allowedUsersRoles = xmlRolesReader.getAllAllowedRoles("Users", "list");
    MetaDataRoleAuthorizationStrategy.authorize(usersLink, WebPage.ENABLE, allowedUsersRoles);
    page.add(usersLink);
    usersLink.add(new Image("usersIcon",
            new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "users" + IMG_SUFFIX)));

    BookmarkablePageLink rolesLink = new BookmarkablePageLink("roles", Roles.class);
    MetaDataRoleAuthorizationStrategy.authorizeAll(rolesLink, WebPage.ENABLE);
    page.add(rolesLink);
    rolesLink.add(new Image("rolesIcon",
            new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "roles" + IMG_SUFFIX)));

    BookmarkablePageLink resourcesLink = new BookmarkablePageLink("resources", Resources.class);
    MetaDataRoleAuthorizationStrategy.authorizeAll(resourcesLink, WebPage.ENABLE);
    page.add(resourcesLink);
    resourcesLink.add(new Image("resourcesIcon",
            new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "resources" + IMG_SUFFIX)));

    BookmarkablePageLink todoLink = new BookmarkablePageLink("todo", Todo.class);
    MetaDataRoleAuthorizationStrategy.authorize(todoLink, WebPage.ENABLE,
            xmlRolesReader.getAllAllowedRoles("Approval", "list"));
    page.add(todoLink);
    todoLink.add(new Image("todoIcon",
            new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "todo" + IMG_SUFFIX)));

    BookmarkablePageLink reportLink = new BookmarkablePageLink("reports", Reports.class);
    String allowedReportRoles = xmlRolesReader.getAllAllowedRoles("Reports", "list");
    MetaDataRoleAuthorizationStrategy.authorize(reportLink, WebPage.ENABLE, allowedReportRoles);
    page.add(reportLink);
    reportLink.add(new Image("reportsIcon",
            new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "reports" + IMG_SUFFIX)));

    BookmarkablePageLink configurationLink = new BookmarkablePageLink("configuration", Configuration.class);
    String allowedConfigurationRoles = xmlRolesReader.getAllAllowedRoles("Configuration", "list");
    MetaDataRoleAuthorizationStrategy.authorize(configurationLink, WebPage.ENABLE, allowedConfigurationRoles);
    page.add(configurationLink);
    configurationLink.add(new Image("configurationIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "configuration" + IMG_SUFFIX)));

    BookmarkablePageLink taskLink = new BookmarkablePageLink("tasks", Tasks.class);
    String allowedTasksRoles = xmlRolesReader.getAllAllowedRoles("Tasks", "list");
    MetaDataRoleAuthorizationStrategy.authorize(taskLink, WebPage.ENABLE, allowedTasksRoles);
    page.add(taskLink);
    taskLink.add(new Image("tasksIcon",
            new ContextRelativeResource(IMG_PREFIX + (notsel ? IMG_NOTSEL : "") + "tasks" + IMG_SUFFIX)));

    page.add(new BookmarkablePageLink("logout", Logout.class));
}