Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/feature/gui-wrapper…
Browse files Browse the repository at this point in the history
…' into feature/gui-wrapper
  • Loading branch information
skublik committed Jun 14, 2019
2 parents aa4fb74 + 888a198 commit aef0b38
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 76 deletions.
Expand Up @@ -71,13 +71,7 @@ public class PasswordPanel extends InputPanel {
private boolean passwordInputVisble;

public PasswordPanel(String id, IModel<ProtectedStringType> model) {
this(id, model, false);
}

public PasswordPanel(String id, IModel<ProtectedStringType> model, boolean isReadOnly) {
super(id);
this.passwordInputVisble = model.getObject() == null;
initLayout(model, isReadOnly);
this(id, model, false, model == null || model.getObject() == null);
}

public PasswordPanel(String id, IModel<ProtectedStringType> model, boolean isReadOnly, boolean isInputVisible) {
Expand Down
@@ -0,0 +1,27 @@
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="col-lg-2 col-md-4 col-xs-12 prism-property-label " wicket:id="header"/>
<div class="col-lg-10 col-md-8 col-xs-12 prism-property-value" wicket:id="values">
<div class="row">
<div class="col-xs-10" wicket:id="passwordPanel" />
</div>
</div>
</wicket:panel>
</html>
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.gui.api.component.password;

import com.evolveum.midpoint.gui.api.factory.GuiComponentFactory;
import com.evolveum.midpoint.gui.impl.factory.ItemRealValueModel;
import com.evolveum.midpoint.gui.impl.prism.*;
import com.evolveum.midpoint.web.page.admin.users.PageUser;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.model.IModel;

/**
* Created by honchar
*/
public class PasswordPropertyPanel extends PrismPropertyPanel<ProtectedStringType>{
private static final long serialVersionUID = 1L;

private static final String ID_PASSWORD_PANEL= "passwordPanel";

public PasswordPropertyPanel(String id, IModel<PrismPropertyWrapper<ProtectedStringType>> model, ItemVisibilityHandler visibilitytHandler){
super(id, model, visibilitytHandler);
}

@Override
protected Component createValuePanel(ListItem<PrismPropertyValueWrapper<ProtectedStringType>> item, GuiComponentFactory factory, ItemVisibilityHandler visibilityHandler) {

PasswordPanel passwordPanel;
if (!(getPageBase() instanceof PageUser)) {
passwordPanel = new PasswordPanel(ID_PASSWORD_PANEL, new ItemRealValueModel<>(item.getModel()),
getModelObject() != null && getModelObject().isReadOnly(), true);

} else {

passwordPanel = new PasswordPanel(ID_PASSWORD_PANEL, new ItemRealValueModel<>(item.getModel()),
getModelObject() != null && getModelObject().isReadOnly(),
item.getModelObject() == null || item.getModelObject().getRealValue() == null );
}
passwordPanel.setOutputMarkupId(true);
item.add(passwordPanel);
return passwordPanel;



}

@Override
protected void createButtons(ListItem<PrismPropertyValueWrapper<ProtectedStringType>> item) {
//nothing to do
}

}

This file was deleted.

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.gui.impl.factory;

import com.evolveum.midpoint.gui.api.component.password.PasswordPropertyPanel;
import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.gui.impl.prism.*;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
* Created by honchar
*/
@Component
public class ProtectedStringWrapperFactory extends PrismPropertyWrapperFactoryImpl<ProtectedStringType>{

@Override
public boolean match(ItemDefinition<?> def) {
return QNameUtil.match(ProtectedStringType.COMPLEX_TYPE, def.getTypeName()) ;
}

@PostConstruct
@Override
public void register() {
getRegistry().addToRegistry(this);
}

@Override
public int getOrder() {
return 1010;
}

@Override
protected PrismPropertyWrapper<ProtectedStringType> createWrapper(PrismContainerValueWrapper<?> parent, PrismProperty<ProtectedStringType> item,
ItemStatus status) {
ProtectedStringTypeWrapperImpl propertyWrapper = new ProtectedStringTypeWrapperImpl(parent, item, status);
getRegistry().registerWrapperPanel(item.getDefinition().getTypeName(), PasswordPropertyPanel.class);
return propertyWrapper;
}

}
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.gui.impl.prism;

import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

import java.util.Collection;

/**
* Created by honchar
*/
public class ProtectedStringTypeWrapperImpl extends PrismPropertyWrapperImpl<ProtectedStringType>{
private static final long serialVersionUID = 1L;

private static final transient Trace LOGGER = TraceManager.getTrace(ProtectedStringTypeWrapperImpl.class);

public ProtectedStringTypeWrapperImpl(PrismContainerValueWrapper<?> parent, PrismProperty<ProtectedStringType> item, ItemStatus status) {
super(parent, item, status);

// getItem().setRealValue(null);
}

@Override
public <D extends ItemDelta<PrismPropertyValue<ProtectedStringType>, PrismPropertyDefinition<ProtectedStringType>>> Collection<D> getDelta() throws SchemaException {
PrismPropertyValueWrapper<ProtectedStringType> valueWrapper = getValue();
if (valueWrapper != null && valueWrapper.getRealValue() == null && valueWrapper.getOldValue().getRealValue() != null){
valueWrapper.setStatus(ValueStatus.DELETED);
}
return super.getDelta();
}


}

0 comments on commit aef0b38

Please sign in to comment.