Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Oct 11, 2023
2 parents 80aab41 + 4892348 commit 0982938
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.TextField;
Expand Down Expand Up @@ -64,6 +65,10 @@ public void configure(PrismPropertyPanelContext<T> panelCtx, Component component
}
formComponent.add(panelCtx.getAjaxEventBehavior());
formComponent.add(panelCtx.getVisibleEnableBehavior());
if (panelCtx.getAttributeValuesMap() != null) {
panelCtx.getAttributeValuesMap().keySet().stream()
.forEach(a -> formComponent.add(AttributeAppender.replace(a, panelCtx.getAttributeValuesMap().get(a))));
}
}

ExpressionValidator ev = panelCtx.getExpressionValidator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
package com.evolveum.midpoint.gui.impl.factory.panel;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.ClassUtils;
import org.apache.wicket.Component;
Expand Down Expand Up @@ -42,6 +44,7 @@ public abstract class ItemPanelContext<T, IW extends ItemWrapper<?, ?>> implemen
private FeedbackAlerts feedback;

private FormPanelType formType = FormPanelType.getDefault();
private Map<String, String> attributeValuesMap = new HashMap<>();

public ItemPanelContext(IModel<IW> itemWrapper) {
this.itemWrapper = itemWrapper;
Expand Down Expand Up @@ -147,6 +150,14 @@ public FeedbackAlerts getFeedback() {
return feedback;
}

public void setAttributeValuesMap(Map<String, String> attributeValuesMap) {
this.attributeValuesMap = attributeValuesMap;
}

public Map<String, String> getAttributeValuesMap() {
return attributeValuesMap;
}

/**
* @return the form
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
<html xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<h4 class="text-bold text-center pb-3"><wicket:child/></h4>
<div wicket:id="providers" class="col-md-12">
<div wicket:id="providers" class="col-md-12 pt-3">
<a wicket:id="provider" class="p-3 mb-2 card tile-panel selectable btn text-left"/>
</div>
<div class="pull-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<wicket:extend>
<form method="post" class="form-horizontal" wicket:id="form">
<div wicket:id="csrfField"/>
<input type="hidden" wicket:id="attributeValues"/>
<!-- <input type="hidden" wicket:id="attributeValues"/>-->
<wicket:child class="mt-4"/>
<div wicket:id="attributes" class="d-flex flex-column my-2 justify-content-between login-panel-control">
<!-- <div wicket:id="attributePanel"></div>-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
package com.evolveum.midpoint.gui.impl.page.login.module;

import java.io.Serial;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext;
import com.evolveum.midpoint.gui.api.prism.ItemStatus;
Expand All @@ -34,6 +36,7 @@
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.HiddenField;
import org.apache.wicket.markup.html.list.ListItem;
Expand All @@ -58,7 +61,7 @@ public abstract class PageAbstractAttributeVerification<MA extends ModuleAuthent
private static final Trace LOGGER = TraceManager.getTrace(PageAbstractAttributeVerification.class);
private static final String DOT_CLASS = PageAbstractAttributeVerification.class.getName() + ".";
protected static final String OPERATION_CREATE_ITEM_WRAPPER = DOT_CLASS + "createItemWrapper";
private static final String ID_ATTRIBUTE_VALUES = "attributeValues";
// private static final String ID_ATTRIBUTE_VALUES = "attributeValues";
private static final String ID_ATTRIBUTES = "attributes";
private static final String ID_ATTRIBUTE_NAME = "attributeName";
private static final String ID_ATTRIBUTE_PANEL = "attributePanel";
Expand Down Expand Up @@ -87,9 +90,9 @@ protected List<VerificationAttributeDto> load() {

@Override
protected void initModuleLayout(MidpointForm form) {
HiddenField<String> verified = new HiddenField<>(ID_ATTRIBUTE_VALUES, attrValuesModel);
verified.setOutputMarkupId(true);
form.add(verified);
// HiddenField<String> verified = new HiddenField<>(ID_ATTRIBUTE_VALUES, attrValuesModel);
// verified.setOutputMarkupId(true);
// form.add(verified);

initAttributesLayout(form);
}
Expand Down Expand Up @@ -119,23 +122,30 @@ private void createAttributePanel(ListItem<VerificationAttributeDto> item) {

@Serial private static final long serialVersionUID = 1L;

// @Override
// protected AjaxEventBehavior createEventBehavior() {
// return new AjaxFormComponentUpdatingBehavior("blur") {
//
// @Serial private static final long serialVersionUID = 1L;
//
// @Override
// protected void onUpdate(AjaxRequestTarget target) {
// attrValuesModel.setObject(generateAttributeValuesString());
// target.add(getVerifiedField());
// }
//
// @Override
// protected void onError(AjaxRequestTarget target, RuntimeException e) {
// target.add(getFeedback());
// }
// };
// }

@Override
protected AjaxEventBehavior createEventBehavior() {
return new AjaxFormComponentUpdatingBehavior("blur") {

@Serial private static final long serialVersionUID = 1L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
attrValuesModel.setObject(generateAttributeValuesString());
target.add(getVerifiedField());
}

@Override
protected void onError(AjaxRequestTarget target, RuntimeException e) {
target.add(getFeedback());
}
};
protected Map<String, String> getAttributeValuesMap() {
Map<String, String> nameAttribute = new HashMap<>();
nameAttribute.put("name", AuthConstants.ATTR_VERIFICATION_PARAMETER_START + item.getModelObject().getItemPath());
return nameAttribute;
}

@Override
Expand Down Expand Up @@ -197,25 +207,25 @@ private WrapperContext createWrapperContext() {
return ctx;
}

private String generateAttributeValuesString() {
JSONArray attrValues = new JSONArray();
attributePathModel.getObject().forEach(entry -> {
PrismPropertyValueWrapper value = (PrismPropertyValueWrapper) entry.getValue();
if (value == null || value.getRealValue() == null) {
return;
}
JSONObject json = new JSONObject();
json.put(AuthConstants.ATTR_VERIFICATION_J_PATH, entry.getItemPath());
json.put(AuthConstants.ATTR_VERIFICATION_J_VALUE, value.getRealValue());
attrValues.put(json);
});
if (attrValues.length() == 0) {
return null;
}
return attrValues.toString();
}

private Component getVerifiedField() {
return getForm().get(ID_ATTRIBUTE_VALUES);
}
// private String generateAttributeValuesString() {
// JSONArray attrValues = new JSONArray();
// attributePathModel.getObject().forEach(entry -> {
// PrismPropertyValueWrapper value = (PrismPropertyValueWrapper) entry.getValue();
// if (value == null || value.getRealValue() == null) {
// return;
// }
// JSONObject json = new JSONObject();
// json.put(AuthConstants.ATTR_VERIFICATION_J_PATH, entry.getItemPath());
// json.put(AuthConstants.ATTR_VERIFICATION_J_VALUE, value.getRealValue());
// attrValues.put(json);
// });
// if (attrValues.length() == 0) {
// return null;
// }
// return attrValues.toString();
// }

// private Component getVerifiedField() {
// return getForm().get(ID_ATTRIBUTE_VALUES);
// }
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.Serial;

import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationToken;

Expand All @@ -35,12 +36,12 @@ protected boolean isBackButtonVisible() {

@Override
protected IModel<String> getLoginPanelTitleModel() {
return createStringResource("PageOidcSelect.title");
return createStringResource("PageOidcSelect.select.identity.provider");
}

@Override
protected IModel<String> getLoginPanelDescriptionModel() {
return createStringResource("PageOidcSelect.title.description");
return Model.of();
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.Serializable;

import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.springframework.security.core.Authentication;
import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationToken;

Expand All @@ -36,12 +37,12 @@ protected boolean isBackButtonVisible() {

@Override
protected IModel<String> getLoginPanelTitleModel() {
return createStringResource("PageSamlSelect.title");
return createStringResource("PageSamlSelect.select.identity.provider");
}

@Override
protected IModel<String> getLoginPanelDescriptionModel() {
return createStringResource("PageSamlSelect.title.description");
return Model.of();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import java.util.HashMap;
import java.util.Map;

public abstract class PrismValuePanel<T, IW extends ItemWrapper, VW extends PrismValueWrapper<T>> extends BasePanel<VW> {

private static final Trace LOGGER = TraceManager.getTrace(PrismValuePanel.class);
Expand Down Expand Up @@ -162,6 +165,7 @@ protected void createValuePanel(MidpointForm form) {
panelCtx.setVisibleEnableBehaviour(createVisibleEnableBehavior());
panelCtx.setExpressionValidator(createExpressionValidator());
panelCtx.setFeedback(feedback);
panelCtx.setAttributeValuesMap(getAttributeValuesMap());

Component component;
try {
Expand Down Expand Up @@ -330,4 +334,8 @@ protected Component getValueContainer() {
private ValueMetadataWrapperImpl getValueMetadata() {
return getModelObject().getValueMetadata();
}

protected Map<String, String> getAttributeValuesMap() {
return new HashMap<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public class AuthConstants {
public static final String SEC_QUESTION_J_QTXT = "qtxt";
public static final String ATTR_VERIFICATION_J_PATH = "path";
public static final String ATTR_VERIFICATION_J_VALUE = "value";

public static final String ATTR_VERIFICATION_PARAMETER_START = "attributeValue.";
}

0 comments on commit 0982938

Please sign in to comment.