Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public final class AMConstants {

public static final String PREF_CLIENTAPP_PROPERTIES_PAGINATOR_ROWS = "clientapp.properties.paginator.rows";

public static final String PREF_ACCESS_POLICY_CONF_REQUIRED_ATTRS_PAGINATOR_ROWS =
"accesspolicy.conf.requiredattrs.paginator.rows";
public static final String PREF_ACCESS_POLICY_CONF_ATTRS_PAGINATOR_ROWS = "accesspolicy.conf.attrs.paginator.rows";

public static final String PREF_SAML2_IDP_ENTITY_PAGINATOR_ROWS = "saml2idpentity.properties.paginator.rows";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.Serializable;
import java.net.URI;
import java.util.List;
import java.util.Optional;
import org.apache.syncope.client.console.rest.SRARouteRestClient;
import org.apache.syncope.client.console.wizards.BaseAjaxWizardBuilder;
import org.apache.syncope.client.ui.commons.Constants;
Expand Down Expand Up @@ -82,16 +83,12 @@ public Profile(final SRARouteTO route) {

@Override
public String getObject() {
return route.getTarget() == null ? null : route.getTarget().toASCIIString();
return Optional.ofNullable(route.getTarget()).map(URI::toASCIIString).orElse(null);
}

@Override
public void setObject(final String object) {
if (object == null) {
route.setTarget(null);
} else {
route.setTarget(URI.create(object));
}
route.setTarget(Optional.ofNullable(object).map(URI::create).orElse(null));
}
}, false);
target.addRequiredLabel().setEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,54 @@
*/
package org.apache.syncope.client.console.policies;

import java.io.Serializable;
import java.util.List;
import java.util.function.Function;
import org.apache.syncope.client.console.commons.AMConstants;
import org.apache.syncope.client.console.panels.AttrListDirectoryPanel;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.client.ui.commons.wizards.AjaxWizard;
import org.apache.syncope.common.lib.Attr;
import org.apache.syncope.common.lib.policy.AccessPolicyConf;
import org.apache.syncope.common.lib.policy.AccessPolicyTO;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.model.IModel;

public class AccessPolicyRequiredAttrsDirectoryPanel extends AttrListDirectoryPanel {
public class AccessPolicyAttrsDirectoryPanel extends AttrListDirectoryPanel {

private static final long serialVersionUID = 1L;
public interface AttrsAccessor extends Function<AccessPolicyConf, List<Attr>>, Serializable {
}

private static final long serialVersionUID = 33604877627114L;

private final BaseModal<AccessPolicyTO> wizardModal;

private final IModel<AccessPolicyTO> model;

public AccessPolicyRequiredAttrsDirectoryPanel(
private final AttrsAccessor attrsAccessor;

public AccessPolicyAttrsDirectoryPanel(
final String id,
final BaseModal<AccessPolicyTO> wizardModal,
final IModel<AccessPolicyTO> model,
final AttrsAccessor attrsAccessor,
final PageReference pageRef) {

super(id, pageRef, false);

this.wizardModal = wizardModal;
this.model = model;
this.attrsAccessor = attrsAccessor;

setOutputMarkupId(true);

enableUtilityButton();
setFooterVisibility(false);

addNewItemPanelBuilder(
new AccessPolicyRequiredAttrsWizardBuilder(model.getObject(), new Attr(), pageRef), true);
new AccessPolicyAttrsWizardBuilder(model.getObject(), attrsAccessor, new Attr(), pageRef), true);

initResultTable();
}
Expand All @@ -75,25 +85,25 @@ public void onEvent(final IEvent<?> event) {

@Override
protected AttrListProvider dataProvider() {
return new AccessPolicyRequiredAttrsProvider(rows);
return new AccessPolicyAttrsProvider(rows);
}

@Override
protected String paginatorRowsKey() {
return AMConstants.PREF_ACCESS_POLICY_CONF_REQUIRED_ATTRS_PAGINATOR_ROWS;
return AMConstants.PREF_ACCESS_POLICY_CONF_ATTRS_PAGINATOR_ROWS;
}

protected final class AccessPolicyRequiredAttrsProvider extends AttrListProvider {
protected final class AccessPolicyAttrsProvider extends AttrListProvider {

private static final long serialVersionUID = -185944053385660794L;

private AccessPolicyRequiredAttrsProvider(final int paginatorRows) {
private AccessPolicyAttrsProvider(final int paginatorRows) {
super(paginatorRows);
}

@Override
protected List<Attr> list() {
return model.getObject().getConf().getRequiredAttrs();
return attrsAccessor.apply(model.getObject().getConf());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,29 @@
import org.apache.syncope.common.lib.types.PolicyType;
import org.apache.wicket.PageReference;

public class AccessPolicyRequiredAttrsWizardBuilder extends AttrWizardBuilder {
public class AccessPolicyAttrsWizardBuilder extends AttrWizardBuilder {

private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 33625775269155L;

private final AccessPolicyTO accessPolicy;

public AccessPolicyRequiredAttrsWizardBuilder(
private final AccessPolicyAttrsDirectoryPanel.AttrsAccessor attrsAccessor;

public AccessPolicyAttrsWizardBuilder(
final AccessPolicyTO accessPolicy,
final AccessPolicyAttrsDirectoryPanel.AttrsAccessor attrsAccessor,
final Attr attr,
final PageReference pageRef) {

super(attr, pageRef);
this.accessPolicy = accessPolicy;
this.attrsAccessor = attrsAccessor;
}

@Override
protected Serializable onApplyInternal(final Attr modelObject) {
accessPolicy.getConf().getRequiredAttrs().removeIf(p -> modelObject.getSchema().equals(p.getSchema()));
accessPolicy.getConf().getRequiredAttrs().add(modelObject);
attrsAccessor.apply(accessPolicy.getConf()).removeIf(p -> modelObject.getSchema().equals(p.getSchema()));
attrsAccessor.apply(accessPolicy.getConf()).add(modelObject);

PolicyRestClient.update(PolicyType.ACCESS, accessPolicy);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.BooleanPropertyColumn;
import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
import org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel;
import org.apache.syncope.common.lib.policy.AccessPolicyConf;
import org.apache.syncope.common.lib.policy.AccessPolicyTO;
import org.apache.syncope.common.lib.policy.DefaultAccessPolicyConf;
import org.apache.syncope.common.lib.types.IdRepoEntitlement;
Expand All @@ -32,6 +33,7 @@
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;
Expand All @@ -54,10 +56,15 @@ public AccessPolicyDirectoryPanel(final String id, final PageReference pageRef)

@Override
protected void addCustomColumnFields(final List<IColumn<AccessPolicyTO, String>> columns) {
columns.add(new PropertyColumn<>(new StringResourceModel("order", this), "order", "order"));
columns.add(new BooleanPropertyColumn<>(
new StringResourceModel("enabled", this), "enabled", "enabled"));
columns.add(new BooleanPropertyColumn<>(
new StringResourceModel("ssoEnabled", this), "ssoEnabled", "ssoEnabled"));
columns.add(new BooleanPropertyColumn<>(
new StringResourceModel("requireAllAttributes", this), "requireAllAttributes", "requireAllAttributes"));
columns.add(new BooleanPropertyColumn<>(
new StringResourceModel("caseInsensitive", this), "caseInsensitive", "caseInsensitive"));
}

@Override
Expand All @@ -73,12 +80,41 @@ public void onClick(final AjaxRequestTarget target, final AccessPolicyTO ignore)
model.getObject().setConf(new DefaultAccessPolicyConf());
}
target.add(ruleCompositionModal.setContent(new ModalDirectoryPanel<>(
ruleCompositionModal,
new AccessPolicyRequiredAttrsDirectoryPanel("panel", ruleCompositionModal, model, pageRef),
pageRef)));
ruleCompositionModal,
new AccessPolicyAttrsDirectoryPanel(
"panel",
ruleCompositionModal,
model,
AccessPolicyConf::getRequiredAttrs,
pageRef),
pageRef)));
ruleCompositionModal.header(new Model<>(getString("requiredAttrs.title", model)));
ruleCompositionModal.show(true);
}
}, ActionLink.ActionType.TYPE_EXTENSIONS, IdRepoEntitlement.POLICY_UPDATE);

panel.add(new ActionLink<>() {

private static final long serialVersionUID = -3722207913631435501L;

@Override
public void onClick(final AjaxRequestTarget target, final AccessPolicyTO ignore) {
model.setObject(PolicyRestClient.read(type, model.getObject().getKey()));
if (model.getObject().getConf() == null) {
model.getObject().setConf(new DefaultAccessPolicyConf());
}
target.add(ruleCompositionModal.setContent(new ModalDirectoryPanel<>(
ruleCompositionModal,
new AccessPolicyAttrsDirectoryPanel(
"panel",
ruleCompositionModal,
model,
AccessPolicyConf::getRejectedAttrs,
pageRef),
pageRef)));
ruleCompositionModal.header(new Model<>(getString("rejectedAttrs.title", model)));
ruleCompositionModal.show(true);
}
}, ActionLink.ActionType.CLAIM, IdRepoEntitlement.POLICY_UPDATE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
sra=SRA
routes=Rotte
metrics=Metriche
order=Ordine
order=Ordinamento
target=Obiettivo
type=Tipo
any.new=Nuova rotta del gateway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
package org.apache.syncope.client.console.policies;

import java.io.Serializable;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.syncope.client.console.SyncopeWebApplication;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.ui.commons.Constants;
Expand All @@ -39,14 +41,19 @@
import org.apache.syncope.common.lib.policy.PolicyTO;
import org.apache.syncope.common.lib.types.ConflictResolutionAction;
import org.apache.syncope.common.lib.types.PolicyType;
import org.apache.wicket.Application;
import org.apache.wicket.Component;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.core.util.lang.PropertyResolver;
import org.apache.wicket.core.util.lang.PropertyResolverConverter;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.util.ListModel;
import org.apache.wicket.validation.validator.UrlValidator;

public class PolicyModalPanelBuilder<T extends PolicyTO> extends AbstractModalPanelBuilder<T> {

Expand Down Expand Up @@ -140,6 +147,11 @@ protected List<String> load() {
break;

case ACCESS:
fields.add(new AjaxSpinnerFieldPanel.Builder<Integer>().build(
"field",
"order",
Integer.class,
new PropertyModel<>(policyTO, "order")));
fields.add(new AjaxCheckBoxPanel(
"field",
"enabled",
Expand All @@ -150,6 +162,42 @@ protected List<String> load() {
"ssoEnabled",
new PropertyModel<>(policyTO, "ssoEnabled"),
false));
fields.add(new AjaxCheckBoxPanel(
"field",
"requireAllAttributes",
new PropertyModel<>(policyTO, "requireAllAttributes"),
false));
fields.add(new AjaxCheckBoxPanel(
"field",
"caseInsensitive",
new PropertyModel<>(policyTO, "caseInsensitive"),
false));
AjaxTextFieldPanel unauthorizedRedirectUrl = new AjaxTextFieldPanel(
"field",
"unauthorizedRedirectUrl",
new IModel<>() {

@Override
public String getObject() {
return Optional.ofNullable(
(URI) PropertyResolver.getValue("unauthorizedRedirectUrl", policyTO)).
map(URI::toASCIIString).orElse(null);
}

@Override
public void setObject(final String object) {
PropertyResolverConverter prc = new PropertyResolverConverter(
Application.get().getConverterLocator(),
SyncopeConsoleSession.get().getLocale());
PropertyResolver.setValue(
"unauthorizedRedirectUrl",
policyTO,
Optional.ofNullable(object).map(URI::create).orElse(null),
prc);
}
}, false);
unauthorizedRedirectUrl.getField().add(new UrlValidator(new String[] { "http", "https" }));
fields.add(unauthorizedRedirectUrl);
break;

case ATTR_RELEASE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ conflictResolutionAction=Conflict Resolution Action
enabled=Enabled
ssoEnabled=SSO Enabled
requiredAttrs.title=Required Attributes
type_extensions.title=configuration
type_extensions.title=required attributes
type_extensions.class=fas fa-check-circle
claim.title=rejected attributes
claim.class=far fa-check-circle
status=Status
allowedAttrs=Allowed Attributes
excludedAttrs=Excluded Attributes
Expand All @@ -41,3 +44,8 @@ attrReleasePolicyConf.title=Attribute Release Configuration
authPolicyConf.title=Authentication Configuration
tryAll=Try All
authModules=Authentication Modules
requireAllAttributes=Require All Attributes
caseInsensitive=Case Insensitive
order=Order
rejectedAttrs.title=Rejected Attributes
unauthorizedRedirectUrl=Unauthorized Redirect URL
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ conflictResolutionAction=Action de r\u00e9solution des conflits
enabled=Enabled
ssoEnabled=SSO Enabled
requiredAttrs.title=Required Attributes
type_extensions.title=configuration
type_extensions.title=required attributes
type_extensions.class=fas fa-check-circle
claim.title=rejected attributes
claim.class=far fa-check-circle
status=Status
allowedAttrs=Allowed Attributes
excludedAttrs=Excluded Attributes
Expand All @@ -41,3 +44,8 @@ attrReleasePolicyConf.title=Attribute Release Configuration
authPolicyConf.title=Authentication Configuration
tryAll=Try All
authModules=Authentication Modules
requireAllAttributes=Require All Attributes
caseInsensitive=Case Insensitive
order=Order
rejectedAttrs.title=Rejected Attributes
unauthorizedRedirectUrl=Unauthorized Redirect URL
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ conflictResolutionAction=Azione di Risoluzione Conflitti
enabled=Abilitata
ssoEnabled=SSO Abilitato
requiredAttrs.title=Attributi Richiesti
type_extensions.title=configurazione
type_extensions.title=attributi richiesti
type_extensions.class=fas fa-check-circle
claim.title=attributi rifiutati
claim.class=far fa-check-circle
status=Stato
allowedAttrs=Attributi Consentiti
excludedAttrs=Attributi Esclusi
Expand All @@ -41,3 +44,8 @@ attrReleasePolicyConf.title=Configurazione Rilascio Attributi
authPolicyConf.title=Configurazione Autenticazione
tryAll=Prova Tutti
authModules=Moduli di Authenticazione
requireAllAttributes=Attributi Obbligatori
caseInsensitive=Case Insensitive
order=Ordinamento
rejectedAttrs.title=Attributi Rifiutati
unauthorizedRedirectUrl=URL di Ridirezione Per Mancata Autorizzazione
Loading