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

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

Introduction

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

Prototype

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

Source Link

Document

Grants authorization to perform the given action to just the role NO_ROLE, effectively denying all other roles.

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  . j  a 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();
    // ---------------------------
}