Shmuel Leib Melamud has uploaded a new change for review.

Change subject: webadmin: Run Once & Sysprep: mask and verify user password
......................................................................

webadmin: Run Once & Sysprep: mask and verify user password

Masked Sysprep password field in Run Once dialog and added second field
for password verification.

Also renamed get/setVmInit() methods to get/setVmInitModel() to
designate that they're working with field of type VmInitModel. This
differs from get/setVmInit() methods in other places that work with
VmInit class.

Change-Id: I72d9d993abd52759e159e41577dc1030173e028e
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1087936
Signed-off-by: Shmuel Melamud <smela...@redhat.com>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
5 files changed, 46 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/39418/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
index 19a3a92..c1a1184 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
@@ -157,6 +157,9 @@
     @DefaultStringValue("Password")
     String runOncePopupSysPrepPasswordLabel();
 
+    @DefaultStringValue("Verify Password")
+    String runOncePopupSysPrepPasswordVerificationLabel();
+
     @DefaultStringValue("Boot Sequence:")
     String runOncePopupBootSequenceLabel();
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
index 26ead4d..aa91469 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
@@ -15,6 +15,7 @@
 import org.ovirt.engine.ui.common.widget.editor.VncKeyMapRenderer;
 import 
org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor;
 import 
org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor;
+import 
org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelPasswordBoxEditor;
 import 
org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor;
 import org.ovirt.engine.ui.common.widget.form.key_value.KeyValueWidget;
 import org.ovirt.engine.ui.common.widget.renderer.NameRenderer;
@@ -204,7 +205,12 @@
     @UiField
     @Path(value = "sysPrepPassword.entity")
     @WithElementId("sysPrepPassword")
-    StringEntityModelTextBoxEditor sysPrepPasswordEditor;
+    StringEntityModelPasswordBoxEditor sysPrepPasswordEditor;
+
+    @UiField
+    @Path(value = "sysPrepPasswordVerification.entity")
+    @WithElementId("sysPrepPasswordVerification")
+    StringEntityModelPasswordBoxEditor sysPrepPasswordVerificationEditor;
 
     @UiField(provided = true)
     @Path(value = "displayConsole_Vnc_IsSelected.entity")
@@ -331,6 +337,7 @@
         
useAlternateCredentialsEditor.setLabel(constants.runOnceUseAlternateCredentialsLabel());
         
sysPrepUserNameEditor.setLabel(constants.runOncePopupSysPrepUserNameLabel());
         
sysPrepPasswordEditor.setLabel(constants.runOncePopupSysPrepPasswordLabel());
+        
sysPrepPasswordVerificationEditor.setLabel(constants.runOncePopupSysPrepPasswordVerificationLabel());
 
         // Display Protocol
         
displayConsoleVncEditor.setLabel(constants.runOncePopupDisplayConsoleVncLabel());
@@ -538,7 +545,7 @@
         bootSequenceModel = object.getBootSequence();
         UpdateBootSequenceListBox();
 
-        vmInitWidget.edit(object.getVmInit());
+        vmInitWidget.edit(object.getVmInitModel());
     }
 
     private void updateSysprepVisibility(RunOnceModel model) {
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml
index 39fce1c..3399beb 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml
@@ -219,7 +219,8 @@
                     <w:ComboBox ui:field="sysPrepDomainNameComboBox" />
                     <ge:EntityModelCheckBoxEditor 
ui:field="useAlternateCredentialsEditor" addStyleNames="{style.sysprepOption}" 
/>
                     <ge:StringEntityModelTextBoxEditor 
ui:field="sysPrepUserNameEditor" addStyleNames="{style.sysprepOption}" />
-                    <ge:StringEntityModelTextBoxEditor 
ui:field="sysPrepPasswordEditor" addStyleNames="{style.sysprepOption}" />
+                    <ge:StringEntityModelPasswordBoxEditor 
ui:field="sysPrepPasswordEditor" addStyleNames="{style.sysprepOption}" />
+                    <ge:StringEntityModelPasswordBoxEditor 
ui:field="sysPrepPasswordVerificationEditor" 
addStyleNames="{style.sysprepOption}" />
                 </g:VerticalPanel>
 
                        </g:FlowPanel>
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java
index 61cecb7..3bc8399 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java
@@ -43,6 +43,7 @@
 import 
org.ovirt.engine.ui.uicommonweb.validation.I18NExtraNameOrNoneValidation;
 import org.ovirt.engine.ui.uicommonweb.validation.IValidation;
 import org.ovirt.engine.ui.uicommonweb.validation.LengthValidation;
+import org.ovirt.engine.ui.uicommonweb.validation.MatchFieldsValidator;
 import 
org.ovirt.engine.ui.uicommonweb.validation.NoTrimmingWhitespacesValidation;
 import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
@@ -215,6 +216,15 @@
         privateSysPrepPassword = value;
     }
 
+    private EntityModel<String> privateSysPrepPasswordVerification;
+
+    public EntityModel<String> getSysPrepPasswordVerification()
+    {
+        return privateSysPrepPasswordVerification;
+    }
+
+    private void setSysPrepPasswordVerification(EntityModel<String> value) { 
privateSysPrepPasswordVerification = value; }
+
     private EntityModel<Boolean> privateUseAlternateCredentials;
 
     public EntityModel<Boolean> getUseAlternateCredentials()
@@ -293,12 +303,12 @@
 
     public VmInitModel privateVmInitModel;
 
-    public VmInitModel getVmInit()
+    public VmInitModel getVmInitModel()
     {
         return privateVmInitModel;
     }
 
-    public void setVmInit(VmInitModel value)
+    public void setVmInitModel(VmInitModel value)
     {
         privateVmInitModel = value;
     }
@@ -621,6 +631,7 @@
 
         setSysPrepUserName(new EntityModel<String>().setIsChangable(false));
         setSysPrepPassword(new EntityModel<String>().setIsChangable(false));
+        setSysPrepPasswordVerification(new 
EntityModel<String>().setIsChangable(false));
 
         setIsSysprepEnabled(new EntityModel<Boolean>(false));
         setIsSysprepPossible(new EntityModel<Boolean>());
@@ -633,7 +644,7 @@
         // Initial Boot tab - Cloud-Init
         setIsCloudInitPossible(new EntityModel<Boolean>());
 
-        setVmInit(new VmInitModel());
+        setVmInitModel(new VmInitModel());
 
         // Custom Properties tab
         setCustomPropertySheet(new KeyValueModel());
@@ -718,7 +729,7 @@
         getIsVmFirstRun().setEntity(!vm.isInitialized());
 
         initVmInitEnabled(vm.getVmInit(), vm.isInitialized());
-        getVmInit().init(vm.getStaticData());
+        getVmInitModel().init(vm.getStaticData());
 
         updateDomainList();
         updateSystemTabLists();
@@ -808,7 +819,7 @@
 
         if (getIsCloudInitEnabled() != null && 
getIsCloudInitEnabled().getEntity() ||
                 getIsSysprepEnabled() != null && 
getIsSysprepEnabled().getEntity()) {
-            params.setVmInit(getVmInit().buildCloudInitParameters(this));
+            params.setVmInit(getVmInitModel().buildCloudInitParameters(this));
         }
 
         
params.getRunOnceGraphics().add(Boolean.TRUE.equals(getDisplayConsole_Vnc_IsSelected().getEntity())
@@ -1160,9 +1171,11 @@
 
         
getSysPrepUserName().setIsChangable(getUseAlternateCredentials().getEntity());
         
getSysPrepPassword().setIsChangable(getUseAlternateCredentials().getEntity());
+        
getSysPrepPasswordVerification().setIsChangable(getUseAlternateCredentials().getEntity());
 
         getSysPrepUserName().setEntity(useAlternateCredentials ? "" : null); 
//$NON-NLS-1$
         getSysPrepPassword().setEntity(useAlternateCredentials ? "" : null); 
//$NON-NLS-1$
+        getSysPrepPasswordVerification().setEntity(useAlternateCredentials ? 
"" : null); //$NON-NLS-1$
     }
 
     private void isVmFirstRun_EntityChanged()
@@ -1244,7 +1257,18 @@
             getDefaultHost().setIsValid(true);
         }
 
-        boolean cloudInitIsValid = getVmInit().validate();
+        getSysPrepPassword().setIsValid(true);
+        getSysPrepPasswordVerification().setIsValid(true);
+
+        if (getIsWindowsOS() && getIsSysprepEnabled().getEntity()) {
+            getSysPrepPassword().validateEntity(new IValidation[] {
+                    new NotEmptyValidation(),
+                    new MatchFieldsValidator(getSysPrepPassword().getEntity(),
+                                             
getSysPrepPasswordVerification().getEntity())
+            });
+        }
+
+        boolean cloudInitIsValid = getVmInitModel().validate();
 
         getEmulatedMachine().validateSelectedItem(new IValidation[] { new 
I18NExtraNameOrNoneValidation(), new 
LengthValidation(BusinessEntitiesDefinitions.VM_EMULATED_MACHINE_SIZE) });
         getCustomCpu().validateSelectedItem(new IValidation[] { new 
I18NExtraNameOrNoneValidation(), new 
LengthValidation(BusinessEntitiesDefinitions.VM_CPU_NAME_SIZE) });
@@ -1257,6 +1281,7 @@
                 && getDefaultHost().getIsValid()
                 && customPropertyValidation
                 && cloudInitIsValid
+                && getSysPrepPassword().getIsValid()
                 && getEmulatedMachine().getIsValid()
                 && getCustomCpu().getIsValid();
     }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
index be2cb9d..e89ca1a 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
@@ -880,6 +880,7 @@
             vmInit.setActiveDirectoryOU(getActiveDirectoryOU().getEntity());
             if (getSysprepPasswordEnabled()) {
                 vmInit.setRootPassword(getSysprepAdminPassword().getEntity());
+                vmInit.setRootPassword(getSysprepAdminPassword().getEntity());
             }
             
vmInit.setPasswordAlreadyStored(getSysprepPasswordSet().getEntity());
             vmInit.setOrgName(getSysprepOrgName().getEntity());


-- 
To view, visit https://gerrit.ovirt.org/39418
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I72d9d993abd52759e159e41577dc1030173e028e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Shmuel Leib Melamud <smela...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to