Skip to content

Commit

Permalink
Merge branch 'feature/password-history' of https://github.com/Evolveu…
Browse files Browse the repository at this point in the history
…m/midpoint into feature/password-history
  • Loading branch information
katkav committed Jun 23, 2016
2 parents 19dfc23 + 1c2674b commit e3ca168
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
Expand Up @@ -144,7 +144,9 @@ private MyPasswordsDto loadPageModel() {
String userOid = SecurityUtils.getPrincipalUser().getOid();
Task task = createSimpleTask(OPERATION_LOAD_USER);
OperationResult subResult = result.createSubresult(OPERATION_LOAD_USER);
user = getModelService().getObject(UserType.class, userOid, null, task, subResult);
Collection<SelectorOptions<GetOperationOptions>> resolveNames =
SelectorOptions.createCollection(GetOperationOptions.createResolveNames());
user = getModelService().getObject(UserType.class, userOid, resolveNames, task, subResult);
subResult.recordSuccessIfUnknown();

UserType userType = user.asObjectable();
Expand Down
Expand Up @@ -29,7 +29,10 @@
</div>
</div>
<div class="row">
<label class="control-label" wicket:id="lastChange"/>
<label class="col-sm-10 control-label" wicket:id="createLabel"/>
</div>
<div class="row">
<label class="col-sm-10 control-label" wicket:id="lastChange"/>
</div>

<div wicket:id="accountsContainer" class="row">
Expand Down
Expand Up @@ -16,8 +16,11 @@
package com.evolveum.midpoint.web.page.self.component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.xml.datatype.XMLGregorianCalendar;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand All @@ -42,8 +45,11 @@
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.SelectableDataTable;
import com.evolveum.midpoint.web.component.data.TablePanel;
import com.evolveum.midpoint.web.component.data.column.CheckBoxColumn;
Expand All @@ -53,13 +59,17 @@
import com.evolveum.midpoint.web.component.util.ListDataProvider;
import com.evolveum.midpoint.web.page.admin.home.dto.MyPasswordsDto;
import com.evolveum.midpoint.web.page.admin.home.dto.PasswordAccountDto;
import com.evolveum.midpoint.web.page.self.PageSelfCredentials;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPropagationUserControlType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordChangeSecurityType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;

/**
* @author Kate Honchar
*/
Expand All @@ -71,7 +81,8 @@ public class ChangePasswordPanel extends BasePanel<MyPasswordsDto> {
private static final String ID_PASSWORD_LABEL = "passwordLabel";
private static final String ID_OLD_PASSWORD_LABEL = "oldPasswordLabel";
public static final String ID_ACCOUNTS_TABLE = "accounts";
public static final String ID_LAST_CHANGE = "lastChange";
private static final String ID_PASSWORD_CREATE_INFO_LABEL = "createLabel";
public static final String ID_LAST_CHANGE_LABEL = "lastChange";
public static final String ID_ACCOUNTS_CONTAINER = "accountsContainer";
private static final String ID_BUTTON_HELP = "help";
private static final String DOT_CLASS = ChangePasswordPanel.class.getName() + ".";
Expand All @@ -81,6 +92,7 @@ public class ChangePasswordPanel extends BasePanel<MyPasswordsDto> {
public static final String PROPAGATED_ACCOUNT_ICON_CSS = "fa fa-sign-out";
private static final int HELP_MODAL_WIDTH = 400;
private static final int HELP_MODAL_HEIGH = 600;
private static final Trace LOGGER = TraceManager.getTrace(ChangePasswordPanel.class);

private LoadableModel<MyPasswordsDto> model;
private boolean midpointAccountSelected = true;
Expand All @@ -105,23 +117,17 @@ private void initLayout() {
Label passwordLabel = new Label(ID_PASSWORD_LABEL, createStringResource("PageSelfCredentials.passwordLabel1"));
add(passwordLabel);



MetadataType metadata = model.getObject().getMetadata();
PrismObject<UserType> modifier = null;

if(metadata!=null){
ObjectReferenceType modifierRef = metadata.getModifierRef();
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_USER);
OperationResult result = new OperationResult(OPERATION_LOAD_USER);
if(modifierRef!=null){
modifier = WebModelServiceUtils.loadObject(UserType.class, modifierRef.getOid(), getPageBase(), task, result);
}
}
Label lastChange = new Label(ID_LAST_CHANGE,
createStringResource("PageSelfCredentials.lastChangeLabel",
metadata == null ? "NO CHANGE" : metadata.getModifyTimestamp(),
WebComponentUtil.getName(modifier)));
add(lastChange);

passwordMetaInfo(metadata.getCreatorRef(),ID_PASSWORD_CREATE_INFO_LABEL, metadata.getCreateTimestamp(), "PageSelfCredentials.createInfoLabel");
passwordMetaInfo(metadata.getModifierRef(),ID_LAST_CHANGE_LABEL, metadata.getModifyTimestamp(), "PageSelfCredentials.lastChangeLabel");





PasswordTextField oldPasswordField =
new PasswordTextField(ID_OLD_PASSWORD_FIELD, new PropertyModel<String>(model, MyPasswordsDto.F_OLD_PASSWORD));
Expand Down Expand Up @@ -165,8 +171,21 @@ public void onClick(AjaxRequestTarget target) {

add(accountContainer);
}

public void passwordMetaInfo(ObjectReferenceType user,String wicketid, XMLGregorianCalendar timestamp, String messageKey){

String cmUser = user == null ? "--" : WebComponentUtil.getOrigStringFromPoly(user.getTargetName());
Label lastChangeLabel = new Label(wicketid,
createStringResource(messageKey,
user == null ? "--" : timestamp,
cmUser));
add(lastChangeLabel);

}



private List<IColumn<PasswordAccountDto, String>> initColumns() {
private List<IColumn<PasswordAccountDto, String>> initColumns() {
List<IColumn<PasswordAccountDto, String>> columns = new ArrayList<IColumn<PasswordAccountDto, String>>();

IColumn column = new IconColumn<PasswordAccountDto>(new Model<String>()) {
Expand Down
Expand Up @@ -3215,4 +3215,5 @@ LockoutStatusPanel.changesSaving=(will be applied after Save button click)
operation.com.evolveum.midpoint.web.page.admin.server.PageTaskEdit.saveTask=Save task (GUI)
operation.com.evolveum.midpoint.web.page.admin.users.PageUsers.unlockUsers=Unlock user

PageSelfCredentials.lastChangeLabel=The last change for password was made by {1} on {0}
PageSelfCredentials.createInfoLabel=Password was created by {1} on {0}
PageSelfCredentials.lastChangeLabel=Password was last changed by {1} on {0}

0 comments on commit e3ca168

Please sign in to comment.