Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 202695 | Differences between
and this patch

Collapse All | Expand All

(-)src-test/org/eclipse/hyades/models/common/datapool/DPLVariable.java (-1 / +33 lines)
Lines 32-37 Link Here
32
 * <ul>
32
 * <ul>
33
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getType <em>Type</em>}</li>
33
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getType <em>Type</em>}</li>
34
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getRole <em>Role</em>}</li>
34
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getRole <em>Role</em>}</li>
35
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#isEncrypted <em>Encrypted</em>}</li>
35
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getVariables <em>Variables</em>}</li>
36
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getVariables <em>Variables</em>}</li>
36
 * </ul>
37
 * </ul>
37
 * </p>
38
 * </p>
Lines 40-46 Link Here
40
 * @model
41
 * @model
41
 * @generated
42
 * @generated
42
 */
43
 */
43
public interface DPLVariable extends CMNNamedElement, IDatapoolVariable{
44
public interface DPLVariable extends CMNNamedElement, IDatapoolVariable {
44
	/**
45
	/**
45
	 * <!-- begin-user-doc -->
46
	 * <!-- begin-user-doc -->
46
	 * <!-- end-user-doc -->
47
	 * <!-- end-user-doc -->
Lines 104-109 Link Here
104
	void setRole(DPLRole value);
105
	void setRole(DPLRole value);
105
106
106
	/**
107
	/**
108
	 * Returns the value of the '<em><b>Encrypted</b></em>' attribute.
109
	 * The default value is <code>"false"</code>.
110
	 * <!-- begin-user-doc -->
111
	 * <p>
112
	 * If the meaning of the '<em>Encrypted</em>' attribute isn't clear,
113
	 * there really should be more of a description here...
114
	 * </p>
115
	 * <!-- end-user-doc -->
116
	 * <!-- begin-model-doc -->
117
	 * This boolean specifies whether or not this DPLVariable is encrypted.
118
	 * <!-- end-model-doc -->
119
	 * @return the value of the '<em>Encrypted</em>' attribute.
120
	 * @see #setEncrypted(boolean)
121
	 * @see org.eclipse.hyades.models.common.datapool.Common_DatapoolPackage#getDPLVariable_Encrypted()
122
	 * @model default="false"
123
	 * @generated
124
	 */
125
	boolean isEncrypted();
126
127
	/**
128
	 * Sets the value of the '{@link org.eclipse.hyades.models.common.datapool.DPLVariable#isEncrypted <em>Encrypted</em>}' attribute.
129
	 * <!-- begin-user-doc -->
130
	 * <!-- end-user-doc -->
131
	 * @param value the new value of the '<em>Encrypted</em>' attribute.
132
	 * @see #isEncrypted()
133
	 * @generated
134
	 */
135
	void setEncrypted(boolean value);
136
137
	/**
107
	 * Returns the value of the '<em><b>Variables</b></em>' containment reference list.
138
	 * Returns the value of the '<em><b>Variables</b></em>' containment reference list.
108
	 * The list contents are of type {@link org.eclipse.hyades.models.common.datapool.DPLVariable}.
139
	 * The list contents are of type {@link org.eclipse.hyades.models.common.datapool.DPLVariable}.
109
	 * <!-- begin-user-doc -->
140
	 * <!-- begin-user-doc -->
Lines 119-122 Link Here
119
	 */
150
	 */
120
	EList getVariables();
151
	EList getVariables();
121
152
153
	
122
} // DPLVariable
154
} // DPLVariable
(-)src-test/org/eclipse/hyades/models/common/datapool/Common_DatapoolPackage.java (-5 / +61 lines)
Lines 330-342 Link Here
330
	int DPL_VARIABLE__ROLE = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 1;
330
	int DPL_VARIABLE__ROLE = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 1;
331
331
332
	/**
332
	/**
333
	 * The feature id for the '<em><b>Encrypted</b></em>' attribute.
334
	 * <!-- begin-user-doc -->
335
	 * <!-- end-user-doc -->
336
	 * @generated
337
	 * @ordered
338
	 */
339
	int DPL_VARIABLE__ENCRYPTED = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 2;
340
341
	/**
333
	 * The feature id for the '<em><b>Variables</b></em>' containment reference list.
342
	 * The feature id for the '<em><b>Variables</b></em>' containment reference list.
334
	 * <!-- begin-user-doc -->
343
	 * <!-- begin-user-doc -->
335
	 * <!-- end-user-doc -->
344
	 * <!-- end-user-doc -->
336
	 * @generated
345
	 * @generated
337
	 * @ordered
346
	 * @ordered
338
	 */
347
	 */
339
	int DPL_VARIABLE__VARIABLES = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 2;
348
	int DPL_VARIABLE__VARIABLES = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 3;
340
349
341
	/**
350
	/**
342
	 * The number of structural features of the '<em>DPL Variable</em>' class.
351
	 * The number of structural features of the '<em>DPL Variable</em>' class.
Lines 345-351 Link Here
345
	 * @generated
354
	 * @generated
346
	 * @ordered
355
	 * @ordered
347
	 */
356
	 */
348
	int DPL_VARIABLE_FEATURE_COUNT = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 3;
357
	int DPL_VARIABLE_FEATURE_COUNT = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 4;
349
358
350
	/**
359
	/**
351
	 * The feature id for the '<em><b>Id</b></em>' attribute.
360
	 * The feature id for the '<em><b>Id</b></em>' attribute.
Lines 402-414 Link Here
402
	int DPL_DATAPOOL__INSTANTIATIONS = Common_ConfigurationPackage.CFG_CLASS__INSTANTIATIONS;
411
	int DPL_DATAPOOL__INSTANTIATIONS = Common_ConfigurationPackage.CFG_CLASS__INSTANTIATIONS;
403
412
404
	/**
413
	/**
414
	 * The feature id for the '<em><b>Challenge</b></em>' attribute.
415
	 * <!-- begin-user-doc -->
416
	 * <!-- end-user-doc -->
417
	 * @generated
418
	 * @ordered
419
	 */
420
	int DPL_DATAPOOL__CHALLENGE = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 0;
421
422
	/**
405
	 * The feature id for the '<em><b>Equivalence Classes</b></em>' containment reference list.
423
	 * The feature id for the '<em><b>Equivalence Classes</b></em>' containment reference list.
406
	 * <!-- begin-user-doc -->
424
	 * <!-- begin-user-doc -->
407
	 * <!-- end-user-doc -->
425
	 * <!-- end-user-doc -->
408
	 * @generated
426
	 * @generated
409
	 * @ordered
427
	 * @ordered
410
	 */
428
	 */
411
	int DPL_DATAPOOL__EQUIVALENCE_CLASSES = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 0;
429
	int DPL_DATAPOOL__EQUIVALENCE_CLASSES = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 1;
412
430
413
	/**
431
	/**
414
	 * The feature id for the '<em><b>Datapool Spec</b></em>' containment reference.
432
	 * The feature id for the '<em><b>Datapool Spec</b></em>' containment reference.
Lines 417-423 Link Here
417
	 * @generated
435
	 * @generated
418
	 * @ordered
436
	 * @ordered
419
	 */
437
	 */
420
	int DPL_DATAPOOL__DATAPOOL_SPEC = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 1;
438
	int DPL_DATAPOOL__DATAPOOL_SPEC = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 2;
421
439
422
	/**
440
	/**
423
	 * The number of structural features of the '<em>DPL Datapool</em>' class.
441
	 * The number of structural features of the '<em>DPL Datapool</em>' class.
Lines 426-432 Link Here
426
	 * @generated
444
	 * @generated
427
	 * @ordered
445
	 * @ordered
428
	 */
446
	 */
429
	int DPL_DATAPOOL_FEATURE_COUNT = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 2;
447
	int DPL_DATAPOOL_FEATURE_COUNT = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 3;
430
448
431
	/**
449
	/**
432
	 * The meta object id for the '{@link org.eclipse.hyades.models.common.datapool.DPLRole <em>DPL Role</em>}' enum.
450
	 * The meta object id for the '{@link org.eclipse.hyades.models.common.datapool.DPLRole <em>DPL Role</em>}' enum.
Lines 471-476 Link Here
471
	EClass getDPLDatapool();
489
	EClass getDPLDatapool();
472
490
473
	/**
491
	/**
492
	 * Returns the meta object for the attribute '{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getChallenge <em>Challenge</em>}'.
493
	 * <!-- begin-user-doc -->
494
	 * <!-- end-user-doc -->
495
	 * @return the meta object for the attribute '<em>Challenge</em>'.
496
	 * @see org.eclipse.hyades.models.common.datapool.DPLDatapool#getChallenge()
497
	 * @see #getDPLDatapool()
498
	 * @generated
499
	 */
500
	EAttribute getDPLDatapool_Challenge();
501
502
	/**
474
	 * Returns the meta object for the containment reference list '{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getEquivalenceClasses <em>Equivalence Classes</em>}'.
503
	 * Returns the meta object for the containment reference list '{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getEquivalenceClasses <em>Equivalence Classes</em>}'.
475
	 * <!-- begin-user-doc -->
504
	 * <!-- begin-user-doc -->
476
	 * <!-- end-user-doc -->
505
	 * <!-- end-user-doc -->
Lines 610-615 Link Here
610
	EAttribute getDPLVariable_Role();
639
	EAttribute getDPLVariable_Role();
611
640
612
	/**
641
	/**
642
	 * Returns the meta object for the attribute '{@link org.eclipse.hyades.models.common.datapool.DPLVariable#isEncrypted <em>Encrypted</em>}'.
643
	 * <!-- begin-user-doc -->
644
	 * <!-- end-user-doc -->
645
	 * @return the meta object for the attribute '<em>Encrypted</em>'.
646
	 * @see org.eclipse.hyades.models.common.datapool.DPLVariable#isEncrypted()
647
	 * @see #getDPLVariable()
648
	 * @generated
649
	 */
650
	EAttribute getDPLVariable_Encrypted();
651
652
	/**
613
	 * Returns the meta object for the containment reference list '{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getVariables <em>Variables</em>}'.
653
	 * Returns the meta object for the containment reference list '{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getVariables <em>Variables</em>}'.
614
	 * <!-- begin-user-doc -->
654
	 * <!-- begin-user-doc -->
615
	 * <!-- end-user-doc -->
655
	 * <!-- end-user-doc -->
Lines 767-772 Link Here
767
		EAttribute DPL_VARIABLE__ROLE = eINSTANCE.getDPLVariable_Role();
807
		EAttribute DPL_VARIABLE__ROLE = eINSTANCE.getDPLVariable_Role();
768
808
769
		/**
809
		/**
810
		 * The meta object literal for the '<em><b>Encrypted</b></em>' attribute feature.
811
		 * <!-- begin-user-doc -->
812
		 * <!-- end-user-doc -->
813
		 * @generated
814
		 */
815
		EAttribute DPL_VARIABLE__ENCRYPTED = eINSTANCE.getDPLVariable_Encrypted();
816
817
		/**
770
		 * The meta object literal for the '<em><b>Variables</b></em>' containment reference list feature.
818
		 * The meta object literal for the '<em><b>Variables</b></em>' containment reference list feature.
771
		 * <!-- begin-user-doc -->
819
		 * <!-- begin-user-doc -->
772
		 * <!-- end-user-doc -->
820
		 * <!-- end-user-doc -->
Lines 785-790 Link Here
785
		EClass DPL_DATAPOOL = eINSTANCE.getDPLDatapool();
833
		EClass DPL_DATAPOOL = eINSTANCE.getDPLDatapool();
786
834
787
		/**
835
		/**
836
		 * The meta object literal for the '<em><b>Challenge</b></em>' attribute feature.
837
		 * <!-- begin-user-doc -->
838
		 * <!-- end-user-doc -->
839
		 * @generated
840
		 */
841
		EAttribute DPL_DATAPOOL__CHALLENGE = eINSTANCE.getDPLDatapool_Challenge();
842
843
		/**
788
		 * The meta object literal for the '<em><b>Equivalence Classes</b></em>' containment reference list feature.
844
		 * The meta object literal for the '<em><b>Equivalence Classes</b></em>' containment reference list feature.
789
		 * <!-- begin-user-doc -->
845
		 * <!-- begin-user-doc -->
790
		 * <!-- end-user-doc -->
846
		 * <!-- end-user-doc -->
(-)src-test/org/eclipse/hyades/models/common/datapool/DPLDatapool.java (-1 / +28 lines)
Lines 31-36 Link Here
31
 * <p>
31
 * <p>
32
 * The following features are supported:
32
 * The following features are supported:
33
 * <ul>
33
 * <ul>
34
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getChallenge <em>Challenge</em>}</li>
34
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getEquivalenceClasses <em>Equivalence Classes</em>}</li>
35
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getEquivalenceClasses <em>Equivalence Classes</em>}</li>
35
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getDatapoolSpec <em>Datapool Spec</em>}</li>
36
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getDatapoolSpec <em>Datapool Spec</em>}</li>
36
 * </ul>
37
 * </ul>
Lines 40-46 Link Here
40
 * @model
41
 * @model
41
 * @generated
42
 * @generated
42
 */
43
 */
43
public interface DPLDatapool extends CFGClass, CMNNamedElement, IDatapool{
44
public interface DPLDatapool extends CFGClass, CMNNamedElement, IDatapool {
44
	/**
45
	/**
45
	 * <!-- begin-user-doc -->
46
	 * <!-- begin-user-doc -->
46
	 * <!-- end-user-doc -->
47
	 * <!-- end-user-doc -->
Lines 49-54 Link Here
49
	String copyright = "";
50
	String copyright = "";
50
51
51
	/**
52
	/**
53
	 * Returns the value of the '<em><b>Challenge</b></em>' attribute.
54
	 * <!-- begin-user-doc -->
55
	 * <!-- end-user-doc -->
56
	 * <!-- begin-model-doc -->
57
	 * This string is used to determine whether a user supplied password for an encrypted datapool is correct.
58
	 * <!-- end-model-doc -->
59
	 * @return the value of the '<em>Challenge</em>' attribute.
60
	 * @see #setChallenge(String)
61
	 * @see org.eclipse.hyades.models.common.datapool.Common_DatapoolPackage#getDPLDatapool_Challenge()
62
	 * @model
63
	 * @generated
64
	 */
65
	String getChallenge();
66
67
	/**
68
	 * Sets the value of the '{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getChallenge <em>Challenge</em>}' attribute.
69
	 * <!-- begin-user-doc -->
70
	 * <!-- end-user-doc -->
71
	 * @param value the new value of the '<em>Challenge</em>' attribute.
72
	 * @see #getChallenge()
73
	 * @generated
74
	 */
75
	void setChallenge(String value);
76
77
	/**
52
	 * Returns the value of the '<em><b>Equivalence Classes</b></em>' containment reference list.
78
	 * Returns the value of the '<em><b>Equivalence Classes</b></em>' containment reference list.
53
	 * The list contents are of type {@link org.eclipse.hyades.models.common.datapool.DPLEquivalenceClass}.
79
	 * The list contents are of type {@link org.eclipse.hyades.models.common.datapool.DPLEquivalenceClass}.
54
	 * <!-- begin-user-doc -->
80
	 * <!-- begin-user-doc -->
Lines 90-93 Link Here
90
	 */
116
	 */
91
	void setDatapoolSpec(DPLDatapoolSpec value);
117
	void setDatapoolSpec(DPLDatapoolSpec value);
92
118
119
	
93
} // DPLDatapool
120
} // DPLDatapool
(-)src-test/org/eclipse/hyades/models/common/datapool/impl/Common_DatapoolPackageImpl.java (-3 / +25 lines)
Lines 227-234 Link Here
227
	 * <!-- end-user-doc -->
227
	 * <!-- end-user-doc -->
228
	 * @generated
228
	 * @generated
229
	 */
229
	 */
230
	public EAttribute getDPLDatapool_Challenge() {
231
		return (EAttribute)dplDatapoolEClass.getEStructuralFeatures().get(0);
232
	}
233
234
	/**
235
	 * <!-- begin-user-doc -->
236
	 * <!-- end-user-doc -->
237
	 * @generated
238
	 */
230
	public EReference getDPLDatapool_EquivalenceClasses() {
239
	public EReference getDPLDatapool_EquivalenceClasses() {
231
		return (EReference)dplDatapoolEClass.getEStructuralFeatures().get(0);
240
		return (EReference)dplDatapoolEClass.getEStructuralFeatures().get(1);
232
	}
241
	}
233
242
234
	/**
243
	/**
Lines 237-243 Link Here
237
	 * @generated
246
	 * @generated
238
	 */
247
	 */
239
	public EReference getDPLDatapool_DatapoolSpec() {
248
	public EReference getDPLDatapool_DatapoolSpec() {
240
		return (EReference)dplDatapoolEClass.getEStructuralFeatures().get(1);
249
		return (EReference)dplDatapoolEClass.getEStructuralFeatures().get(2);
241
	}
250
	}
242
251
243
	/**
252
	/**
Lines 344-351 Link Here
344
	 * <!-- end-user-doc -->
353
	 * <!-- end-user-doc -->
345
	 * @generated
354
	 * @generated
346
	 */
355
	 */
356
	public EAttribute getDPLVariable_Encrypted() {
357
		return (EAttribute)dplVariableEClass.getEStructuralFeatures().get(2);
358
	}
359
360
	/**
361
	 * <!-- begin-user-doc -->
362
	 * <!-- end-user-doc -->
363
	 * @generated
364
	 */
347
	public EReference getDPLVariable_Variables() {
365
	public EReference getDPLVariable_Variables() {
348
		return (EReference)dplVariableEClass.getEStructuralFeatures().get(2);
366
		return (EReference)dplVariableEClass.getEStructuralFeatures().get(3);
349
	}
367
	}
350
368
351
	/**
369
	/**
Lines 402-410 Link Here
402
		dplVariableEClass = createEClass(DPL_VARIABLE);
420
		dplVariableEClass = createEClass(DPL_VARIABLE);
403
		createEAttribute(dplVariableEClass, DPL_VARIABLE__TYPE);
421
		createEAttribute(dplVariableEClass, DPL_VARIABLE__TYPE);
404
		createEAttribute(dplVariableEClass, DPL_VARIABLE__ROLE);
422
		createEAttribute(dplVariableEClass, DPL_VARIABLE__ROLE);
423
		createEAttribute(dplVariableEClass, DPL_VARIABLE__ENCRYPTED);
405
		createEReference(dplVariableEClass, DPL_VARIABLE__VARIABLES);
424
		createEReference(dplVariableEClass, DPL_VARIABLE__VARIABLES);
406
425
407
		dplDatapoolEClass = createEClass(DPL_DATAPOOL);
426
		dplDatapoolEClass = createEClass(DPL_DATAPOOL);
427
		createEAttribute(dplDatapoolEClass, DPL_DATAPOOL__CHALLENGE);
408
		createEReference(dplDatapoolEClass, DPL_DATAPOOL__EQUIVALENCE_CLASSES);
428
		createEReference(dplDatapoolEClass, DPL_DATAPOOL__EQUIVALENCE_CLASSES);
409
		createEReference(dplDatapoolEClass, DPL_DATAPOOL__DATAPOOL_SPEC);
429
		createEReference(dplDatapoolEClass, DPL_DATAPOOL__DATAPOOL_SPEC);
410
430
Lines 464-472 Link Here
464
		initEClass(dplVariableEClass, DPLVariable.class, "DPLVariable", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
484
		initEClass(dplVariableEClass, DPLVariable.class, "DPLVariable", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
465
		initEAttribute(getDPLVariable_Type(), ecorePackage.getEString(), "type", null, 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
485
		initEAttribute(getDPLVariable_Type(), ecorePackage.getEString(), "type", null, 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
466
		initEAttribute(getDPLVariable_Role(), this.getDPLRole(), "role", null, 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
486
		initEAttribute(getDPLVariable_Role(), this.getDPLRole(), "role", null, 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
487
		initEAttribute(getDPLVariable_Encrypted(), ecorePackage.getEBoolean(), "encrypted", "false", 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
467
		initEReference(getDPLVariable_Variables(), this.getDPLVariable(), null, "variables", null, 0, -1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
488
		initEReference(getDPLVariable_Variables(), this.getDPLVariable(), null, "variables", null, 0, -1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
468
489
469
		initEClass(dplDatapoolEClass, DPLDatapool.class, "DPLDatapool", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
490
		initEClass(dplDatapoolEClass, DPLDatapool.class, "DPLDatapool", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
491
		initEAttribute(getDPLDatapool_Challenge(), ecorePackage.getEString(), "challenge", null, 0, 1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
470
		initEReference(getDPLDatapool_EquivalenceClasses(), this.getDPLEquivalenceClass(), null, "equivalenceClasses", null, 0, -1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
492
		initEReference(getDPLDatapool_EquivalenceClasses(), this.getDPLEquivalenceClass(), null, "equivalenceClasses", null, 0, -1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
471
		initEReference(getDPLDatapool_DatapoolSpec(), this.getDPLDatapoolSpec(), null, "datapoolSpec", null, 1, 1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
493
		initEReference(getDPLDatapool_DatapoolSpec(), this.getDPLDatapoolSpec(), null, "datapoolSpec", null, 1, 1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
472
494
(-)src-test/org/eclipse/hyades/models/common/datapool/impl/DPLCellImpl.java (-10 / +33 lines)
Lines 16-23 Link Here
16
16
17
package org.eclipse.hyades.models.common.datapool.impl;
17
package org.eclipse.hyades.models.common.datapool.impl;
18
18
19
import java.util.HashMap;
19
import org.eclipse.emf.common.notify.Notification;
20
import org.eclipse.emf.common.notify.Notification;
20
import org.eclipse.emf.ecore.EClass;
21
import org.eclipse.emf.ecore.EClass;
22
import org.eclipse.emf.ecore.EStructuralFeature;
21
import org.eclipse.emf.ecore.InternalEObject;
23
import org.eclipse.emf.ecore.InternalEObject;
22
import org.eclipse.emf.ecore.impl.ENotificationImpl;
24
import org.eclipse.emf.ecore.impl.ENotificationImpl;
23
import org.eclipse.emf.ecore.impl.EObjectImpl;
25
import org.eclipse.emf.ecore.impl.EObjectImpl;
Lines 28-34 Link Here
28
import org.eclipse.hyades.models.common.datapool.Common_DatapoolPackage;
30
import org.eclipse.hyades.models.common.datapool.Common_DatapoolPackage;
29
import org.eclipse.hyades.models.common.datapool.DPLCell;
31
import org.eclipse.hyades.models.common.datapool.DPLCell;
30
import org.eclipse.hyades.models.common.datapool.DPLVariable;
32
import org.eclipse.hyades.models.common.datapool.DPLVariable;
33
import org.eclipse.hyades.models.common.datapool.util.DPLPasswordCollection;
31
import org.eclipse.hyades.models.common.util.DatapoolUtil;
34
import org.eclipse.hyades.models.common.util.DatapoolUtil;
35
import org.eclipse.hyades.models.common.util.EncryptionManager;
32
import org.eclipse.hyades.models.common.util.XMLParserUtil;
36
import org.eclipse.hyades.models.common.util.XMLParserUtil;
33
import org.w3c.dom.Document;
37
import org.w3c.dom.Document;
34
38
Lines 361-367 Link Here
361
	{
365
	{
362
		Object cellValue = this.getCellValue();
366
		Object cellValue = this.getCellValue();
363
		if(cellValue != null)
367
		if(cellValue != null)
364
			return cellValue.toString();
368
			return decryptValue(cellValue.toString());
365
		else
369
		else
366
			return new String();
370
			return new String();
367
	}
371
	}
Lines 376-382 Link Here
376
	 */
380
	 */
377
	public long getLongValue()
381
	public long getLongValue()
378
	{
382
	{
379
		return Long.parseLong((String)this.getCellValue());
383
		return Long.parseLong(decryptValue((String)this.getCellValue()));
380
	}
384
	}
381
	
385
	
382
	/**
386
	/**
Lines 389-395 Link Here
389
	 */
393
	 */
390
	public int getIntValue()
394
	public int getIntValue()
391
	{
395
	{
392
		return Integer.parseInt((String)this.getCellValue());
396
		return Integer.parseInt(decryptValue((String)this.getCellValue()));
393
	}
397
	}
394
	
398
	
395
	/**
399
	/**
Lines 402-408 Link Here
402
	 */
406
	 */
403
	public short getShortValue()
407
	public short getShortValue()
404
	{
408
	{
405
		return Short.parseShort((String)this.getCellValue());
409
		return Short.parseShort(decryptValue((String)this.getCellValue()));
406
	}
410
	}
407
	
411
	
408
	/**
412
	/**
Lines 415-421 Link Here
415
	 */
419
	 */
416
	public byte getByteValue()
420
	public byte getByteValue()
417
	{
421
	{
418
		return Byte.parseByte((String)this.getCellValue());
422
		return Byte.parseByte(decryptValue((String)this.getCellValue()));
419
	}
423
	}
420
	
424
	
421
	/**
425
	/**
Lines 428-434 Link Here
428
	 */
432
	 */
429
	public double getDoubleValue()
433
	public double getDoubleValue()
430
	{
434
	{
431
		return Double.parseDouble((String)this.getCellValue());
435
		return Double.parseDouble(decryptValue((String)this.getCellValue()));
432
	}
436
	}
433
	
437
	
434
	/**
438
	/**
Lines 441-447 Link Here
441
	 */
445
	 */
442
	public float getFloatValue()
446
	public float getFloatValue()
443
	{
447
	{
444
		return Float.parseFloat((String)this.getCellValue());
448
		return Float.parseFloat(decryptValue((String)this.getCellValue()));
445
	}
449
	}
446
	
450
	
447
	/**
451
	/**
Lines 454-460 Link Here
454
	 */
458
	 */
455
	public boolean getBooleanValue()
459
	public boolean getBooleanValue()
456
	{
460
	{
457
		return Boolean.getBoolean ((String)this.getCellValue());
461
		return Boolean.getBoolean (decryptValue((String)this.getCellValue()));
458
	}
462
	}
459
	
463
	
460
	/**
464
	/**
Lines 468-474 Link Here
468
	 */
472
	 */
469
	public char getCharValue()
473
	public char getCharValue()
470
	{
474
	{
471
		return ((String)this.getCellValue()).charAt(0);
475
		return decryptValue(((String)this.getCellValue())).charAt(0);
472
	}
476
	}
473
477
474
	/**
478
	/**
Lines 504-510 Link Here
504
		{
508
		{
505
	        //get the tag and value from the XML fragment
509
	        //get the tag and value from the XML fragment
506
			try {	
510
			try {	
507
				Document doc = XMLParserUtil.parse(value.toString());		
511
				Document doc = XMLParserUtil.parse(value.toString());					
508
				tag = doc.getFirstChild().getNodeName();
512
				tag = doc.getFirstChild().getNodeName();
509
				val = doc.getFirstChild().getFirstChild().getNodeValue();
513
				val = doc.getFirstChild().getFirstChild().getNodeValue();
510
		    }
514
		    }
Lines 569-572 Link Here
569
		else
573
		else
570
			return START_LITERAL + END_LITERAL;
574
			return START_LITERAL + END_LITERAL;
571
	}	
575
	}	
576
	/*
577
	 * decryptValue the cell value
578
	 */
579
	public String decryptValue(String value){
580
		String result = null;
581
		if(value == null)
582
			return result;
583
		
584
		result = value;
585
		HashMap passes = DPLPasswordCollection.getInstance().getDatapoolPassword();		
586
	    String dpName = this.getCellRecord().getEquivalenceClass().getDatapool().getName();
587
		if(passes!=null && passes.size()>0 && dpName != null && this.getVariable().isEncrypted()){
588
	    	String pass = (String)passes.get(dpName);
589
	    	if(pass != null){
590
	    		result = EncryptionManager.decrypt(value, pass);
591
	    	}
592
	    }
593
		return result;
594
	}
572
} //DPLCellImpl
595
} //DPLCellImpl
(-)src-test/org/eclipse/hyades/models/common/datapool/impl/DPLVariableImpl.java (+59 lines)
Lines 48-53 Link Here
48
 * <ul>
48
 * <ul>
49
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getType <em>Type</em>}</li>
49
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getType <em>Type</em>}</li>
50
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getRole <em>Role</em>}</li>
50
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getRole <em>Role</em>}</li>
51
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#isEncrypted <em>Encrypted</em>}</li>
51
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getVariables <em>Variables</em>}</li>
52
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getVariables <em>Variables</em>}</li>
52
 * </ul>
53
 * </ul>
53
 * </p>
54
 * </p>
Lines 105-110 Link Here
105
	protected DPLRole role = ROLE_EDEFAULT;
106
	protected DPLRole role = ROLE_EDEFAULT;
106
107
107
	/**
108
	/**
109
	 * The default value of the '{@link #isEncrypted() <em>Encrypted</em>}' attribute.
110
	 * <!-- begin-user-doc -->
111
	 * <!-- end-user-doc -->
112
	 * @see #isEncrypted()
113
	 * @generated
114
	 * @ordered
115
	 */
116
	protected static final boolean ENCRYPTED_EDEFAULT = false;
117
118
	/**
119
	 * The cached value of the '{@link #isEncrypted() <em>Encrypted</em>}' attribute.
120
	 * <!-- begin-user-doc -->
121
	 * <!-- end-user-doc -->
122
	 * @see #isEncrypted()
123
	 * @generated
124
	 * @ordered
125
	 */
126
	protected boolean encrypted = ENCRYPTED_EDEFAULT;
127
128
	/**
108
	 * The cached value of the '{@link #getVariables() <em>Variables</em>}' containment reference list.
129
	 * The cached value of the '{@link #getVariables() <em>Variables</em>}' containment reference list.
109
	 * <!-- begin-user-doc -->
130
	 * <!-- begin-user-doc -->
110
	 * <!-- end-user-doc -->
131
	 * <!-- end-user-doc -->
Lines 179-184 Link Here
179
	 * <!-- end-user-doc -->
200
	 * <!-- end-user-doc -->
180
	 * @generated
201
	 * @generated
181
	 */
202
	 */
203
	public boolean isEncrypted() {
204
		return encrypted;
205
	}
206
207
	/**
208
	 * <!-- begin-user-doc -->
209
	 * <!-- end-user-doc -->
210
	 * @generated
211
	 */
212
	public void setEncrypted(boolean newEncrypted) {
213
		boolean oldEncrypted = encrypted;
214
		encrypted = newEncrypted;
215
		if (eNotificationRequired())
216
			eNotify(new ENotificationImpl(this, Notification.SET, Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED, oldEncrypted, encrypted));
217
	}
218
219
	/**
220
	 * <!-- begin-user-doc -->
221
	 * <!-- end-user-doc -->
222
	 * @generated
223
	 */
182
	public EList getVariables() {
224
	public EList getVariables() {
183
		if (variables == null) {
225
		if (variables == null) {
184
			variables = new EObjectContainmentEList(DPLVariable.class, this, Common_DatapoolPackage.DPL_VARIABLE__VARIABLES);
226
			variables = new EObjectContainmentEList(DPLVariable.class, this, Common_DatapoolPackage.DPL_VARIABLE__VARIABLES);
Lines 210-215 Link Here
210
				return getType();
252
				return getType();
211
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
253
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
212
				return getRole();
254
				return getRole();
255
			case Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED:
256
				return isEncrypted() ? Boolean.TRUE : Boolean.FALSE;
213
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
257
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
214
				return getVariables();
258
				return getVariables();
215
		}
259
		}
Lines 229-234 Link Here
229
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
273
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
230
				setRole((DPLRole)newValue);
274
				setRole((DPLRole)newValue);
231
				return;
275
				return;
276
			case Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED:
277
				setEncrypted(((Boolean)newValue).booleanValue());
278
				return;
232
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
279
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
233
				getVariables().clear();
280
				getVariables().clear();
234
				getVariables().addAll((Collection)newValue);
281
				getVariables().addAll((Collection)newValue);
Lines 250-255 Link Here
250
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
297
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
251
				setRole(ROLE_EDEFAULT);
298
				setRole(ROLE_EDEFAULT);
252
				return;
299
				return;
300
			case Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED:
301
				setEncrypted(ENCRYPTED_EDEFAULT);
302
				return;
253
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
303
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
254
				getVariables().clear();
304
				getVariables().clear();
255
				return;
305
				return;
Lines 267-273 Link Here
267
			case Common_DatapoolPackage.DPL_VARIABLE__TYPE:
317
			case Common_DatapoolPackage.DPL_VARIABLE__TYPE:
268
				return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
318
				return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
269
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
319
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
320
       		
270
				return role != ROLE_EDEFAULT;
321
				return role != ROLE_EDEFAULT;
322
	        
323
			case Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED:
324
       		
325
				return encrypted != ENCRYPTED_EDEFAULT;
326
	        
271
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
327
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
272
				return variables != null && !variables.isEmpty();
328
				return variables != null && !variables.isEmpty();
273
		}
329
		}
Lines 287-296 Link Here
287
		result.append(type);
343
		result.append(type);
288
		result.append(", role: ");
344
		result.append(", role: ");
289
		result.append(role);
345
		result.append(role);
346
		result.append(", encrypted: ");
347
		result.append(encrypted);
290
		result.append(')');
348
		result.append(')');
291
		return result.toString();
349
		return result.toString();
292
	}
350
	}
293
351
352
	
294
	//Beginning of non-generated classes
353
	//Beginning of non-generated classes
295
	
354
	
296
	//org.eclipse.hyades.edit.datapool.IDatapoolVariable methods
355
	//org.eclipse.hyades.edit.datapool.IDatapoolVariable methods
(-)src-test/org/eclipse/hyades/models/common/datapool/impl/DPLDatapoolImpl.java (+68 lines)
Lines 55-60 Link Here
55
 * <p>
55
 * <p>
56
 * The following features are implemented:
56
 * The following features are implemented:
57
 * <ul>
57
 * <ul>
58
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getChallenge <em>Challenge</em>}</li>
58
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getEquivalenceClasses <em>Equivalence Classes</em>}</li>
59
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getEquivalenceClasses <em>Equivalence Classes</em>}</li>
59
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getDatapoolSpec <em>Datapool Spec</em>}</li>
60
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getDatapoolSpec <em>Datapool Spec</em>}</li>
60
 * </ul>
61
 * </ul>
Lines 73-78 Link Here
73
	public static final String copyright = "";
74
	public static final String copyright = "";
74
75
75
	/**
76
	/**
77
	 * The default value of the '{@link #getChallenge() <em>Challenge</em>}' attribute.
78
	 * <!-- begin-user-doc -->
79
	 * <!-- end-user-doc -->
80
	 * @see #getChallenge()
81
	 * @generated
82
	 * @ordered
83
	 */
84
	protected static final String CHALLENGE_EDEFAULT = null;
85
86
	/**
87
	 * The cached value of the '{@link #getChallenge() <em>Challenge</em>}' attribute.
88
	 * <!-- begin-user-doc -->
89
	 * <!-- end-user-doc -->
90
	 * @see #getChallenge()
91
	 * @generated
92
	 * @ordered
93
	 */
94
	protected String challenge = CHALLENGE_EDEFAULT;
95
96
	/**
76
	 * The cached value of the '{@link #getEquivalenceClasses() <em>Equivalence Classes</em>}' containment reference list.
97
	 * The cached value of the '{@link #getEquivalenceClasses() <em>Equivalence Classes</em>}' containment reference list.
77
	 * <!-- begin-user-doc -->
98
	 * <!-- begin-user-doc -->
78
	 * <!-- end-user-doc -->
99
	 * <!-- end-user-doc -->
Lines 132-137 Link Here
132
	 * <!-- end-user-doc -->
153
	 * <!-- end-user-doc -->
133
	 * @generated
154
	 * @generated
134
	 */
155
	 */
156
	public String getChallenge() {
157
		return challenge;
158
	}
159
160
	/**
161
	 * <!-- begin-user-doc -->
162
	 * <!-- end-user-doc -->
163
	 * @generated
164
	 */
165
	public void setChallenge(String newChallenge) {
166
		String oldChallenge = challenge;
167
		challenge = newChallenge;
168
		if (eNotificationRequired())
169
			eNotify(new ENotificationImpl(this, Notification.SET, Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE, oldChallenge, challenge));
170
	}
171
172
	/**
173
	 * <!-- begin-user-doc -->
174
	 * <!-- end-user-doc -->
175
	 * @generated
176
	 */
135
	public EList getEquivalenceClasses() {
177
	public EList getEquivalenceClasses() {
136
		if (equivalenceClasses == null) {
178
		if (equivalenceClasses == null) {
137
			equivalenceClasses = new EObjectContainmentEList(DPLEquivalenceClass.class, this, Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES);
179
			equivalenceClasses = new EObjectContainmentEList(DPLEquivalenceClass.class, this, Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES);
Lines 204-209 Link Here
204
	 */
246
	 */
205
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
247
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
206
		switch (featureID) {
248
		switch (featureID) {
249
			case Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE:
250
				return getChallenge();
207
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
251
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
208
				return getEquivalenceClasses();
252
				return getEquivalenceClasses();
209
			case Common_DatapoolPackage.DPL_DATAPOOL__DATAPOOL_SPEC:
253
			case Common_DatapoolPackage.DPL_DATAPOOL__DATAPOOL_SPEC:
Lines 219-224 Link Here
219
	 */
263
	 */
220
	public void eSet(int featureID, Object newValue) {
264
	public void eSet(int featureID, Object newValue) {
221
		switch (featureID) {
265
		switch (featureID) {
266
			case Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE:
267
				setChallenge((String)newValue);
268
				return;
222
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
269
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
223
				getEquivalenceClasses().clear();
270
				getEquivalenceClasses().clear();
224
				getEquivalenceClasses().addAll((Collection)newValue);
271
				getEquivalenceClasses().addAll((Collection)newValue);
Lines 237-242 Link Here
237
	 */
284
	 */
238
	public void eUnset(int featureID) {
285
	public void eUnset(int featureID) {
239
		switch (featureID) {
286
		switch (featureID) {
287
			case Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE:
288
				setChallenge(CHALLENGE_EDEFAULT);
289
				return;
240
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
290
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
241
				getEquivalenceClasses().clear();
291
				getEquivalenceClasses().clear();
242
				return;
292
				return;
Lines 254-259 Link Here
254
	 */
304
	 */
255
	public boolean eIsSet(int featureID) {
305
	public boolean eIsSet(int featureID) {
256
		switch (featureID) {
306
		switch (featureID) {
307
			case Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE:
308
				return CHALLENGE_EDEFAULT == null ? challenge != null : !CHALLENGE_EDEFAULT.equals(challenge);
257
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
309
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
258
				return equivalenceClasses != null && !equivalenceClasses.isEmpty();
310
				return equivalenceClasses != null && !equivalenceClasses.isEmpty();
259
			case Common_DatapoolPackage.DPL_DATAPOOL__DATAPOOL_SPEC:
311
			case Common_DatapoolPackage.DPL_DATAPOOL__DATAPOOL_SPEC:
Lines 262-267 Link Here
262
		return super.eIsSet(featureID);
314
		return super.eIsSet(featureID);
263
	}
315
	}
264
316
317
	/**
318
	 * <!-- begin-user-doc -->
319
	 * <!-- end-user-doc -->
320
	 * @generated
321
	 */
322
	public String toString() {
323
		if (eIsProxy()) return super.toString();
324
325
		StringBuffer result = new StringBuffer(super.toString());
326
		result.append(" (challenge: ");
327
		result.append(challenge);
328
		result.append(')');
329
		return result.toString();
330
	}
331
332
	
265
	/* (non-Javadoc)
333
	/* (non-Javadoc)
266
	 * @see org.eclipse.hyades.models.common.configuration.impl.CFGClassImpl#getLocation()
334
	 * @see org.eclipse.hyades.models.common.configuration.impl.CFGClassImpl#getLocation()
267
	 */
335
	 */
(-)src-test/org/eclipse/hyades/models/common/datapool/util/DatapoolEncryptManager.java (+177 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: DatapoolEncryptManager.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.models.common.datapool.util;
14
15
import org.eclipse.hyades.edit.datapool.IDatapool;
16
import org.eclipse.hyades.edit.datapool.IDatapoolCell;
17
import org.eclipse.hyades.edit.datapool.IDatapoolRecord;
18
import org.eclipse.hyades.execution.runtime.datapool.IDatapoolEquivalenceClass;
19
import org.eclipse.hyades.execution.runtime.datapool.IDatapoolVariable;
20
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
21
import org.eclipse.hyades.models.common.datapool.DPLVariable;
22
import org.eclipse.hyades.models.common.util.EncryptionManager;
23
24
/**
25
 * It's used to provide functions of encryption for a datapool .
26
 * 
27
 * @author Huang Xin Ying 
28
 */
29
public class DatapoolEncryptManager {
30
31
	public static void encryptedCellInVarible(IDatapoolVariable varible,
32
			String key, IDatapool datapool) {
33
34
		// String key = DatapoolKeyManager.getKeyInDatapool(datapool);
35
		// IDatapoolEquivalenceClass equivalenceClass =
36
		// getDefaultEquivalenceClass(datapool);
37
		int index = datapool.getDefaultEquivalenceClassIndex();
38
		if (index == -1) {
39
40
			return;
41
		}
42
		IDatapoolEquivalenceClass equivalenceClass = datapool
43
				.getEquivalenceClass(index);
44
		// datapool.get
45
		for (int i = 0; i < equivalenceClass.getRecordCount(); i++) {
46
			IDatapoolRecord record = (IDatapoolRecord) equivalenceClass
47
					.getRecord(i);
48
			int cellCount = record.getCellCount();
49
50
			int variableCount = datapool.getVariableCount();
51
			String rowContents[] = new String[variableCount + 1];
52
			IDatapoolCell[] rowData = new IDatapoolCell[variableCount];
53
			rowContents[0] = String.valueOf(i);
54
55
			for (int k = 0; k < cellCount; k++) {
56
				IDatapoolCell cell = (IDatapoolCell) record.getCell(k);
57
				if (cell.getCellVariable().getId().equals(varible.getId())) {
58
					cell.setCellValue(EncryptionManager.encrypt(cell.getStringValue(),
59
							key));
60
				}
61
			}
62
		}
63
	}
64
65
	public static void deencryptedCellInVarible(IDatapoolVariable varible,
66
			String key, IDatapool datapool) {
67
		int index = datapool.getDefaultEquivalenceClassIndex();
68
		if (index == -1) {
69
			return;
70
		}
71
		IDatapoolEquivalenceClass equivalenceClass = datapool
72
				.getEquivalenceClass(index);
73
74
		for (int i = 0; i < equivalenceClass.getRecordCount(); i++) {
75
			IDatapoolRecord record = (IDatapoolRecord) equivalenceClass
76
					.getRecord(i);
77
			int cellCount = record.getCellCount();
78
79
			int variableCount = datapool.getVariableCount();
80
			String rowContents[] = new String[variableCount + 1];
81
			IDatapoolCell[] rowData = new IDatapoolCell[variableCount];
82
			rowContents[0] = String.valueOf(i);
83
84
			for (int k = 0; k < cellCount; k++) {
85
				IDatapoolCell cell = (IDatapoolCell) record.getCell(k);
86
				if (cell.getCellVariable().getId().equals(varible.getId())) {
87
					cell.setCellValue(EncryptionManager.decrypt(cell.getStringValue(),
88
							key));
89
				}
90
			}
91
		}
92
	}
93
94
	public static void ChangeKey(String newKey, IDatapool datapool) {
95
		if (!(datapool instanceof DPLDatapool))
96
			return;
97
		if (newKey == null || newKey.equals(""))
98
			((DPLDatapool) datapool).setChallenge(null);
99
		else
100
			((DPLDatapool) datapool).setChallenge(newKey);
101
	}
102
103
	public static void changeKeyOfEncryCell(IDatapool datapool, String oldKey,
104
			String newKey) {
105
		int variableCount = datapool.getVariableCount();
106
		IDatapoolVariable variable = null;
107
		for (int i = 0; i < variableCount; i++) {
108
			variable = datapool.getVariable(i);
109
			if (isVaribelEncrypted(variable)) {
110
				deencryptedCellInVarible(variable, oldKey, datapool);
111
				encryptedCellInVarible(variable, newKey, datapool);
112
			}
113
		}
114
	}
115
	
116
	public static void deencrypDatapool(IDatapool datapool, String key){
117
		int variableCount = datapool.getVariableCount();
118
		IDatapoolVariable variable = null;
119
		for (int i = 0; i < variableCount; i++) {
120
			variable = datapool.getVariable(i);
121
			if (isVaribelEncrypted(variable)) {
122
				deencryptedCellInVarible(variable, key, datapool);				
123
			}
124
		}
125
	}
126
	
127
	public static void encrypDatapool(IDatapool datapool, String key){
128
		int variableCount = datapool.getVariableCount();
129
		IDatapoolVariable variable = null;
130
		for (int i = 0; i < variableCount; i++) {
131
			variable = datapool.getVariable(i);
132
			if (isVaribelEncrypted(variable)) {
133
				encryptedCellInVarible(variable, key, datapool);			
134
			}
135
		}
136
	}
137
138
	public static boolean isDatapoolEncrypted(IDatapool datapool) {
139
		if (!(datapool instanceof DPLDatapool))
140
			return false;
141
142
		if (((DPLDatapool) datapool).getChallenge() == null
143
				|| ((DPLDatapool) datapool).getChallenge().equals(""))
144
			return false;
145
		return true;
146
	}
147
148
	public static boolean isKeyCorrect(IDatapool datapool, String key) {
149
		if (!(datapool instanceof DPLDatapool))
150
			return false;
151
		if (key == null)
152
			return false;
153
		boolean flag = false;
154
		try {
155
			flag = EncryptionManager.EncoderByMd5(key).equals(
156
					((DPLDatapool) datapool).getChallenge());
157
		} catch (Exception e) {
158
			System.out.println("error while keycorrect");
159
		}
160
		return flag;
161
162
	}
163
164
	public static boolean isVaribelEncrypted(IDatapoolVariable varible) {
165
		return (varible instanceof DPLVariable) ? ((DPLVariable) varible)
166
				.isEncrypted() : false;
167
	}
168
169
	public static String encrypt(String content, String pass) {
170
		return EncryptionManager.encrypt(content, pass);
171
	}
172
173
	public static String decrypt(String content, String pass) {
174
		return EncryptionManager.decrypt(content, pass);
175
	}
176
177
}
(-)src-test/org/eclipse/hyades/models/common/datapool/util/DPLPasswordCollection.java (+48 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: DPLPasswordCollection.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.models.common.datapool.util;
13
14
import java.util.HashMap;
15
16
/**
17
 * It's used to save HashMap of datapools and passwords for the test 
18
 * during executing a test in agent controller side .
19
 * 
20
 * @author Huang Xin Ying 
21
 */
22
public class DPLPasswordCollection {
23
	private static DPLPasswordCollection instance = null;
24
25
	private HashMap datapoolPassword = new HashMap();
26
27
	private DPLPasswordCollection() {
28
	}
29
30
	public static DPLPasswordCollection getInstance() {
31
		if (instance == null) {
32
			instance = new DPLPasswordCollection();
33
		} 
34
		return instance;
35
	}
36
37
	public HashMap getDatapoolPassword() {
38
		return datapoolPassword;
39
	}
40
41
	public void setDatapoolPassword(HashMap datapoolPassword) {
42
		this.datapoolPassword = datapoolPassword;
43
	}
44
	
45
	public void clear(){
46
		this.datapoolPassword.clear();
47
	}	
48
}
(-)src-test/org/eclipse/hyades/models/common/util/EncryptionManager.java (+154 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: EncryptionManager.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.models.common.util;
14
15
import java.io.UnsupportedEncodingException;
16
import java.security.MessageDigest;
17
import java.security.NoSuchAlgorithmException;
18
19
import javax.crypto.Cipher;
20
import javax.crypto.spec.SecretKeySpec;
21
22
/**
23
 * It's used to provide encryption and decryption algorithm for a datapool .
24
 * 
25
 * @author Huang Xin Ying 
26
 */
27
public class EncryptionManager {
28
29
	public static String encrypt(String content, String pass) {
30
		RC4Encrypter encrypter = new RC4Encrypter();
31
		String encryptedStr = encrypter.cipherMessage(pass, content);
32
		return encryptedStr;
33
	}
34
35
	public static String decrypt(String content, String pass) {
36
		RC4Encrypter rc4Encrypted = new RC4Encrypter();
37
38
		String deencryptedStr = rc4Encrypted.decipherMessage(pass, content);
39
		return deencryptedStr;
40
41
	}
42
43
	public static String EncoderByMd5(String str)
44
			throws NoSuchAlgorithmException, UnsupportedEncodingException {
45
		if (str == null)
46
			return null;
47
		MessageDigest md5 = MessageDigest.getInstance("MD5");
48
		RC4Encrypter rc4Encrypted = new RC4Encrypter();
49
		
50
		return rc4Encrypted.byteArrayToHexString(md5.digest(str.getBytes()));
51
	}
52
53
	public static class RC4Encrypter {
54
		
55
		public static final String[] HEXARRAY = {
56
	        "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"
57
	    };
58
59
		public String cipherMessage(String pass, String content) {
60
			if (pass == null || pass.equals("") || content == null
61
					|| content.equals("")) {
62
				return content;
63
			}
64
			try {
65
				SecretKeySpec key = this.generateKey(pass);
66
				Cipher cipher = Cipher.getInstance("RC4");
67
				cipher.init(Cipher.ENCRYPT_MODE, key);
68
				byte[] code = cipher.update(content.getBytes());
69
				return byteArrayToHexString(code);
70
			} catch (Exception e) {
71
				e.printStackTrace();
72
			}
73
			return null;
74
		}
75
76
		public String decipherMessage(String pass, String encryptStr)
77
78
		{
79
			if (pass == null || pass.equals("") || encryptStr == null
80
					|| encryptStr.equals("")) {
81
				return encryptStr;
82
			}
83
			try {
84
				SecretKeySpec key = this.generateKey(pass);
85
				Cipher cipher = Cipher.getInstance("RC4");
86
				cipher.init(Cipher.DECRYPT_MODE, key);
87
				byte[] text = hexStringToByteArray(encryptStr);
88
				byte[] code = cipher.update(text);
89
				return new String(code);
90
			} catch (Exception e) {
91
				e.printStackTrace();
92
			}
93
			return null;
94
		}
95
96
		private SecretKeySpec generateKey(String inpass)
97
98
		{
99
			try {
100
				byte[] pass = inpass.getBytes();
101
102
				MessageDigest md5 = MessageDigest.getInstance("MD5");
103
104
				md5.update(pass);
105
				byte temp[] = md5.digest();
106
107
				SecretKeySpec key = new SecretKeySpec(temp, "RC4");
108
				return key;
109
110
			} catch (Exception e) {
111
				e.printStackTrace();
112
			}
113
			return null;
114
		}
115
		
116
		/**
117
	      * Method converting byte array into String.
118
	      *
119
	      * @param The byte array to be converted.
120
	      * @return A <code>String[]</code> containing String value of byte array.
121
	      */
122
	     public  String byteArrayToHexString(byte[] bytes){
123
	        
124
	         String result = "";
125
	          for (int i = 0; i < bytes.length; i++){
126
	            //the up 4 bits
127
	            int tmp = bytes[i] >>> 4;
128
	            result += HEXARRAY[tmp % 16];
129
	            //the lower 4 bits
130
	            tmp = bytes[i] & 0x0f;
131
	              result += HEXARRAY[tmp % 16];
132
	           }
133
	         
134
	           return result;
135
	     }
136
	    
137
	     /**
138
	      * Method converting String into byte[].
139
	      *
140
	      * @param The String to be converted.
141
	      * @return A <code>byte[]</code> containing byte[] value of string.
142
	      */ 
143
	    public  byte[] hexStringToByteArray(String hex){
144
	        
145
	         byte[] bytes = new byte[hex.length() / 2];
146
	         for (int i = 0; i < bytes.length; i++){
147
	              bytes[i] = (byte) Integer.parseInt(hex.substring(2*i, 2*i+2), 16);
148
	         }
149
	           
150
	       
151
	        return bytes;
152
	    }		
153
	}	
154
}
(-)plugin.xml (+19 lines)
Lines 32-37 Link Here
32
   <extension-point id="RecorderApplication" name="%RecorderApplication" schema="schema/RecorderAppAdapter.exsd"/>
32
   <extension-point id="RecorderApplication" name="%RecorderApplication" schema="schema/RecorderAppAdapter.exsd"/>
33
   <extension-point id="Recorder" name="%Recorder" schema="schema/Recorder.exsd"/>
33
   <extension-point id="Recorder" name="%Recorder" schema="schema/Recorder.exsd"/>
34
   <extension-point id="executionHarnessListener" name="%executionHarnessListener" schema="schema/executionHarnessListener.exsd"/>
34
   <extension-point id="executionHarnessListener" name="%executionHarnessListener" schema="schema/executionHarnessListener.exsd"/>
35
   <extension-point id="launchconfigDatapoolHandler" name="launchconfigDatapoolHandler" schema="schema/launchconfigDatapoolHandler.exsd"/>
36
   <extension-point id="launchDatapoolCheckPass" name="check passwords while launching" schema="schema/launchDatapoolCheckPass.exsd"/>
35
37
36
   <extension
38
   <extension
37
         id="org.eclipse.hyades.execution.harness.RegisteredExecutionComponentImpl.JAVA"
39
         id="org.eclipse.hyades.execution.harness.RegisteredExecutionComponentImpl.JAVA"
Lines 216-220 Link Here
216
       point="org.eclipse.hyades.execution.testService">
218
       point="org.eclipse.hyades.execution.testService">
217
    <testService class="org.eclipse.hyades.test.core.testservices.resources.FilesystemResourceProviderService"/>
219
    <testService class="org.eclipse.hyades.test.core.testservices.resources.FilesystemResourceProviderService"/>
218
 </extension>
220
 </extension>
221
 <extension
222
       point="org.eclipse.hyades.test.core.launchconfigDatapoolHandler">
223
    <launchconfigDatapoolHandler
224
          class="org.eclipse.hyades.test.core.internal.launch.datapool.extensions.JUnitLaunchconfigDatapoolHandler">
225
       <supportedTestType
226
             name="org.eclipse.hyades.test.java.junit.testSuite">
227
       </supportedTestType>
228
    </launchconfigDatapoolHandler>
229
 </extension>
230
 <extension
231
       id="DatapoolPasswordProvider"
232
       name="DatapoolPasswordProvider"
233
       point="org.eclipse.hyades.execution.testService">
234
    <testService
235
          class="org.eclipse.hyades.test.core.testservices.resources.DatapoolPasswordsService">
236
    </testService>
237
 </extension>
219
238
220
</plugin>
239
</plugin>
(-)src/org/eclipse/hyades/test/core/launch/delegates/AbstractLaunchConfigurationDelegate2.java (-1 / +27 lines)
Lines 12-17 Link Here
12
package org.eclipse.hyades.test.core.launch.delegates;
12
package org.eclipse.hyades.test.core.launch.delegates;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.Iterator;
16
import java.util.List;
17
import java.util.List;
17
18
Lines 27-39 Link Here
27
import org.eclipse.emf.ecore.resource.ResourceSet;
28
import org.eclipse.emf.ecore.resource.ResourceSet;
28
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
29
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
29
import org.eclipse.hyades.execution.core.IExecutor;
30
import org.eclipse.hyades.execution.core.IExecutor;
31
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
30
import org.eclipse.hyades.test.core.TestCorePlugin;
32
import org.eclipse.hyades.test.core.TestCorePlugin;
33
import org.eclipse.hyades.test.core.internal.launch.datapool.extensions.LaunchDatapoolExtensionManager;
31
import org.eclipse.hyades.test.core.internal.launch.extensions.LaunchConfigurationExtensionsManager;
34
import org.eclipse.hyades.test.core.internal.launch.extensions.LaunchConfigurationExtensionsManager;
32
import org.eclipse.hyades.test.core.internal.launch.processes.TestExecutionProcess;
35
import org.eclipse.hyades.test.core.internal.launch.processes.TestExecutionProcess;
33
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
36
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
37
import org.eclipse.hyades.test.core.launch.configurations.DeploymentLaunchConfigurationFacade;
38
import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade;
39
import org.eclipse.hyades.test.core.launch.extensions.ILaunchconfigDatapoolHandler;
40
import org.eclipse.hyades.test.core.launch.extensions.IPassInfoCollector;
34
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler;
41
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler;
35
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler2;
42
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler2;
36
import org.eclipse.hyades.test.core.launch.extensions.ITestLaunchConfigurationValidator;
43
import org.eclipse.hyades.test.core.launch.extensions.ITestLaunchConfigurationValidator;
44
import org.eclipse.hyades.test.core.testservices.resources.PasswordCollection;
37
import org.eclipse.osgi.util.NLS;
45
import org.eclipse.osgi.util.NLS;
38
46
39
/**
47
/**
Lines 185-194 Link Here
185
	    		}
193
	    		}
186
	    	}
194
	    	}
187
			
195
			
196
	    	// find the datapools which is encrypted   	
197
	    	ILaunchconfigDatapoolHandler datapoolHandler = LaunchDatapoolExtensionManager.getInstance().getRunHandler(getLaunchedElement(configuration));
198
			DPLDatapool[] dp = null;
199
			if(datapoolHandler != null){
200
				dp = datapoolHandler.getAllDatapools(TestLaunchConfigurationFacade.getTest(configuration, getResourceSet()), 
201
						DeploymentLaunchConfigurationFacade.getDeployment(configuration, getResourceSet()));				
202
			}
203
			HashMap pass = PasswordCollection.getInstance().getDatapoolPassword();
204
			
205
			// show a dialog to collect the passwords
206
			if(dp!=null && dp.length > 0){
207
				IPassInfoCollector collector = LaunchDatapoolExtensionManager.getInstance().getCollector(getLaunchedElement(configuration));
208
				List isContinue = new ArrayList();
209
				isContinue.add(TestLaunchConfigurationFacade.getTest(configuration, getResourceSet()).getImplementor().getId());
210
				collector.execute(dp, pass, isContinue);
211
				if(isContinue.size()==0)				
212
					return;
213
			}				
188
			// Invoke the Test Execution Harness
214
			// Invoke the Test Execution Harness
189
			StringBuffer errorMessages = new StringBuffer();
215
			StringBuffer errorMessages = new StringBuffer();
190
			IExecutor executor = null;
216
			IExecutor executor = null;
191
			try {
217
			try {				
192
				executor = invokeTestExecutionHarness(configuration, mode, errorMessages, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
218
				executor = invokeTestExecutionHarness(configuration, mode, errorMessages, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
193
				if (errorMessages.length() > 0) {
219
				if (errorMessages.length() > 0) {
194
					IStatus status = new Status(IStatus.ERROR, TestCorePlugin.getPluginId(), 0, TestCorePluginResourceBundle._EXC_AbstractLaunchConfigurationDelegate_testHarnessProblems + errorMessages, null); 
220
					IStatus status = new Status(IStatus.ERROR, TestCorePlugin.getPluginId(), 0, TestCorePluginResourceBundle._EXC_AbstractLaunchConfigurationDelegate_testHarnessProblems + errorMessages, null); 
(-)src/org/eclipse/hyades/test/core/internal/launch/processes/TestExecutionProcess.java (+3 lines)
Lines 44-49 Link Here
44
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
44
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
45
import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade;
45
import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade;
46
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler;
46
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler;
47
import org.eclipse.hyades.test.core.testservices.resources.PasswordCollection;
47
48
48
/**
49
/**
49
 * Fake process that represents a Hyades Execution Session. The lifecycle of
50
 * Fake process that represents a Hyades Execution Session. The lifecycle of
Lines 146-151 Link Here
146
147
147
	protected synchronized void onTerminate() {
148
	protected synchronized void onTerminate() {
148
		if (!terminated) {
149
		if (!terminated) {
150
			//remove the dps and passwords from passwordCollection
151
			PasswordCollection.getInstance().clear(test.getImplementor().getId());
149
			// Notify the run handler (if any)
152
			// Notify the run handler (if any)
150
			IRunHandler runHandler = LaunchConfigurationExtensionsManager.getInstance().getRunHandler(test);
153
			IRunHandler runHandler = LaunchConfigurationExtensionsManager.getInstance().getRunHandler(test);
151
			if (runHandler != null) {
154
			if (runHandler != null) {
(-)src/org/eclipse/hyades/test/core/internal/launch/datapool/extensions/LaunchDatapoolExtensionManager.java (+199 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: LaunchDatapoolExtensionManager.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.core.internal.launch.datapool.extensions;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IExtensionPoint;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.hyades.models.common.testprofile.TPFTest;
22
import org.eclipse.hyades.test.core.TestCorePlugin;
23
import org.eclipse.hyades.test.core.launch.extensions.ILaunchconfigDatapoolHandler;
24
import org.eclipse.hyades.test.core.launch.extensions.IPassInfoCollector;
25
26
/**
27
 * It's used to manage extensions for launchconfigDatapoolHandler and 
28
 * launchDatapoolCheckPass extension points ,based on the type of each test .
29
 * 
30
 * @author Huang Xin Ying 
31
 *
32
 */
33
public class LaunchDatapoolExtensionManager {
34
35
	private static LaunchDatapoolExtensionManager instance;
36
37
	public static LaunchDatapoolExtensionManager getInstance() {
38
		if (instance == null) {
39
			instance = new LaunchDatapoolExtensionManager();
40
		}
41
		return instance;
42
	}
43
44
	private LaunchDatapoolExtensionManager() {
45
		registerDatapoolHandlers();
46
		registerCheckPass();
47
	}
48
49
	private Map datapoolHandlerExtensionMap = new HashMap();
50
51
	public ILaunchconfigDatapoolHandler getRunHandler(Object testElement) {
52
		LaunchDatapoolExtensionDescriper ed = getLaunchDatapoolDescriptor(testElement);
53
		if (ed != null) {
54
			return ed.getRunHandler();
55
		}
56
		return null;
57
	}
58
	
59
	public IPassInfoCollector getCollector(Object testElement) {
60
		LaunchDatapoolExtensionDescriper ed = getLaunchDatapoolDescriptor(testElement);
61
		if (ed != null && ed.getCollector()!= null) 
62
			return ed.getCollector();
63
64
		return getExtensionDescriptor("default").getCollector();
65
	}
66
67
	private void registerDatapoolHandlers() {
68
		IExtensionPoint extPoint = Platform.getExtensionRegistry()
69
				.getExtensionPoint(
70
						TestCorePlugin.getPluginId()
71
								+ ".launchconfigDatapoolHandler");
72
		if (extPoint != null) {
73
			IConfigurationElement[] datapoolHandlers = extPoint
74
					.getConfigurationElements();
75
			for (int i = 0; i < datapoolHandlers.length; i++) {
76
				IConfigurationElement[] supportedTypes = datapoolHandlers[i]
77
						.getChildren();
78
				for (int j = 0; j < supportedTypes.length; j++) {
79
					String type = supportedTypes[j].getAttribute("name"); //$NON-NLS-1$					
80
					try {
81
						LaunchDatapoolExtensionDescriper ed = getExtensionDescriptor(type);
82
						ed.launchDatapoolConfigElem = datapoolHandlers[i];
83
					} catch (Exception e) {
84
						TestCorePlugin
85
								.getDefault()
86
								.logError(
87
										"Extension "
88
												+ datapoolHandlers[i].getName()
89
												+ " was ignored. See next messages for details.");
90
						TestCorePlugin.getDefault().logError(e);
91
					}
92
				}
93
			}
94
		}
95
	}
96
	
97
	private void registerCheckPass() {
98
		IExtensionPoint extPoint = Platform.getExtensionRegistry()
99
				.getExtensionPoint(
100
						TestCorePlugin.getPluginId()
101
								+ ".launchDatapoolCheckPass");
102
		if (extPoint != null) {
103
			IConfigurationElement[] datapoolHandlers = extPoint
104
					.getConfigurationElements();
105
			for (int i = 0; i < datapoolHandlers.length; i++) {
106
				IConfigurationElement[] supportedTypes = datapoolHandlers[i]
107
						.getChildren();
108
				for (int j = 0; j < supportedTypes.length; j++) {
109
					String type = supportedTypes[j].getAttribute("name"); //$NON-NLS-1$	
110
					if(type == null || type.equals(""))
111
						type = "default";
112
					try {
113
						LaunchDatapoolExtensionDescriper ed = getExtensionDescriptor(type);
114
						ed.CheckPassConfigElem = datapoolHandlers[i];
115
					} catch (Exception e) {
116
						TestCorePlugin
117
								.getDefault()
118
								.logError(
119
										"Extension "
120
												+ datapoolHandlers[i].getName()
121
												+ " was ignored. See next messages for details.");
122
						TestCorePlugin.getDefault().logError(e);
123
					}
124
				}
125
			}
126
		}
127
	}
128
129
	private LaunchDatapoolExtensionDescriper getExtensionDescriptor(String type) {
130
131
		if (type == null) {
132
			throw new NullPointerException("Type must be non-null"); //$NON-NLS-1$
133
		}
134
135
		Object o = datapoolHandlerExtensionMap.get(type);
136
		if (o == null) {
137
			o = new LaunchDatapoolExtensionDescriper();
138
			datapoolHandlerExtensionMap.put(type, o);
139
		}
140
		return (LaunchDatapoolExtensionDescriper) o;
141
	}
142
143
	private LaunchDatapoolExtensionDescriper getLaunchDatapoolDescriptor(
144
			Object testElement) {
145
		if (testElement != null) {
146
			if (testElement instanceof TPFTest) {
147
				TPFTest test = (TPFTest) testElement;
148
				if (test.getType() != null) {
149
					return getExtensionDescriptor(test.getType());
150
				}
151
			}
152
		}
153
		return null;
154
	}
155
156
	private class LaunchDatapoolExtensionDescriper {
157
		public IConfigurationElement launchDatapoolConfigElem = null;
158
		public IConfigurationElement CheckPassConfigElem = null;
159
		private ILaunchconfigDatapoolHandler hanler = null;
160
		private IPassInfoCollector collector = null;
161
		public String launchConfigurationType = null;
162
163
		public ILaunchconfigDatapoolHandler getRunHandler() {
164
			if (this.hanler == null) {
165
				if (this.launchDatapoolConfigElem != null) {
166
					try {
167
						this.hanler = (ILaunchconfigDatapoolHandler) this.launchDatapoolConfigElem
168
								.createExecutableExtension("class"); //$NON-NLS-1$
169
					} catch (CoreException e) {
170
						TestCorePlugin.getDefault().logError(e);
171
						this.launchDatapoolConfigElem = null;
172
					}
173
				}
174
			}
175
			return this.hanler;
176
		}
177
		
178
		public IPassInfoCollector getCollector() {
179
			if (this.collector == null) {
180
				if (this.CheckPassConfigElem != null) {
181
					try {
182
						this.collector = (IPassInfoCollector) this.CheckPassConfigElem
183
								.createExecutableExtension("UIClass"); //$NON-NLS-1$
184
					} catch (CoreException e) {
185
						TestCorePlugin.getDefault().logError(e);
186
						this.CheckPassConfigElem = null;
187
					}
188
				}
189
			}
190
			return this.collector;
191
		}
192
193
		public boolean isLaunchConfigurationTypeSupported(String lcType) {
194
			return (this.launchConfigurationType == lcType)
195
					|| (lcType != null && lcType
196
							.equals(this.launchConfigurationType));
197
		}
198
	}
199
}
(-)src/org/eclipse/hyades/test/core/launch/extensions/ILaunchconfigDatapoolHandler.java (+30 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: ILaunchconfigDatapoolHandler.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.test.core.launch.extensions;
14
15
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
16
import org.eclipse.hyades.models.common.testprofile.TPFDeployment;
17
import org.eclipse.hyades.models.common.testprofile.TPFTest;
18
19
/**
20
*  
21
* It's the interface for the  launchconfigDatapoolHandler extension point.
22
* 
23
* @author Huang Xin Ying 
24
*
25
*/
26
public interface ILaunchconfigDatapoolHandler {
27
	
28
	public	DPLDatapool[] getAllDatapools(TPFTest test, TPFDeployment deploy);
29
30
}
(-)src/org/eclipse/hyades/test/core/launch/extensions/IPassInfoCollector.java (+28 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: IPassInfoCollector.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.core.launch.extensions;
13
14
import java.util.List;
15
import java.util.Map;
16
17
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
18
19
/**
20
*  
21
* It's the interface for the launchDatapoolCheckPass extension point.
22
* @author Huang Xin Ying 
23
*
24
*/
25
public interface IPassInfoCollector {
26
	
27
	void execute(DPLDatapool[] dp, Map pass, List isContinue);
28
}
(-)src/org/eclipse/hyades/test/core/testservices/resources/PasswordCollection.java (+77 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: PasswordCollection.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.test.core.testservices.resources;
14
15
16
17
import java.util.HashMap;
18
import java.util.Iterator;
19
import java.util.Map;
20
21
/**
22
 * This class runs on the workbench, and used to save HashMap of
23
 *  datapool & password for this datapool during luaching  tests .
24
 *  
25
 * It's supposed to support mult-lauch on the workbench side . 
26
 *  
27
 * @author Xin Ying Huang
28
 *
29
 */
30
public class PasswordCollection {
31
	
32
	private static PasswordCollection instance = null;
33
	private HashMap datapoolPassword = new HashMap();
34
	
35
	
36
	private PasswordCollection(){}
37
	
38
	/**
39
	 * @param 
40
	 * @return PasswordCollection
41
	 */
42
	public static PasswordCollection getInstance(){
43
		if(instance == null){
44
			instance = new PasswordCollection();
45
		}
46
		return instance;
47
	}	
48
   
49
	/**
50
	 * @param 
51
	 * @return HashMap
52
	 */
53
	public HashMap getDatapoolPassword() {
54
		return datapoolPassword;
55
	}
56
	
57
	/**
58
	 * @param  testId
59
	 * @return HashMap
60
	 */
61
	public HashMap getDatapoolPassword(String testId){
62
		if(testId == null)
63
			return null;
64
		return (HashMap)datapoolPassword.get(testId);
65
	}
66
	
67
	/**
68
	 * @param  testId
69
	 * @return HashMap
70
	 */
71
	public void clear(String testId){
72
		if(testId == null)
73
			return;
74
		datapoolPassword.remove(testId);
75
		return;
76
	}
77
}
(-)schema/launchconfigDatapoolHandler.exsd (+135 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.hyades.test.core">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.hyades.test.core" id="launchconfigDatapoolHandler" name="launchconfigDatapoolHandler"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point provides a mechanism to get datapool model for each test type when launching a test case .
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="launchconfigDatapoolHandler"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
               <appInfo>
38
                  <meta.attribute translatable="true"/>
39
               </appInfo>
40
            </annotation>
41
         </attribute>
42
      </complexType>
43
   </element>
44
45
   <element name="launchconfigDatapoolHandler">
46
      <complexType>
47
         <sequence>
48
            <element ref="supportedTestType"/>
49
         </sequence>
50
         <attribute name="class" type="string" use="required">
51
            <annotation>
52
               <documentation>
53
                  
54
               </documentation>
55
            </annotation>
56
         </attribute>
57
      </complexType>
58
   </element>
59
60
   <element name="supportedTestType">
61
      <complexType>
62
         <attribute name="name" type="string" use="required">
63
            <annotation>
64
               <documentation>
65
                  
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appInfo>
74
         <meta.section type="since"/>
75
      </appInfo>
76
      <documentation>
77
         [4.5 ]
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="examples"/>
84
      </appInfo>
85
      <documentation>
86
         The following example associates a DatapoolHandler class with tests of type org.eclipse.hyades.test.:
87
88
&lt;pre&gt;
89
90
 &lt;extension
91
92
       point=&quot;org.eclipse.hyades.test.core.launchconfigDatapoolHandler&quot;&gt;
93
94
    &lt;launchconfigDatapoolHandler class=&quot; &quot;&gt;
95
96
       &lt;supportedType
97
98
             name =&quot;  &quot;/&gt;
99
100
    &lt;/runHandler&gt;
101
102
 &lt;/extension&gt;
103
104
&lt;/pre&gt;
105
      </documentation>
106
   </annotation>
107
108
   <annotation>
109
      <appInfo>
110
         <meta.section type="apiInfo"/>
111
      </appInfo>
112
      <documentation>
113
         [org.eclipse.hyades.test.core.launch.extensions.ILaunchconfigDatapoolHandler]
114
      </documentation>
115
   </annotation>
116
117
   <annotation>
118
      <appInfo>
119
         <meta.section type="implementation"/>
120
      </appInfo>
121
      <documentation>
122
         [Enter information about supplied implementation of this extension point.]
123
      </documentation>
124
   </annotation>
125
126
   <annotation>
127
      <appInfo>
128
         <meta.section type="copyright"/>
129
      </appInfo>
130
      <documentation>
131
         
132
      </documentation>
133
   </annotation>
134
135
</schema>
(-)schema/launchDatapoolCheckPass.exsd (+140 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.hyades.test.core">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.hyades.test.core" id="launchDatapoolCheckPass" name="check passwords while launching"/>
7
      </appInfo>
8
      <documentation>
9
         [Used to collect password for each enctypted datapool which used in current test on workbench side .]
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="launchDatapoolCheckPass"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
               <appInfo>
38
                  <meta.attribute translatable="true"/>
39
               </appInfo>
40
            </annotation>
41
         </attribute>
42
      </complexType>
43
   </element>
44
45
   <element name="launchDatapoolCheckPass">
46
      <complexType>
47
         <sequence>
48
            <element ref="supportedTestType"/>
49
         </sequence>
50
         <attribute name="UIClass" type="string" use="required">
51
            <annotation>
52
               <documentation>
53
                  
54
               </documentation>
55
            </annotation>
56
         </attribute>
57
      </complexType>
58
   </element>
59
60
   <element name="supportedTestType">
61
      <complexType>
62
         <attribute name="name" type="string" use="default" value="">
63
            <annotation>
64
               <documentation>
65
                  
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appInfo>
74
         <meta.section type="since"/>
75
      </appInfo>
76
      <documentation>
77
         [4.5.]
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="examples"/>
84
      </appInfo>
85
      <documentation>
86
         [  &lt;element name=&quot;extension&quot;&gt;
87
      &lt;complexType&gt;
88
         &lt;sequence&gt;
89
            &lt;element ref=&quot;launchDatapoolCheckPass&quot;/&gt;
90
         &lt;/sequence&gt;
91
         &lt;attribute name=&quot;point&quot; type=&quot;string&quot; use=&quot;required&quot;&gt;
92
            &lt;annotation&gt;
93
               &lt;documentation&gt;
94
                  
95
               &lt;/documentation&gt;
96
            &lt;/annotation&gt;
97
         &lt;/attribute&gt;
98
         &lt;attribute name=&quot;id&quot; type=&quot;string&quot;&gt;
99
            &lt;annotation&gt;
100
               &lt;documentation&gt;
101
                  
102
               &lt;/documentation&gt;
103
            &lt;/annotation&gt;
104
         &lt;/attribute&gt;
105
         &lt;attribute name=&quot;name&quot; type=&quot;string&quot;&gt;
106
            &lt;annotation&gt;
107
               &lt;documentation&gt;
108
                  
109
               &lt;/documentation&gt;
110
               &lt;appInfo&gt;
111
                  &lt;meta.attribute translatable=&quot;true&quot;/&gt;
112
               &lt;/appInfo&gt;
113
            &lt;/annotation&gt;
114
         &lt;/attribute&gt;
115
      &lt;/complexType&gt;
116
   &lt;/element&gt;
117
.]
118
      </documentation>
119
   </annotation>
120
121
   <annotation>
122
      <appInfo>
123
         <meta.section type="apiInfo"/>
124
      </appInfo>
125
      <documentation>
126
         [org.eclipse.hyades.test.core.launch.extensions.IPassInfoCollector .]
127
      </documentation>
128
   </annotation>
129
130
   <annotation>
131
      <appInfo>
132
         <meta.section type="implementation"/>
133
      </appInfo>
134
      <documentation>
135
         [Enter information about supplied implementation of this extension point.]
136
      </documentation>
137
   </annotation>
138
139
140
</schema>
(-)src/org/eclipse/hyades/test/core/internal/launch/datapool/extensions/JUnitLaunchconfigDatapoolHandler.java (+74 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: JUnitLaunchconfigDatapoolHandler.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.test.core.internal.launch.datapool.extensions;
14
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import java.util.List;
18
19
import org.eclipse.hyades.models.common.configuration.CFGArtifactLocationPair;
20
import org.eclipse.hyades.models.common.configuration.CFGClass;
21
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
22
import org.eclipse.hyades.models.common.testprofile.TPFDeployment;
23
import org.eclipse.hyades.models.common.testprofile.TPFTest;
24
import org.eclipse.hyades.test.core.launch.extensions.ILaunchconfigDatapoolHandler;
25
26
27
/**
28
 * This class runs on the workbench, and provides the workbench side 
29
 * implementation of the launchconfigDatapoolHandler extension point.
30
 * 
31
 * It's used to get datapool[] from test or delpoy for Junit test type .
32
 * 
33
 * @author Huang Xin Ying 
34
 *
35
 */
36
public class JUnitLaunchconfigDatapoolHandler implements
37
		ILaunchconfigDatapoolHandler {
38
	
39
	/**
40
	 * @param test,deploy
41
	 * @return DPLDatapool[]
42
	 */
43
	public DPLDatapool[] getAllDatapools(TPFTest test, TPFDeployment deploy) {
44
		if(deploy == null)
45
			return null;
46
		
47
		List keyList = new ArrayList();
48
		List pairs = deploy.getArtifactLocations();
49
		
50
		if(pairs == null)
51
			return null;
52
		for(Iterator iti = pairs.iterator();iti.hasNext();){
53
			CFGArtifactLocationPair aflp = (CFGArtifactLocationPair)iti.next();
54
			if(aflp == null)
55
				continue;
56
			if(aflp.getArtifact() == null)
57
				continue;
58
			List deploys = aflp.getArtifact().getDeployableInstances();
59
			if(deploys == null)
60
				continue;
61
			for(Iterator it=deploys.iterator();it.hasNext();){
62
				CFGClass cfg = (CFGClass)it.next();
63
				if(cfg instanceof DPLDatapool && ((DPLDatapool)cfg).getChallenge()!= null){					
64
					keyList.add(cfg);
65
				}
66
			}			
67
		}
68
		
69
		if(keyList.size() == 0)			
70
			return null;		
71
	
72
		return (DPLDatapool[])(keyList.toArray(new DPLDatapool[]{}));
73
	}
74
}
(-)src/org/eclipse/hyades/test/core/testservices/resources/DatapoolPasswordsService.java (+60 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: DatapoolPasswordsService.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.core.testservices.resources;
13
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.Map;
17
import java.util.regex.Matcher;
18
import java.util.regex.Pattern;
19
20
import org.eclipse.hyades.execution.local.testservices.AbstractTestService;
21
import org.eclipse.hyades.execution.local.testservices.ITestService;
22
import org.eclipse.hyades.internal.execution.local.control.Agent;
23
24
/**
25
*  
26
* It's the class of DatapoolPasswordsService ,used to provide list of datapool and it's encryption 
27
* password to the agent controller side .
28
* @author Huang Xin Ying 
29
*
30
*/
31
public class DatapoolPasswordsService extends AbstractTestService implements ITestService{
32
	
33
	/**
34
	 * @param agent
35
	 * @param methodArgs
36
	 * @param errBuf
37
	 * @return
38
	 */
39
	public String getDatapoolList(Agent agent, String methodArgs, StringBuffer errBuf){
40
		Pattern pattern = Pattern.compile("testId=(.*)"); //$NON-NLS-1$
41
		Matcher matcher = pattern.matcher(methodArgs);
42
		String testId = null;
43
		if (matcher.find()) {
44
			testId = matcher.group(1);
45
		}
46
		HashMap data = PasswordCollection.getInstance().getDatapoolPassword(testId);
47
		
48
		if(data == null || data.size() == 0)
49
			return null;
50
		
51
		StringBuffer result = new StringBuffer();
52
		
53
		for( Iterator it = data.entrySet().iterator();it.hasNext();){
54
			Map.Entry entry = (Map.Entry)it.next();
55
			result.append(entry.getKey() + "=" + entry.getValue() + ";");
56
		}
57
		
58
		return result.toString();
59
	}	
60
}
(-)src/org/eclipse/hyades/test/ui/internal/editor/extension/DatapoolEditorExtension.java (-3 / +20 lines)
Lines 32-37 Link Here
32
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
32
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
33
import org.eclipse.hyades.ui.editor.IEditActionsExtension;
33
import org.eclipse.hyades.ui.editor.IEditActionsExtension;
34
import org.eclipse.hyades.ui.editor.IHyadesEditorPart;
34
import org.eclipse.hyades.ui.editor.IHyadesEditorPart;
35
import org.eclipse.jface.dialogs.MessageDialog;
35
import org.eclipse.jface.text.IFindReplaceTarget;
36
import org.eclipse.jface.text.IFindReplaceTarget;
36
import org.eclipse.jface.text.IFindReplaceTargetExtension3;
37
import org.eclipse.jface.text.IFindReplaceTargetExtension3;
37
import org.eclipse.jface.viewers.ISelection;
38
import org.eclipse.jface.viewers.ISelection;
Lines 39-44 Link Here
39
import org.eclipse.jface.viewers.StructuredSelection;
40
import org.eclipse.jface.viewers.StructuredSelection;
40
import org.eclipse.swt.custom.TableCursor;
41
import org.eclipse.swt.custom.TableCursor;
41
import org.eclipse.swt.graphics.Point;
42
import org.eclipse.swt.graphics.Point;
43
import org.eclipse.swt.widgets.Shell;
42
import org.eclipse.swt.widgets.Table;
44
import org.eclipse.swt.widgets.Table;
43
import org.eclipse.swt.widgets.TableItem;
45
import org.eclipse.swt.widgets.TableItem;
44
import org.eclipse.tptp.platform.common.ui.internal.util.UIUtil;
46
import org.eclipse.tptp.platform.common.ui.internal.util.UIUtil;
Lines 397-404 Link Here
397
    /* (non-Javadoc)
399
    /* (non-Javadoc)
398
     * @see org.eclipse.hyades.ui.editor.IEditorExtension#createPages()
400
     * @see org.eclipse.hyades.ui.editor.IEditorExtension#createPages()
399
     */
401
     */
402
    private void showErrMes(Shell shell, String mes) {
403
		MessageDialog.openError(shell, UiPluginResourceBundle.DatapoolDialog_ERRORDIALOGTITLE, mes);
404
	}
400
    public void createPages() {
405
    public void createPages() {
401
        IHyadesEditorPart hyadesEditorPart = getHyadesEditorPart();
406
    	IHyadesEditorPart hyadesEditorPart = getHyadesEditorPart();
402
        WidgetFactory widgetFactory = new WidgetFactory();
407
        WidgetFactory widgetFactory = new WidgetFactory();
403
408
404
        datapoolForm = new DatapoolForm(this, widgetFactory);
409
        datapoolForm = new DatapoolForm(this, widgetFactory);
Lines 406-412 Link Here
406
        hyadesEditorPart.setPageText(PAGE_OVERVIEW, UiPluginResourceBundle.W_OVERVIEW); 
411
        hyadesEditorPart.setPageText(PAGE_OVERVIEW, UiPluginResourceBundle.W_OVERVIEW); 
407
        datapoolForm.updateTitle();
412
        datapoolForm.updateTitle();
408
413
409
        IDatapool dp = getDatapool();
414
        IDatapool dp = getDatapool(); 
410
        for (int i = 0; i < dp.getEquivalenceClassCount(); i++) {
415
        for (int i = 0; i < dp.getEquivalenceClassCount(); i++) {
411
            addEquivalenceClassPage(i);
416
            addEquivalenceClassPage(i);
412
        }
417
        }
Lines 631-635 Link Here
631
    public void connectPart(IWorkbenchPart part) {
636
    public void connectPart(IWorkbenchPart part) {
632
        DatapoolActionHandlerListener.INSTANCE.connectPart(part);
637
        DatapoolActionHandlerListener.INSTANCE.connectPart(part);
633
    }
638
    }
634
639
    /**
640
     * used for DatapoolEditorPart to save
641
     * deal with the encrypted datapool
642
     * */
643
    public void save(){
644
    	if(super.getProgressMonitor() != null){
645
    		try{
646
    			super.save(super.getProgressMonitor());
647
    		}catch(Exception e){
648
    			e.printStackTrace();
649
    		}
650
		}
651
    }
635
}
652
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/dialog/DatapoolColumnDialog.java (-4 / +176 lines)
Lines 14-31 Link Here
14
14
15
import org.eclipse.hyades.edit.datapool.IDatapool;
15
import org.eclipse.hyades.edit.datapool.IDatapool;
16
import org.eclipse.hyades.edit.datapool.IDatapoolVariable;
16
import org.eclipse.hyades.edit.datapool.IDatapoolVariable;
17
import org.eclipse.hyades.models.common.datapool.DPLVariable;
18
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
19
import org.eclipse.hyades.models.common.util.EncryptionManager;
17
import org.eclipse.hyades.test.ui.datapool.internal.util.DatapoolUtil;
20
import org.eclipse.hyades.test.ui.datapool.internal.util.DatapoolUtil;
18
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
21
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
19
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
22
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
23
import org.eclipse.jface.dialogs.IDialogConstants;
24
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.osgi.util.NLS;
25
import org.eclipse.osgi.util.NLS;
21
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.events.KeyEvent;
27
import org.eclipse.swt.events.KeyEvent;
23
import org.eclipse.swt.events.KeyListener;
28
import org.eclipse.swt.events.KeyListener;
29
import org.eclipse.swt.events.MouseEvent;
30
import org.eclipse.swt.events.MouseListener;
24
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionEvent;
25
import org.eclipse.swt.events.SelectionListener;
32
import org.eclipse.swt.events.SelectionListener;
26
import org.eclipse.swt.graphics.Color;
33
import org.eclipse.swt.graphics.Color;
27
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.layout.GridLayout;
36
import org.eclipse.swt.widgets.Button;
29
import org.eclipse.swt.widgets.Combo;
37
import org.eclipse.swt.widgets.Combo;
30
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Control;
39
import org.eclipse.swt.widgets.Control;
Lines 43-49 Link Here
43
 * @author psun
51
 * @author psun
44
 *
52
 *
45
 */
53
 */
46
public class DatapoolColumnDialog extends DatapoolBaseDialog implements KeyListener, SelectionListener{
54
public class DatapoolColumnDialog extends DatapoolBaseDialog implements KeyListener, SelectionListener,MouseListener{
47
55
48
	private static final String TAG_VARIABLES = "variables"; //$NON-NLS-1$
56
	private static final String TAG_VARIABLES = "variables"; //$NON-NLS-1$
49
	
57
	
Lines 66-71 Link Here
66
	private String insertionVariableName = null;
74
	private String insertionVariableName = null;
67
	private int defaultNameCounter = 1;
75
	private int defaultNameCounter = 1;
68
	
76
	
77
	private Button okButton;
78
	private Button checkBox;
79
	private Button changeKeyButton;
80
	private boolean isEncrypted;
81
	private boolean isKeyChanged;
82
	private String newKey;
83
	//private String key;
84
	
85
	public boolean isKeyChanged() {
86
		return isKeyChanged;
87
	}
69
	public DatapoolColumnDialog(Shell parentShell, 
88
	public DatapoolColumnDialog(Shell parentShell, 
70
									     IDatapool datapool,
89
									     IDatapool datapool,
71
									     IDatapoolVariable selectedVariable,
90
									     IDatapoolVariable selectedVariable,
Lines 78-83 Link Here
78
		this.title = title; 
97
		this.title = title; 
79
		this.selectedVariable = selectedVariable;
98
		this.selectedVariable = selectedVariable;
80
		this.previousVariable = previousVariable;
99
		this.previousVariable = previousVariable;
100
		boolean isKeyChanged = false;		
81
	}
101
	}
82
102
83
	/**
103
	/**
Lines 122-127 Link Here
122
		typeField.setLayoutData(gridData);
142
		typeField.setLayoutData(gridData);
123
		typeField.addKeyListener(this);
143
		typeField.addKeyListener(this);
124
		typeFieldForeground = typeField.getForeground();
144
		typeFieldForeground = typeField.getForeground();
145
		checkBox = new Button(superComposite,SWT.CHECK);
146
		checkBox.setText(UiPluginResourceBundle.DatapoolDialog_ENCRYPTED);
147
		checkBox.addMouseListener(this);
148
		changeKeyButton = new Button(superComposite,SWT.NONE);
149
		changeKeyButton.setText(UiPluginResourceBundle.DatapoolDialog_CHANGEKEY);
150
		changeKeyButton.addMouseListener(this);
125
	
151
	
126
		IDatapoolVariable[] variables = DatapoolUtil.getInstance().getVariables(datapool, null);
152
		IDatapoolVariable[] variables = DatapoolUtil.getInstance().getVariables(datapool, null);
127
		if(selectedVariable != null)
153
		if(selectedVariable != null)
Lines 156-162 Link Here
156
		else {
182
		else {
157
			insertionLabel.setText(UiPluginResourceBundle.DATA_DLG_MOVE); 
183
			insertionLabel.setText(UiPluginResourceBundle.DATA_DLG_MOVE); 
158
        }
184
        }
159
185
		if(isVaribelEncrypted(selectedVariable))
186
		{
187
			if(DatapoolEncryptManager.isDatapoolEncrypted(datapool))
188
				changeKeyButton.setEnabled(true);
189
			checkBox.setSelection(true);
190
			isEncrypted =true;
191
		}
192
		else
193
		{
194
			changeKeyButton.setEnabled(false);
195
			checkBox.setSelection(false);
196
			isEncrypted = false;
197
		}
160
		insertionVariables = new Combo(superComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
198
		insertionVariables = new Combo(superComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
161
		insertionVariables.setItems(variableLabels);
199
		insertionVariables.setItems(variableLabels);
162
		insertionVariables.setData(TAG_VARIABLES, variables);
200
		insertionVariables.setData(TAG_VARIABLES, variables);
Lines 165-171 Link Here
165
		
203
		
166
		if(variables.length > 0 && previousVariable != null)
204
		if(variables.length > 0 && previousVariable != null)
167
		{
205
		{
168
			int selectIndex = findVariableIndexInCombo(variables, previousVariable) - 1;
206
			int selectIndex = findVariableIndexInCombo(variables, previousVariable);
169
            if (selectIndex < 0) {
207
            if (selectIndex < 0) {
170
                insertionVariables.select(0);
208
                insertionVariables.select(0);
171
                insertionVariableName = new String();
209
                insertionVariableName = new String();
Lines 184-190 Link Here
184
		}
222
		}
185
        if (title.equals(UiPluginResourceBundle.DATA_COL_DLG_TITLE_EDIT) && variables.length == 1) { 
223
        if (title.equals(UiPluginResourceBundle.DATA_COL_DLG_TITLE_EDIT) && variables.length == 1) { 
186
            //- Move field hidden 
224
            //- Move field hidden 
187
            insertionVariables.setVisible(false);
225
             insertionVariables.setVisible(false);
188
            insertionLabel.setVisible(false);
226
            insertionLabel.setVisible(false);
189
        }
227
        }
190
		nameErrorLabel = new Label(superComposite, SWT.NONE);
228
		nameErrorLabel = new Label(superComposite, SWT.NONE);
Lines 384-387 Link Here
384
		defaultNameCounter++;
422
		defaultNameCounter++;
385
		return NLS.bind(UiPluginResourceBundle.DATA_VARIABLE_NAME, NumberFormat.getInstance().format(defaultNameCounter)); 
423
		return NLS.bind(UiPluginResourceBundle.DATA_VARIABLE_NAME, NumberFormat.getInstance().format(defaultNameCounter)); 
386
	}	
424
	}	
425
	public void mouseDoubleClick(MouseEvent e) {
426
		// TODO Auto-generated method stub
427
		
428
	}
429
430
	public void mouseDown(MouseEvent e) {
431
		// TODO Auto-generated method stub
432
		
433
	}
434
435
	public void mouseUp(MouseEvent e) {
436
		// TODO Auto-generated method stub
437
		Button clickButton = (Button)e.getSource();
438
		if(clickButton == null)
439
		{
440
			return;
441
		}
442
		String title = clickButton.getText();
443
		if(title != null)
444
		{
445
			if(title.equals(UiPluginResourceBundle.DatapoolDialog_ENCRYPTED))
446
			{
447
				dealClickCheckBox(clickButton);
448
			}
449
			else if(title.equals(UiPluginResourceBundle.DatapoolDialog_CHANGEKEY))
450
			{
451
				dealClickChangeKey(clickButton);
452
			}
453
		}
454
		
455
		
456
		
457
	}
458
	private void dealClickCheckBox(Button checkBoxButton)
459
	{
460
		//if(key == null || key.equals(""))
461
		//{
462
		//	isEncrypted = checkBox.getSelection();
463
		//	changeKeyButton.setEnabled(false);
464
		//	return ;
465
		//}
466
		checkBox = checkBoxButton;
467
		isEncrypted = checkBox.getSelection();
468
		if(changeKeyButton != null)
469
		{
470
			if(DatapoolEncryptManager.isDatapoolEncrypted(datapool))
471
				changeKeyButton.setEnabled(isChangeKeyButtonEnable());
472
		}
473
	}
474
	public boolean isEncrypted()
475
	{
476
		return isEncrypted;
477
	}
478
	private void dealClickChangeKey(Button changeKeyButton)
479
	{
480
481
		boolean errorKey = true;
482
		Shell shell = Display.getCurrent().getActiveShell();
483
		DatapoolChangeKeyDialog changeKeyDialog = new DatapoolChangeKeyDialog(shell, datapool, UiPluginResourceBundle.DatapoolDialog_CHANGEKEYDIALOGTITLE);
484
		String key = null;
485
		int retVal = 0;
486
			while(errorKey)
487
			{
488
			if (changeKeyDialog.open() == IDialogConstants.OK_ID) {
489
				
490
				key = changeKeyDialog.getOldKey();
491
				retVal = changeKeyDialog.isKeyChangeSuccess(datapool);
492
				switch(retVal)
493
				{
494
				case DatapoolConstant.ORIGINTKEYERROR:
495
					showErrMes(shell,UiPluginResourceBundle.DatapoolDialog_ORIGINKEYERRORMES);
496
					break;
497
				case DatapoolConstant.NEWKEYNULL:
498
					showErrMes(shell,UiPluginResourceBundle.DatapoolDialog_NEWKEYNULLMES);
499
					break;
500
				case DatapoolConstant.NEWKEYNOTCONFIRM:
501
					showErrMes(shell,UiPluginResourceBundle.DatapoolDialog_NEWKEYNOTCONFIRMMES);
502
					break;
503
				case DatapoolConstant.CHANGEKEYSUCCESS:
504
					newKey = changeKeyDialog.getNewKey();
505
					DatapoolEncryptManager.changeKeyOfEncryCell(datapool, key, newKey);
506
					key = newKey;
507
					try{
508
					DatapoolEncryptManager.ChangeKey(EncryptionManager.EncoderByMd5(key),
509
							datapool);
510
					}catch(Exception e){						
511
					}
512
					errorKey = false;
513
					isKeyChanged = true;
514
					break;
515
				default://error
516
						errorKey = false;
517
				        isKeyChanged = false;
518
				}
519
			}
520
			else
521
			{
522
				errorKey = false;
523
				isKeyChanged = false;
524
			}
525
526
		}
527
		
528
	}
529
	private void showErrMes(Shell shell,String mes)
530
	{
531
		MessageDialog.openError(shell,UiPluginResourceBundle.DatapoolDialog_ERRORDIALOGTITLE ,mes);
532
	}
533
    private boolean isChangeKeyButtonEnable()
534
    {
535
    	boolean retValue = true;
536
    	if(checkBox != null)
537
    	{
538
    		if(!checkBox.getSelection())
539
    		{
540
    			retValue = false;
541
    		}
542
    			
543
    	}
544
   
545
    	return retValue;	
546
    	
547
    }
548
549
    private boolean isVaribelEncrypted(IDatapoolVariable varible)
550
    {
551
    	return (varible instanceof DPLVariable)?((DPLVariable)varible).isEncrypted():false;
552
    }
553
554
	public String getNewKey() {
555
		return newKey;
556
	}
557
    
558
  
387
}
559
}
(-)src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolImportWizard.java (+23 lines)
Lines 17-22 Link Here
17
import org.eclipse.emf.ecore.EObject;
17
import org.eclipse.emf.ecore.EObject;
18
import org.eclipse.emf.ecore.resource.Resource;
18
import org.eclipse.emf.ecore.resource.Resource;
19
import org.eclipse.hyades.edit.datapool.IDatapool;
19
import org.eclipse.hyades.edit.datapool.IDatapool;
20
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
20
import org.eclipse.hyades.test.core.util.EMFUtil;
21
import org.eclipse.hyades.test.core.util.EMFUtil;
21
import org.eclipse.hyades.test.ui.TestUIImages;
22
import org.eclipse.hyades.test.ui.TestUIImages;
22
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
23
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
Lines 100-105 Link Here
100
				datapool.removeEquivalenceClass(0);
101
				datapool.removeEquivalenceClass(0);
101
			}
102
			}
102
			
103
			
104
			//TODO:first deencrpted all
105
			String key = datapoolImportPageSelection.getTextArea().getText();
106
			
107
			if(datapoolImportPageSelection.isEncrypted()){
108
				if(!DatapoolEncryptManager.isKeyCorrect(datapool, key)){
109
					datapoolImportPageSelection.setMessage(UiPluginResourceBundle.DatapoolExportWizard_wrongpass,3);
110
					datapoolImportPageSelection.getTextArea().setText("");
111
					datapoolImportPageSelection.getTextArea().setFocus();
112
					return false;
113
				}
114
			}
115
			
116
			if( DatapoolEncryptManager.isDatapoolEncrypted(datapool))
117
			{
118
				DatapoolEncryptManager.deencrypDatapool(datapool, key);
119
			}
103
			if(datapool.getVariableCount() == 0)
120
			if(datapool.getVariableCount() == 0)
104
			{
121
			{
105
				CSVImportExportUtil.getInstance().importCSV(datapool, 
122
				CSVImportExportUtil.getInstance().importCSV(datapool, 
Lines 116-121 Link Here
116
																datapoolImportPage.firstColumnContainsEquivalenceClassName(),
133
																datapoolImportPage.firstColumnContainsEquivalenceClassName(),
117
																datapoolImportPage.getImportEncoding());
134
																datapoolImportPage.getImportEncoding());
118
			}
135
			}
136
			//TODO:deal with the encrypted datapool			
137
						
138
			if( DatapoolEncryptManager.isDatapoolEncrypted(datapool))
139
			{
140
				DatapoolEncryptManager.encrypDatapool(datapool, key);
141
			}
119
			Resource dp = ((EObject)datapool).eResource();
142
			Resource dp = ((EObject)datapool).eResource();
120
			EMFUtil.save(dp);
143
			EMFUtil.save(dp);
121
			dp.unload();
144
			dp.unload();
(-)src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolExportWizard.java (+26 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.Path;
19
import org.eclipse.core.runtime.Path;
20
import org.eclipse.hyades.edit.datapool.IDatapool;
20
import org.eclipse.hyades.edit.datapool.IDatapool;
21
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
21
import org.eclipse.hyades.test.ui.TestUIImages;
22
import org.eclipse.hyades.test.ui.TestUIImages;
22
import org.eclipse.hyades.test.ui.UiPlugin;
23
import org.eclipse.hyades.test.ui.UiPlugin;
23
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
24
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
Lines 28-33 Link Here
28
import org.eclipse.jface.wizard.Wizard;
29
import org.eclipse.jface.wizard.Wizard;
29
import org.eclipse.osgi.util.NLS;
30
import org.eclipse.osgi.util.NLS;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.ui.IExportWizard;
33
import org.eclipse.ui.IExportWizard;
32
import org.eclipse.ui.IWorkbench;
34
import org.eclipse.ui.IWorkbench;
33
35
Lines 86-94 Link Here
86
	/* (non-Javadoc)
88
	/* (non-Javadoc)
87
	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
89
	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
88
	 */
90
	 */
91
	private void showErrMes(Shell shell, String mes) {
92
		MessageDialog.openError(shell, UiPluginResourceBundle.DatapoolDialog_ERRORDIALOGTITLE, mes);
93
	}
89
	public boolean performFinish() 
94
	public boolean performFinish() 
90
	{
95
	{
91
		IDatapool datapool = datapoolSelectionPage.getDatapool();
96
		IDatapool datapool = datapoolSelectionPage.getDatapool();
97
		String key = datapoolSelectionPage.getTextArea().getText();
98
		
99
		if(datapoolSelectionPage.isEncrypted()){
100
			if(!DatapoolEncryptManager.isKeyCorrect(datapool, key)){
101
				datapoolSelectionPage.setMessage(UiPluginResourceBundle.DatapoolExportWizard_wrongpass,3);
102
				datapoolSelectionPage.getTextArea().setText("");
103
				datapoolSelectionPage.getTextArea().setFocus();
104
				return false;
105
			}
106
		}
107
		//TODO:deal with the encrypted datapool
108
		if( DatapoolEncryptManager.isDatapoolEncrypted(datapool))
109
		{
110
			DatapoolEncryptManager.deencrypDatapool(datapool, key);
111
		}
92
		String csvFileName = csvFileLocationPage.getCSVFileName();
112
		String csvFileName = csvFileLocationPage.getCSVFileName();
93
		if(!csvFileName.endsWith(".csv") && !csvFileName.endsWith(".CSV"))
113
		if(!csvFileName.endsWith(".csv") && !csvFileName.endsWith(".CSV"))
94
			csvFileName = csvFileName + ".csv";
114
			csvFileName = csvFileName + ".csv";
Lines 125-130 Link Here
125
                UiPlugin.logError(e);
145
                UiPlugin.logError(e);
126
            }
146
            }
127
        }
147
        }
148
        
149
        //Encrypted back
150
        if( DatapoolEncryptManager.isDatapoolEncrypted(datapool))
151
		{
152
			DatapoolEncryptManager.encrypDatapool(datapool, key);
153
		}
128
        return close;
154
        return close;
129
	}
155
	}
130
}
156
}
(-)src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolExportSelectionPage.java (-2 / +57 lines)
Lines 14-19 Link Here
14
import org.eclipse.core.resources.IResource;
14
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.hyades.edit.datapool.IDatapool;
16
import org.eclipse.hyades.edit.datapool.IDatapool;
17
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
17
import org.eclipse.hyades.models.common.util.ICommonConstants;
18
import org.eclipse.hyades.models.common.util.ICommonConstants;
18
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
19
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
19
import org.eclipse.hyades.test.ui.dialog.EObjectResourceContentProvider;
20
import org.eclipse.hyades.test.ui.dialog.EObjectResourceContentProvider;
Lines 27-39 Link Here
27
import org.eclipse.jface.viewers.ViewerSorter;
28
import org.eclipse.jface.viewers.ViewerSorter;
28
import org.eclipse.jface.wizard.WizardPage;
29
import org.eclipse.jface.wizard.WizardPage;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.events.ModifyEvent;
32
import org.eclipse.swt.events.ModifyListener;
30
import org.eclipse.swt.events.SelectionEvent;
33
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionListener;
34
import org.eclipse.swt.events.SelectionListener;
32
import org.eclipse.swt.graphics.Image;
35
import org.eclipse.swt.graphics.Image;
36
import org.eclipse.swt.layout.FormAttachment;
37
import org.eclipse.swt.layout.FormData;
38
import org.eclipse.swt.layout.FormLayout;
33
import org.eclipse.swt.layout.GridData;
39
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridLayout;
40
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.widgets.Button;
41
import org.eclipse.swt.widgets.Button;
36
import org.eclipse.swt.widgets.Composite;
42
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Group;
44
import org.eclipse.swt.widgets.Text;
37
import org.eclipse.swt.widgets.Tree;
45
import org.eclipse.swt.widgets.Tree;
38
46
39
/**
47
/**
Lines 50-55 Link Here
50
	private EObjectResourceContentProvider contentProvider;
58
	private EObjectResourceContentProvider contentProvider;
51
	private String[] fileExtensions;
59
	private String[] fileExtensions;
52
	private Image fileImage;
60
	private Image fileImage;
61
	private Group group;
62
	private Text textArea;	
63
	private FormData formData;	
64
	private boolean isEncrypted = false;
53
	
65
	
54
	/**
66
	/**
55
	 * @param pageName
67
	 * @param pageName
Lines 148-155 Link Here
148
		};
160
		};
149
		assetViewer.setSorter(sorter);
161
		assetViewer.setSorter(sorter);
150
	
162
	
163
		group = new Group(parent,SWT.NULL);			
164
		group.setText(UiPluginResourceBundle.DatapoolExportWizard_password);
165
		group.setLayoutData(GridDataUtil.createHorizontalFill());
166
		group.setLayout(new FormLayout());
167
		group.setVisible(false);
168
		textArea = new Text(group, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.PASSWORD);		
169
		formData = new FormData();
170
		formData.left = new FormAttachment(0,5);
171
		formData.top = new FormAttachment(0,5);		
172
		formData.bottom = new FormAttachment(80,-5);
173
		formData.width = 200;
174
		textArea.setLayoutData(formData);		
175
		textArea.addModifyListener(new ModifyListener(){
176
			public void modifyText(ModifyEvent e){
177
				if(textArea.getText().length()>0){										
178
					setPageComplete(true);
179
				}
180
			}
181
		});
151
		return assetViewer;
182
		return assetViewer;
152
	}
183
	}
184
	
185
	public Text getTextArea(){
186
		return textArea;
187
	}
188
	
189
	public boolean isEncrypted(){
190
		return isEncrypted;
191
	}
153
192
154
	private void setSelection()
193
	private void setSelection()
155
	{
194
	{
Lines 162-169 Link Here
162
				datapool = (IDatapool)selectedObject;
201
				datapool = (IDatapool)selectedObject;
163
				if(datapool != null)
202
				if(datapool != null)
164
				{
203
				{
165
					setPageComplete(true);
204
					if(DatapoolEncryptManager.isDatapoolEncrypted(datapool)){
166
					getContainer().updateButtons();
205
						isEncrypted = true;
206
						setMessage(datapool.getName() + " " + UiPluginResourceBundle.DatapoolExportWizard_encrypted,WARNING);
207
						group.setVisible(true);
208
						group.setText(UiPluginResourceBundle.DatapoolExportWizard_password + " " + datapool.getName() + ".datapool");
209
						textArea.setFocus();						
210
						
211
						setPageComplete(false);
212
						//getContainer().updateButtons();
213
					}else{		
214
						isEncrypted = false;
215
						setMessage(datapool.getName() + " " + UiPluginResourceBundle.DatapoolExportWizard_unencrypted);
216
						group.setVisible(false);						
217
						textArea.setText("");						
218
						
219
						setPageComplete(true);
220
						getContainer().updateButtons();
221
					}
167
				}
222
				}
168
			}
223
			}
169
		}
224
		}
(-)src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolImportPageSelection.java (-1 / +65 lines)
Lines 25-30 Link Here
25
import org.eclipse.emf.ecore.resource.Resource;
25
import org.eclipse.emf.ecore.resource.Resource;
26
import org.eclipse.hyades.edit.datapool.IDatapool;
26
import org.eclipse.hyades.edit.datapool.IDatapool;
27
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
27
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
28
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
28
import org.eclipse.hyades.models.common.util.DatapoolUtil;
29
import org.eclipse.hyades.models.common.util.DatapoolUtil;
29
import org.eclipse.hyades.models.common.util.ICommonConstants;
30
import org.eclipse.hyades.models.common.util.ICommonConstants;
30
import org.eclipse.hyades.test.ui.UiPlugin;
31
import org.eclipse.hyades.test.ui.UiPlugin;
Lines 39-52 Link Here
39
import org.eclipse.osgi.util.NLS;
40
import org.eclipse.osgi.util.NLS;
40
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.custom.StackLayout;
42
import org.eclipse.swt.custom.StackLayout;
43
import org.eclipse.swt.events.ModifyEvent;
44
import org.eclipse.swt.events.ModifyListener;
42
import org.eclipse.swt.events.SelectionEvent;
45
import org.eclipse.swt.events.SelectionEvent;
43
import org.eclipse.swt.events.SelectionListener;
46
import org.eclipse.swt.events.SelectionListener;
47
import org.eclipse.swt.layout.FormAttachment;
48
import org.eclipse.swt.layout.FormData;
49
import org.eclipse.swt.layout.FormLayout;
44
import org.eclipse.swt.layout.GridData;
50
import org.eclipse.swt.layout.GridData;
45
import org.eclipse.swt.layout.GridLayout;
51
import org.eclipse.swt.layout.GridLayout;
46
import org.eclipse.swt.widgets.Button;
52
import org.eclipse.swt.widgets.Button;
47
import org.eclipse.swt.widgets.Composite;
53
import org.eclipse.swt.widgets.Composite;
48
import org.eclipse.swt.widgets.Event;
54
import org.eclipse.swt.widgets.Event;
55
import org.eclipse.swt.widgets.Group;
49
import org.eclipse.swt.widgets.Listener;
56
import org.eclipse.swt.widgets.Listener;
57
import org.eclipse.swt.widgets.Text;
50
import org.eclipse.tptp.platform.common.internal.util.EMFUtil;
58
import org.eclipse.tptp.platform.common.internal.util.EMFUtil;
51
import org.eclipse.tptp.platform.common.ui.internal.CommonUIMessages;
59
import org.eclipse.tptp.platform.common.ui.internal.CommonUIMessages;
52
import org.eclipse.tptp.platform.common.ui.internal.CommonUIPlugin;
60
import org.eclipse.tptp.platform.common.ui.internal.CommonUIPlugin;
Lines 68-73 Link Here
68
	private final static String nameExistingDatapool = "Select Existing Datapool";
76
	private final static String nameExistingDatapool = "Select Existing Datapool";
69
77
70
	private static final int SIZING_CONTAINER_GROUP_HEIGHT = 250;
78
	private static final int SIZING_CONTAINER_GROUP_HEIGHT = 250;
79
	private Group group;
80
	private Text textArea;	
81
	private boolean valid = false;
82
	private FormData formData;	
83
	private boolean isEncrypted = false;
71
	
84
	
72
	/**
85
	/**
73
	 * Constructor.
86
	 * Constructor.
Lines 145-152 Link Here
145
			{
158
			{
146
				super.setSelection();
159
				super.setSelection();
147
				validateSelection();
160
				validateSelection();
161
				IDatapool datapool = getSelectedDatapool()[0];
162
				if(datapool != null)
163
				{							
164
					if(DatapoolEncryptManager.isDatapoolEncrypted(datapool)){
165
						isEncrypted = true;
166
						setMessage(datapool.getName() + " " + UiPluginResourceBundle.DatapoolExportWizard_encrypted,WARNING);
167
						group.setVisible(true);
168
						group.setText(UiPluginResourceBundle.DatapoolExportWizard_password + " " + datapool.getName() + ".datapool");
169
						textArea.setFocus();						
170
						
171
						setPageComplete(false);
172
						//getContainer().updateButtons();
173
					}else{		
174
						isEncrypted = false;
175
						setMessage(datapool.getName() + " " + UiPluginResourceBundle.DatapoolExportWizard_unencrypted);
176
						group.setVisible(false);						
177
						textArea.setText("");						
178
						
179
						//setPageComplete(true);
180
						getContainer().updateButtons();
181
					}
182
				}
183
148
			}
184
			}
149
		};
185
		};
186
		group = new Group(topLevel,SWT.NULL);			
187
		group.setText(UiPluginResourceBundle.DatapoolExportWizard_password);
188
		group.setLayoutData(GridDataUtil.createHorizontalFill());
189
		group.setLayout(new FormLayout());
190
		group.setVisible(false);
191
		textArea = new Text(group, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.PASSWORD);		
192
		formData = new FormData();
193
		formData.left = new FormAttachment(0,5);
194
		formData.top = new FormAttachment(0,5);		
195
		formData.bottom = new FormAttachment(80,-5);
196
		formData.width = 200;
197
		textArea.setLayoutData(formData);		
198
		
199
		
200
		textArea.addModifyListener(new ModifyListener(){
201
			public void modifyText(ModifyEvent e){
202
				if(textArea.getText().length()>0){					
203
					setPageComplete(valid);
204
				}
205
			}
206
		});
150
		setControl(topLevel);
207
		setControl(topLevel);
151
		validateSelection();
208
		validateSelection();
152
	}
209
	}
Lines 319-325 Link Here
319
	   }
376
	   }
320
	
377
	
321
	protected boolean validateSelection() {
378
	protected boolean validateSelection() {
322
		boolean valid = true;
379
		valid = true;
323
		setMessage(null);
380
		setMessage(null);
324
		setErrorMessage(null);
381
		setErrorMessage(null);
325
		if (existingDatapoolButtonStatus) {
382
		if (existingDatapoolButtonStatus) {
Lines 403-406 Link Here
403
	{
460
	{
404
		return datapoolSelectionViewer.getSelectedFiles();
461
		return datapoolSelectionViewer.getSelectedFiles();
405
	}
462
	}
463
	public Text getTextArea(){
464
		return textArea;
465
	}
466
	
467
	public boolean isEncrypted(){
468
		return isEncrypted;
469
	}	
406
}
470
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/util/ValueObject.java (-1 / +16 lines)
Lines 23-29 Link Here
23
public class ValueObject {
23
public class ValueObject {
24
24
25
	private Object theObject;
25
	private Object theObject;
26
	private IDisplayValueClass valueClass;
26
	protected IDisplayValueClass valueClass;
27
	private String description;
27
	private String description;
28
	private Object display;
28
	private Object display;
29
	
29
	
Lines 65-70 Link Here
65
		return null;
65
		return null;
66
	}
66
	}
67
	
67
	
68
	public Object getEncryptedDisplay(Composite parent)
69
	{
70
		if ( display != null && display instanceof CellEditor )
71
		{
72
			Control control = ((CellEditor)display).getControl();
73
			if ( control != null && !control.isDisposed() )
74
				return display;
75
		}
76
		if ( valueClass != null )
77
		{
78
			display = ((EncryptedStringValueClass)valueClass).getPropertyDisplay(theObject, parent, true);
79
			return display;
80
		}
81
		return null;
82
	}
68
	public Object getDialogDisplay(Composite parent, boolean isEditable)
83
	public Object getDialogDisplay(Composite parent, boolean isEditable)
69
	{
84
	{
70
		return null;
85
		return null;
(-)src/org/eclipse/hyades/test/ui/internal/resources/UiPluginResourceBundle.java (+30 lines)
Lines 69-74 Link Here
69
	public static String DatapoolImportWizard_editOrSelectDatapool;
69
	public static String DatapoolImportWizard_editOrSelectDatapool;
70
	public static String DatapoolImportWizard_selectCSV;
70
	public static String DatapoolImportWizard_selectCSV;
71
	public static String DatapoolImportWizard_selectDatapool;
71
	public static String DatapoolImportWizard_selectDatapool;
72
	public static String DatapoolExportWizard_encrypted;
73
	public static String DatapoolExportWizard_unencrypted;
74
	public static String DatapoolExportWizard_wrongpass;
75
	public static String DatapoolExportWizard_rightpass;
76
	public static String DatapoolExportWizard_password;
77
	public static String DatapoolDialog_CHANGEKEY;
78
	public static String DatapoolDialog_ENCRYPTED;
79
	public static String DatapoolDialog_ASSIGNKEYDIALOGTITLE;
80
	public static String DatapoolDialog_CHANGEKEYDIALOGTITLE;
81
	public static String DatapoolDialog_OLDKEY;
82
	public static String DatapoolDialog_NEWKEY;
83
	public static String DatapoolDialog_CONFIRMNEWKEY;
84
	public static String DatapoolDialog_ORIGINKEYERRORMES;
85
	public static String DatapoolDialog_NEWKEYNULLMES;
86
	public static String DatapoolDialog_NEWKEYNOTCONFIRMMES;
87
	public static String DatapoolDialog_WRONGLOGONKEYMES;
88
	public static String DatapoolDialog_ERRORDIALOGTITLE;
89
	public static String DatapoolDialog_KEY;
90
	public static String DatapoolDialog_LOGONDIALOGTITLE;
91
	public static String DatapoolDialog_ENCRYPTEDID;
92
	public static String DatapoolDialog_ENCRYPTEDDISPLAYVALUE;
93
	public static String DatapoolDialog_ERRORFOREDITENCRYPTEDVALUE;
94
	public static String DatapoolDialog_INPUTKEYDIALGOTITLE;
95
	public static String DatapoolDialog_TRUE;
96
	public static String DatapoolDialog_OK;
97
	public static String DatapoolDialog_PASSWORDSHINT;
98
	public static String DatapoolDialog_SPLITMARK;
99
	public static String DatapoolDialog_TRYAGAIN;
100
	public static String DatapoolDialog_NOTALLMATCH;
101
	public static String DatapoolDialog_INPUTPASSHINT;
72
	public static String ToggleViewAction_resource_label;
102
	public static String ToggleViewAction_resource_label;
73
	public static String ToggleViewAction_resource_description;
103
	public static String ToggleViewAction_resource_description;
74
	public static String ToggleViewAction_resource_tooltip;
104
	public static String ToggleViewAction_resource_tooltip;
(-)src/org/eclipse/hyades/test/ui/internal/resources/messages.properties (-1 / +31 lines)
Lines 64-70 Link Here
64
DatapoolImportWizard_editOrSelectDatapool=Please edit the datapool or select a different one and import again.
64
DatapoolImportWizard_editOrSelectDatapool=Please edit the datapool or select a different one and import again.
65
DatapoolImportWizard_selectCSV=&Select the CSV file to import data from:
65
DatapoolImportWizard_selectCSV=&Select the CSV file to import data from:
66
DatapoolImportWizard_selectDatapool= Select a datapool to import data into:
66
DatapoolImportWizard_selectDatapool= Select a datapool to import data into:
67
67
DatapoolExportWizard_encrypted=  is encrypted. Please supply the password.
68
DatapoolExportWizard_unencrypted=  is not encrypted. Press Finish to complete.
69
DatapoolExportWizard_wrongpass=Wrong password. Try again or cancel.
70
DatapoolExportWizard_rightpass=You passed. Check Finish to complete.
71
DatapoolExportWizard_password=Password for
72
73
DatapoolDialog_CHANGEKEY=Change Password
74
DatapoolDialog_ENCRYPTED=Encrypted
75
DatapoolDialog_ASSIGNKEYDIALOGTITLE=Assign  Password
76
DatapoolDialog_CHANGEKEYDIALOGTITLE=Change Password
77
DatapoolDialog_OLDKEY=Origin Password
78
DatapoolDialog_NEWKEY=New Password
79
DatapoolDialog_CONFIRMNEWKEY=Confirm New Password
80
DatapoolDialog_ORIGINKEYERRORMES=The origin Password is wrong
81
DatapoolDialog_NEWKEYNULLMES=The new Password should not be null
82
DatapoolDialog_NEWKEYNOTCONFIRMMES=The confirm Password is not the same as the new Password
83
DatapoolDialog_WRONGLOGONKEYMES=The Password input is incorrect
84
DatapoolDialog_ERRORDIALOGTITLE=Error
85
DatapoolDialog_KEY=Key
86
DatapoolDialog_LOGONDIALOGTITLE=Log on
87
DatapoolDialog_ENCRYPTEDID=isencrypted
88
DatapoolDialog_ENCRYPTEDDISPLAYVALUE=******
89
DatapoolDialog_ERRORFOREDITENCRYPTEDVALUE=The cell has been encrypted , please decrypted it before editing
90
DatapoolDialog_INPUTKEYDIALGOTITLE=Input Password
91
DatapoolDialog_TRUE=true
92
DatapoolDialog_OK=OK
93
DatapoolDialog_PASSWORDSHINT=password for the following are not correct!:\n\n
94
DatapoolDialog_SPLITMARK=::
95
DatapoolDialog_TRYAGAIN=\n\nPlease try again or Cancel
96
DatapoolDialog_NOTALLMATCH=Passwords not all matched!
97
DatapoolDialog_INPUTPASSHINT=Please enter the passwords for each encrypted datapool:
68
ToggleViewAction_resource_label=Resource test navigator
98
ToggleViewAction_resource_label=Resource test navigator
69
ToggleViewAction_resource_description=Show the resource test navigator
99
ToggleViewAction_resource_description=Show the resource test navigator
70
ToggleViewAction_resource_tooltip=Show the resource test navigator
100
ToggleViewAction_resource_tooltip=Show the resource test navigator
(-)src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolTable.java (-19 / +317 lines)
Lines 25-38 Link Here
25
import org.eclipse.hyades.edit.datapool.IDatapoolRecord;
25
import org.eclipse.hyades.edit.datapool.IDatapoolRecord;
26
import org.eclipse.hyades.edit.datapool.IDatapoolSuggestedType;
26
import org.eclipse.hyades.edit.datapool.IDatapoolSuggestedType;
27
import org.eclipse.hyades.edit.datapool.IDatapoolVariable;
27
import org.eclipse.hyades.edit.datapool.IDatapoolVariable;
28
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
29
import org.eclipse.hyades.models.common.datapool.DPLVariable;
30
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
31
import org.eclipse.hyades.models.common.util.EncryptionManager;
28
import org.eclipse.hyades.test.ui.UiPlugin;
32
import org.eclipse.hyades.test.ui.UiPlugin;
33
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolChangeKeyDialog;
29
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolColumnDialog;
34
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolColumnDialog;
35
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolConstant;
30
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolDeleteColumnDialog;
36
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolDeleteColumnDialog;
37
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolInputKeyDialog;
31
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolRowDialog;
38
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolRowDialog;
32
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IDatapoolPart;
39
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IDatapoolPart;
33
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IValidateValueClass;
40
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IValidateValueClass;
34
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IValueClassFactory;
41
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IValueClassFactory;
35
import org.eclipse.hyades.test.ui.datapool.internal.util.DatapoolUtil;
42
import org.eclipse.hyades.test.ui.datapool.internal.util.DatapoolUtil;
43
import org.eclipse.hyades.test.ui.datapool.internal.util.EncryptedValueObject;
36
import org.eclipse.hyades.test.ui.datapool.internal.util.TypeChecker;
44
import org.eclipse.hyades.test.ui.datapool.internal.util.TypeChecker;
37
import org.eclipse.hyades.test.ui.datapool.internal.util.ValueClassMap;
45
import org.eclipse.hyades.test.ui.datapool.internal.util.ValueClassMap;
38
import org.eclipse.hyades.test.ui.datapool.internal.util.ValueObject;
46
import org.eclipse.hyades.test.ui.datapool.internal.util.ValueObject;
Lines 135-140 Link Here
135
	private boolean showRecords = true;
143
	private boolean showRecords = true;
136
	private boolean isF2Mode = false;
144
	private boolean isF2Mode = false;
137
	private int previousMultiRowSelectionIndex = -1;  // only used for deselecting when multi-selection in place.
145
	private int previousMultiRowSelectionIndex = -1;  // only used for deselecting when multi-selection in place.
146
	private String cellkey;
147
	private boolean passwordExist = false;
148
	private String password = null;
138
	
149
	
139
	private String vendorID = null;
150
	private String vendorID = null;
140
	
151
	
Lines 1379-1397 Link Here
1379
			if(rawValue == null)
1390
			if(rawValue == null)
1380
			{	
1391
			{	
1381
				String typeName = suggestedType.getSuggestedClassName();					
1392
				String typeName = suggestedType.getSuggestedClassName();					
1382
				if(typeName == null || typeName.length() == 0)
1393
				if (typeName == null || typeName.length() == 0) {
1383
				{
1384
					rawValue = new String();
1394
					rawValue = new String();
1385
				}
1395
				} else {
1386
				else
1387
				{
1388
					rawValue = createEmptyCellObject(typeName);
1396
					rawValue = createEmptyCellObject(typeName);
1389
				}
1397
				}
1390
			}
1398
			}
1391
			
1399
			if(DatapoolEncryptManager.isVaribelEncrypted(variable))
1392
			theValueObject = new ValueObject(rawValue);
1400
			{
1393
			cellEditor = (CellEditor)theValueObject.getPropertyDisplay(tableCursor);
1401
				boolean errorKey = true;
1394
		}		
1402
				boolean isCancelChange = false;
1403
				String key = null;
1404
				if(passwordExist){
1405
					key = password;
1406
				}else{
1407
					DatapoolInputKeyDialog logOnDialog = new DatapoolInputKeyDialog(
1408
							Display.getCurrent().getActiveShell(),
1409
							UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE);
1410
	//				String key = getKeyInDatapool(datapool);
1411
					
1412
					while (errorKey) {
1413
						int openValue = logOnDialog.open();
1414
						if (openValue == IDialogConstants.OK_ID) {
1415
							key = logOnDialog.getKey();
1416
							cellkey = key;
1417
							if (DatapoolEncryptManager.isKeyCorrect(datapool, key)) {
1418
								errorKey = false;
1419
								password = key;
1420
								passwordExist = true;
1421
							} else {//the input key is incorrect
1422
								showErrMes(Display.getCurrent()
1423
										.getActiveShell(),
1424
										UiPluginResourceBundle.DatapoolDialog_WRONGLOGONKEYMES);
1425
							}
1426
						} else if (openValue == IDialogConstants.CANCEL_ID) {// click cancel button
1427
							isCancelChange = true;
1428
							errorKey = false;
1429
	
1430
						}
1431
					}
1432
					
1433
					if(isCancelChange)
1434
					{
1435
						return;
1436
					}
1437
				}
1438
				rawValue = EncryptionManager.decrypt(rawValue.toString(), key);
1439
				theValueObject = new EncryptedValueObject(rawValue);
1440
				cellEditor = (CellEditor) theValueObject
1441
				.getEncryptedDisplay(tableCursor);
1442
			}else{
1443
				theValueObject = new ValueObject(rawValue);
1444
			cellEditor = (CellEditor) theValueObject
1445
					.getPropertyDisplay(tableCursor);
1446
			}
1447
//			cellEditor = new TextCellEditor(tableCursor,SWT.PASSWORD);
1448
//			cellEditor.setValue(rawValue.toString());
1449
//			int oldStyle = cellEditor.getStyle();
1450
//			cellEditor.setStyle(SWT.PASSWORD|oldStyle);
1451
//			oldStyle = cellEditor.getStyle();
1452
		}
1395
		
1453
		
1396
		if(cellEditor != null && cellEditor.getControl() != null)
1454
		if(cellEditor != null && cellEditor.getControl() != null)
1397
		{
1455
		{
Lines 1491-1498 Link Here
1491
					}
1549
					}
1492
				}
1550
				}
1493
				
1551
				
1494
				if(update)
1552
				if (update) {
1495
				{
1553
					if(DatapoolEncryptManager.isVaribelEncrypted(cell.getCellVariable()))
1554
					{
1555
						String value = String.valueOf(updatedValue);
1556
						String encryptValue = DatapoolEncryptManager.encrypt(value, cellkey);
1557
						updatedValue = (Object)encryptValue;
1558
						
1559
					}
1496
					cell.setCellValue(updatedValue);
1560
					cell.setCellValue(updatedValue);
1497
					selectedTableItem.setText(selectedColumnIndex, newDescription);
1561
					selectedTableItem.setText(selectedColumnIndex, newDescription);
1498
					tableCursor.setSelection(table.getSelectionIndex(), selectedColumnIndex);
1562
					tableCursor.setSelection(table.getSelectionIndex(), selectedColumnIndex);
Lines 1501-1506 Link Here
1501
			}
1565
			}
1502
			
1566
			
1503
			if(dispose)
1567
			if(dispose)
1568
				refreshRows();
1504
				clearCellEditor();
1569
				clearCellEditor();
1505
		}						
1570
		}						
1506
	}
1571
	}
Lines 1838-1852 Link Here
1838
1903
1839
		IDatapool datapool = getDatapool();
1904
		IDatapool datapool = getDatapool();
1840
		DatapoolColumnDialog dialog = new DatapoolColumnDialog(Display.getCurrent().getActiveShell(), datapool, null, previousVariable, UiPluginResourceBundle.DATA_COL_DLG_TITLE_INS);  
1905
		DatapoolColumnDialog dialog = new DatapoolColumnDialog(Display.getCurrent().getActiveShell(), datapool, null, previousVariable, UiPluginResourceBundle.DATA_COL_DLG_TITLE_INS);  
1841
		if ( dialog.open() == IDialogConstants.OK_ID)
1906
		if (dialog.open() == IDialogConstants.OK_ID) {
1842
		{
1907
			if(dialog.isEncrypted()){
1908
			String key = null;			
1909
			if(isKeyExist())
1910
			{
1911
				boolean errorKey = true;
1912
				if(passwordExist && !dialog.isKeyChanged()){
1913
					key = password;
1914
				}else{
1915
					DatapoolInputKeyDialog logOnDialog = new DatapoolInputKeyDialog(
1916
							Display.getCurrent().getActiveShell(),
1917
							UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE);
1918
					while (errorKey) {
1919
						int openValue = logOnDialog.open();
1920
						if (openValue == IDialogConstants.OK_ID) {
1921
							key = logOnDialog.getKey();
1922
							if (DatapoolEncryptManager.isKeyCorrect(datapool,key)) {
1923
								errorKey = false;
1924
								password = key;
1925
								passwordExist = true;
1926
							} else {
1927
								showErrMes(Display.getCurrent()
1928
										.getActiveShell(),
1929
										UiPluginResourceBundle.DatapoolDialog_WRONGLOGONKEYMES);
1930
							}
1931
						} else if (openValue == IDialogConstants.CANCEL_ID) {
1932
							errorKey = false;
1933
						}
1934
					}
1935
				}
1936
			}
1937
			else
1938
			{
1939
				Shell shell = Display.getCurrent().getActiveShell();
1940
				DatapoolChangeKeyDialog assignKeyDialog = new DatapoolChangeKeyDialog(
1941
						shell, datapool,
1942
						UiPluginResourceBundle.DatapoolDialog_ASSIGNKEYDIALOGTITLE);
1943
				boolean errorKey = true;				
1944
				while (errorKey) {
1945
					if (assignKeyDialog.open() == IDialogConstants.OK_ID) {
1946
						key = assignKeyDialog.getNewKey();
1947
						int ret = assignKeyDialog.isKeyAssignSuccess();
1948
						switch (ret) {
1949
						case DatapoolConstant.NEWKEYNULL:
1950
							showErrMes(shell,
1951
									UiPluginResourceBundle.DatapoolDialog_NEWKEYNULLMES);
1952
							break;
1953
						case DatapoolConstant.NEWKEYNOTCONFIRM:
1954
							showErrMes(
1955
									shell,
1956
									UiPluginResourceBundle.DatapoolDialog_NEWKEYNOTCONFIRMMES);
1957
							break;
1958
						case DatapoolConstant.CHANGEKEYSUCCESS:									
1959
							try{
1960
							DatapoolEncryptManager.ChangeKey(EncryptionManager.EncoderByMd5(key),
1961
									datapool);
1962
//							
1963
							errorKey = false;
1964
							password = key;
1965
							passwordExist = true;
1966
							}catch(Exception e){}
1967
							break;
1968
						default:// error
1969
						}
1970
					} else {						
1971
						errorKey = false;
1972
					}
1973
				}
1974
			}
1975
			}
1976
			
1843
			setWaitCursor();
1977
			setWaitCursor();
1844
			IDatapoolVariable variable = datapool.constructVariable();
1978
			IDatapoolVariable variable = datapool.constructVariable();
1845
			variable.setName(dialog.getName());
1979
			variable.setName(dialog.getName());
1846
			IDatapoolSuggestedType suggestedType = (IDatapoolSuggestedType)variable.getSuggestedType();
1980
			IDatapoolSuggestedType suggestedType = (IDatapoolSuggestedType)variable.getSuggestedType();
1847
			setVariableType(suggestedType, dialog.getType());
1981
			setVariableType(suggestedType, dialog.getType());
1848
			variable.setSuggestedType(suggestedType);
1982
			variable.setSuggestedType(suggestedType);
1849
			int insertionIndex = findColumnIndex(dialog.getInsertionVariableName());
1983
			
1984
			((DPLVariable)variable).setEncrypted(dialog.isEncrypted());
1985
			
1986
			int insertionIndex = findColumnIndex(dialog
1987
					.getInsertionVariableName());
1850
			if(insertionIndex == -1)
1988
			if(insertionIndex == -1)
1851
				insertionIndex = 0;
1989
				insertionIndex = 0;
1852
1990
Lines 1858-1863 Link Here
1858
			if (tableCursor != null && !tableCursor.isDisposed() && !(row < 0 || row >= table.getItemCount() || insertionIndex < 0 || insertionIndex > maxColumnIndex)) {
1996
			if (tableCursor != null && !tableCursor.isDisposed() && !(row < 0 || row >= table.getItemCount() || insertionIndex < 0 || insertionIndex > maxColumnIndex)) {
1859
                tableCursor.setSelection(row, insertionIndex + 1);			
1997
                tableCursor.setSelection(row, insertionIndex + 1);			
1860
            }
1998
            }
1999
			refreshRows();
1861
		}
2000
		}
1862
	}
2001
	}
1863
2002
Lines 1922-1927 Link Here
1922
	 * Function that actually does the editing of the variable/column.
2061
	 * Function that actually does the editing of the variable/column.
1923
	 */	
2062
	 */	
1924
	private void editColumnAux(TableColumn tableColumn) {
2063
	private void editColumnAux(TableColumn tableColumn) {
2064
		boolean isVariableEncrypted = false;
1925
        try {
2065
        try {
1926
            if (showVariables == false) return;
2066
            if (showVariables == false) return;
1927
2067
Lines 1932-1939 Link Here
1932
            IDatapoolVariable previousVariable = null;
2072
            IDatapoolVariable previousVariable = null;
1933
            if (previousTableColumn != null) previousVariable = (IDatapoolVariable) previousTableColumn.getData(TAG_VARIABLE);
2073
            if (previousTableColumn != null) previousVariable = (IDatapoolVariable) previousTableColumn.getData(TAG_VARIABLE);
1934
            IDatapoolVariable variable = (IDatapoolVariable) tableColumn.getData(TAG_VARIABLE);
2074
            IDatapoolVariable variable = (IDatapoolVariable) tableColumn.getData(TAG_VARIABLE);
1935
            DatapoolColumnDialog dialog = new DatapoolColumnDialog(Display.getCurrent().getActiveShell(), datapool, variable, previousVariable, UiPluginResourceBundle.DATA_COL_DLG_TITLE_EDIT); //$NON-NLS-1$
2075
            DatapoolColumnDialog dialog = new DatapoolColumnDialog(Display
1936
            if (dialog.open() == IDialogConstants.OK_ID) {
2076
					.getCurrent().getActiveShell(), datapool, variable,
2077
					previousVariable,
2078
					UiPluginResourceBundle.DATA_COL_DLG_TITLE_EDIT); //$NON-NLS-1$
2079
			isVariableEncrypted = DatapoolEncryptManager.isVaribelEncrypted(variable);
2080
			String key = null;
2081
			if (dialog.open() == IDialogConstants.OK_ID) {
2082
				if (isNeedKeyVerify(dialog,isVariableEncrypted)) {//need to confrim key or assign a new key
2083
					boolean isCancelChange = false;
2084
					if(isKeyExist())//key exists means it needs to confirm key
2085
					{
2086
						//if(dialog.isKeyChanged())
2087
						//{
2088
							//key = dialog.getKey();							
2089
						//}
2090
						boolean errorKey = true;
2091
						
2092
						if(passwordExist && !dialog.isKeyChanged()){
2093
							key = password;
2094
						}else{
2095
						
2096
							DatapoolInputKeyDialog logOnDialog = new DatapoolInputKeyDialog(
2097
									Display.getCurrent().getActiveShell(),
2098
									UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE);
2099
							while (errorKey) {
2100
								int openValue = logOnDialog.open();
2101
								if (openValue == IDialogConstants.OK_ID) {
2102
									key = logOnDialog.getKey();									
2103
									if (DatapoolEncryptManager.isKeyCorrect(datapool,key)) {
2104
										errorKey = false;
2105
										password = key;
2106
										passwordExist = true;
2107
									} else {//the input key is incorrect
2108
										showErrMes(Display.getCurrent()
2109
												.getActiveShell(),
2110
												UiPluginResourceBundle.DatapoolDialog_WRONGLOGONKEYMES);
2111
									}
2112
								} else if (openValue == IDialogConstants.CANCEL_ID) {// click cancel button
2113
									isCancelChange = true;
2114
									errorKey = false;
2115
								}
2116
							}
2117
						}
2118
					}
2119
					else//it should assing a new key
2120
					{
2121
						Shell shell = Display.getCurrent().getActiveShell();
2122
						DatapoolChangeKeyDialog assignKeyDialog = new DatapoolChangeKeyDialog(
2123
								shell, datapool,
2124
								UiPluginResourceBundle.DatapoolDialog_ASSIGNKEYDIALOGTITLE);
2125
						boolean errorKey = true;
2126
						
2127
						while (errorKey) {
2128
2129
							if (assignKeyDialog.open() == IDialogConstants.OK_ID) {
2130
								key = assignKeyDialog.getNewKey();
2131
								int ret = assignKeyDialog.isKeyAssignSuccess();
2132
								switch (ret) {
2133
								case DatapoolConstant.NEWKEYNULL:
2134
									showErrMes(shell,
2135
											UiPluginResourceBundle.DatapoolDialog_NEWKEYNULLMES);
2136
									break;
2137
								case DatapoolConstant.NEWKEYNOTCONFIRM:
2138
									showErrMes(
2139
											shell,
2140
											UiPluginResourceBundle.DatapoolDialog_NEWKEYNOTCONFIRMMES);
2141
									break;
2142
								case DatapoolConstant.CHANGEKEYSUCCESS:									
2143
									try{
2144
									DatapoolEncryptManager.ChangeKey(EncryptionManager.EncoderByMd5(key),
2145
											datapool);
2146
//									encryptedCellInVarible(variable,newKey);
2147
									errorKey = false;
2148
									
2149
									//TODO: added 
2150
									password = key;
2151
									passwordExist = true;
2152
									}catch(Exception e){}
2153
									break;
2154
								default:// error
2155
								}
2156
2157
							} else {
2158
								isCancelChange = true;
2159
								errorKey = false;
2160
							}
2161
						}
2162
					}
2163
					if(!isCancelChange)//input the correct key
2164
					{					
2165
						if (dialog.isEncrypted()) {
2166
							if (!isVariableEncrypted) {//encrypted a varible which didn't encrypted
2167
								DatapoolEncryptManager.encryptedCellInVarible(variable,key,datapool);
2168
								if(variable instanceof DPLVariable)
2169
									((DPLVariable)variable).setEncrypted(true);
2170
							}
2171
2172
						} else {
2173
							if (isVariableEncrypted) {//deencrypted a encrypted variable
2174
								DatapoolEncryptManager.deencryptedCellInVarible(variable,key,datapool);
2175
								if(variable instanceof DPLVariable)
2176
									((DPLVariable)variable).setEncrypted(false);
2177
							}
2178
						}
1937
                setWaitCursor();
2179
                setWaitCursor();
1938
                String name = dialog.getName();
2180
                String name = dialog.getName();
1939
                String insertionVariableID = dialog.getInsertionVariableID();
2181
                String insertionVariableID = dialog.getInsertionVariableID();
Lines 1945-1952 Link Here
1945
                variable.setName(dialog.getName());
2187
                variable.setName(dialog.getName());
1946
                setVariableType(suggestedType, dialog.getType());
2188
                setVariableType(suggestedType, dialog.getType());
1947
                variable.setSuggestedType(suggestedType);
2189
                variable.setSuggestedType(suggestedType);
2190
						int insertionIndex = findColumnIndex(dialog
2191
								.getInsertionVariableName());
2192
						if (insertionIndex == columnIndex - 1) {
2193
							refresh();
2194
							return;
2195
						}
2196
						if (insertionIndex == -1)
2197
							datapool.moveVariable(columnIndex - 1, 0);
2198
						else if (insertionIndex > columnIndex)
2199
							datapool.moveVariable(columnIndex - 1,
2200
									insertionIndex - 1);
2201
						else
2202
							datapool.moveVariable(columnIndex - 1, insertionIndex);
1948
2203
1949
                int insertionIndex = findColumnIndex(dialog.getInsertionVariableName());
2204
						refreshRows();//needs to refresh row
2205
						tableCursor.setSelection(0, 0);
2206
					}
2207
				
2208
				} else {
2209
					setWaitCursor();
2210
2211
					String name = dialog.getName();
2212
					String insertionVariableID = dialog
2213
							.getInsertionVariableID();
2214
2215
					IDatapoolSuggestedType suggestedType = (IDatapoolSuggestedType) variable
2216
							.getSuggestedType();
2217
					if (name.equals(variable.getName())
2218
							&& insertionVariableID.equals(variable.getId())) {
2219
						return;
2220
					}
2221
					variable.setName(dialog.getName());
2222
					setVariableType(suggestedType, dialog.getType());
2223
					variable.setSuggestedType(suggestedType);
2224
					
2225
					int insertionIndex = findColumnIndex(dialog
2226
							.getInsertionVariableName());
1950
                if (insertionIndex == columnIndex - 1) {
2227
                if (insertionIndex == columnIndex - 1) {
1951
                    return;
2228
                    return;
1952
                }
2229
                }
Lines 1956-1963 Link Here
1956
                    datapool.moveVariable(columnIndex - 1, insertionIndex - 1);
2233
                    datapool.moveVariable(columnIndex - 1, insertionIndex - 1);
1957
                else
2234
                else
1958
                    datapool.moveVariable(columnIndex - 1, insertionIndex);
2235
                    datapool.moveVariable(columnIndex - 1, insertionIndex);
2236
					tableCursor.setSelection(0, 0);
1959
            }
2237
            }
1960
        } finally {
2238
        }} finally {
1961
            unsetWaitCursor();
2239
            unsetWaitCursor();
1962
        }
2240
        }
1963
    }
2241
    }
Lines 2890-2896 Link Here
2890
				IDatapoolVariable cellVariable = (IDatapoolVariable)cell.getCellVariable();
3168
				IDatapoolVariable cellVariable = (IDatapoolVariable)cell.getCellVariable();
2891
				int index = findColumnIndex(cellVariable.getName());
3169
				int index = findColumnIndex(cellVariable.getName());
2892
				String cellValue = cell.getStringValue();
3170
				String cellValue = cell.getStringValue();
2893
				ValueObject valueObject = new ValueObject(cell.getCellValue());
3171
				if(DatapoolEncryptManager.isVaribelEncrypted(cell.getCellVariable()))
3172
				{
3173
					cellValue = UiPluginResourceBundle.DatapoolDialog_ENCRYPTEDDISPLAYVALUE;
3174
				}
3175
//				ValueObject valueObject = new ValueObject(cell.getCellValue());
3176
				ValueObject valueObject = new ValueObject(cellValue);
2894
				if(valueObject != null)
3177
				if(valueObject != null)
2895
					cellValue = valueObject.getDescription();
3178
					cellValue = valueObject.getDescription();
2896
				rowContents[index] = cellValue;
3179
				rowContents[index] = cellValue;
Lines 3013-3016 Link Here
3013
		setMenuMode(datapoolMenuManager);
3296
		setMenuMode(datapoolMenuManager);
3014
	}
3297
	}
3015
	
3298
	
3299
	public void setPassword(String password){
3300
		this.password = password;
3301
	}
3302
	private void showErrMes(Shell shell, String mes) {
3303
		MessageDialog.openError(shell, UiPluginResourceBundle.DatapoolDialog_ERRORDIALOGTITLE, mes);
3304
	}
3305
	
3306
		private boolean isNeedKeyVerify(DatapoolColumnDialog dialog,boolean isVariableEncrypted)
3307
		{
3308
			return dialog.isEncrypted() || isVariableEncrypted;
3309
		}
3310
		private boolean isKeyExist()
3311
		{
3312
			return (datapool instanceof DPLDatapool)?(((DPLDatapool)datapool).getChallenge()!=null):false;	
3313
		}	
3016
}
3314
}
(-)src/org/eclipse/hyades/test/ui/internal/editor/DatapoolEditorPart.java (-1 / +22 lines)
Lines 12-18 Link Here
12
package org.eclipse.hyades.test.ui.internal.editor;
12
package org.eclipse.hyades.test.ui.internal.editor;
13
13
14
import org.eclipse.emf.ecore.EObject;
14
import org.eclipse.emf.ecore.EObject;
15
import org.eclipse.hyades.edit.datapool.IDatapool;
15
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
16
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
17
import org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl;
18
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
16
import org.eclipse.hyades.models.common.util.ICommonConstants;
19
import org.eclipse.hyades.models.common.util.ICommonConstants;
17
import org.eclipse.hyades.test.ui.TestUIExtension;
20
import org.eclipse.hyades.test.ui.TestUIExtension;
18
import org.eclipse.hyades.test.ui.internal.editor.extension.DatapoolEditorExtension;
21
import org.eclipse.hyades.test.ui.internal.editor.extension.DatapoolEditorExtension;
Lines 86-90 Link Here
86
		return true;
89
		return true;
87
	}
90
	}
88
91
89
	
92
	public void dispose(){		
93
		if(this.getEditorExtension() instanceof DatapoolEditorExtension){
94
			IDatapool dp = ((DatapoolEditorExtension)this.getEditorExtension()).getDatapool();
95
	        boolean isAnyColumnEncrypted = false;
96
	        int variableCount = dp.getVariableCount();
97
			for(int i=0;i<variableCount;i++){			
98
				if(DatapoolEncryptManager.isVaribelEncrypted(((DPLVariableImpl)dp.getVariable(i)))){
99
					isAnyColumnEncrypted = true;
100
					break;
101
				}
102
			}
103
			if(!isAnyColumnEncrypted && (dp instanceof DPLDatapool)){
104
				((DPLDatapool)dp).setChallenge(null);
105
				((DatapoolEditorExtension)this.getEditorExtension()).save();
106
			}		
107
		}
108
		super.dispose();	
109
		
110
	}	
90
}
111
}
(-)plugin.xml (+8 lines)
Lines 900-905 Link Here
900
                testType="org.eclipse.hyades.test.http.junit.testSuite">
900
                testType="org.eclipse.hyades.test.http.junit.testSuite">
901
          </verdictProvider>
901
          </verdictProvider>
902
       </extension>
902
       </extension>
903
          <extension
904
             point="org.eclipse.hyades.test.core.launchDatapoolCheckPass">
905
          <launchDatapoolCheckPass
906
                UIClass="org.eclipse.hyades.test.ui.dialog.DatapoolCheck">
907
             <supportedTestType>
908
             </supportedTestType>
909
          </launchDatapoolCheckPass>
910
       </extension>
903
   
911
   
904
   
912
   
905
</plugin>
913
</plugin>
(-)src/org/eclipse/hyades/test/ui/datapool/internal/dialog/DatapoolConstant.java (+24 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: DatapoolConstant.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.ui.datapool.internal.dialog;
13
14
/**
15
* It's used to provide constant message for datapool related dialog .
16
* 
17
* @author Huang Xin Ying 
18
*/
19
public class DatapoolConstant {
20
	public static final int CHANGEKEYSUCCESS = 0;
21
	public static final int ORIGINTKEYERROR = 1;
22
	public static final int NEWKEYNULL = 2;
23
	public static final int NEWKEYNOTCONFIRM = 3;	
24
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/util/EncryptedStringValueClass.java (+40 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: EncryptedStringValueClass.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.ui.datapool.internal.util;
13
14
import org.eclipse.jface.viewers.TextCellEditor;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Label;
18
19
/**
20
* @author Huang Xin Ying 
21
*/
22
public class EncryptedStringValueClass extends StringValueClass{
23
	public Object getPropertyDisplay(Object theObject, Composite parent, boolean editable)
24
	{
25
		if(editable && theObject != null)
26
		{
27
			TextCellEditor cellEditor = new TextCellEditor(parent,SWT.PASSWORD);
28
29
			cellEditor.setValue(theObject.toString());
30
			return cellEditor;
31
		}
32
		else
33
		{
34
			Label label = new Label(parent, SWT.NONE);
35
			label.setText(getPropertyDescription(theObject));
36
			return label;
37
		}
38
	}
39
40
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/util/EncryptedValueObject.java (+28 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: EncryptedValueObject.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.test.ui.datapool.internal.util;
14
15
/**
16
* @author Huang Xin Ying 
17
*/
18
public class EncryptedValueObject extends ValueObject{
19
20
	public EncryptedValueObject(Object theObject) {
21
		super(theObject);
22
		valueClass = new EncryptedStringValueClass();
23
		
24
		// TODO Auto-generated constructor stub
25
	}
26
	
27
28
}
(-)src/org/eclipse/hyades/test/ui/dialog/DatapoolCheck.java (+330 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: DatapoolCheck.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.ui.dialog;
13
14
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
18
19
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
20
import org.eclipse.hyades.models.common.util.EncryptionManager;
21
import org.eclipse.hyades.test.core.launch.extensions.IPassInfoCollector;
22
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
23
import org.eclipse.jface.dialogs.Dialog;
24
import org.eclipse.jface.dialogs.IDialogConstants;
25
import org.eclipse.jface.dialogs.MessageDialog;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.MouseAdapter;
28
import org.eclipse.swt.events.MouseEvent;
29
import org.eclipse.swt.layout.FormAttachment;
30
import org.eclipse.swt.layout.FormData;
31
import org.eclipse.swt.layout.FormLayout;
32
import org.eclipse.swt.widgets.Button;
33
import org.eclipse.swt.widgets.Composite;
34
import org.eclipse.swt.widgets.Control;
35
import org.eclipse.swt.widgets.Display;
36
import org.eclipse.swt.widgets.Label;
37
import org.eclipse.swt.widgets.Shell;
38
import org.eclipse.swt.widgets.Text;
39
40
/**
41
 * 
42
 * It's the implementation of launchDatapoolCheckPass extension point , provide
43
 * dialog to prompt user input password for encrypted datapool during launching a test 
44
 * on workbench side .
45
 * 
46
 * @author Huang Xin Ying 
47
 */
48
public class DatapoolCheck implements IPassInfoCollector {
49
50
	public DatapoolCheck() {
51
	}
52
53
	public void execute(DPLDatapool[] dp, Map pass, List isContinue) {
54
		DialogRun dr = new DialogRun();
55
		dr.setDp(dp);
56
		dr.setContinue(isContinue);
57
		dr.setPass(pass);
58
		Display.getDefault().syncExec(dr);
59
	}
60
61
	private class DialogRun implements Runnable {
62
		private DPLDatapool[] dp;
63
		private Map pass;
64
		private List isContinue;
65
66
		public void setDp(DPLDatapool[] dp) {
67
			this.dp = dp;
68
		}
69
70
		public void setPass(Map pass) {
71
			this.pass = pass;
72
		}
73
74
		public void setContinue(List isContinue) {
75
			this.isContinue = isContinue;
76
		}
77
78
		public void run() {
79
			String testId = null;
80
			if(isContinue != null && isContinue.size() == 1){
81
				testId = (String)isContinue.get(0);
82
				isContinue.clear();
83
			}
84
			DatapoolCheckDialog db = new DatapoolCheckDialog(null, 
85
					dp, 
86
					UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE,
87
					pass,
88
					testId);
89
			db.setBlockOnOpen(true);
90
			if (db.open() == IDialogConstants.OK_ID) {
91
				isContinue.add(UiPluginResourceBundle.DatapoolDialog_TRUE);
92
			}
93
		}
94
	}
95
    
96
	
97
	private class DatapoolCheckDialog extends Dialog {
98
		private Button okButton;
99
100
		private Button checkButton;
101
102
		private DPLDatapool[] dp;
103
		private String title;
104
		private int dpNameLength = 0;
105
		private int oriHeight = 0;
106
		private Label[] name;
107
		private Text[] pass;
108
		private Button[] status;
109
		private List unCorrectList = new ArrayList();
110
		private Map passed;
111
		private String testId;
112
113
		/**
114
		 * @param parentShell
115
		 */
116
		public DatapoolCheckDialog(Shell parentShell) {
117
			super(parentShell);
118
		}
119
120
		public DatapoolCheckDialog(Shell parentShell, DPLDatapool[] dp,
121
				String title, Map passed,String testId) {
122
			super(parentShell);
123
			this.dp = dp;
124
			this.title = title;
125
			this.passed = passed;
126
			this.testId = testId;
127
		}
128
129
		/*
130
		 * (non-Javadoc)
131
		 * 
132
		 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
133
		 */
134
		protected void createButtonsForButtonBar(Composite parent) {
135
			// create OK and Cancel buttons by default
136
			okButton = createButton(parent, IDialogConstants.OK_ID,
137
					IDialogConstants.OK_LABEL, true);
138
			checkButton = createButton(parent, IDialogConstants.YES_ID,
139
					IDialogConstants.YES_LABEL, false);
140
			checkButton.setText(UiPluginResourceBundle.DatapoolDialog_OK);
141
			checkButton.addMouseListener(new MouseAdapter() {
142
				public void mouseDown(MouseEvent e) {
143
					// check all the passwords
144
					for (int i = 0; i < dp.length; i++) {
145
						try {
146
							if (status[i].getSelection()) {
147
								continue;
148
							} else if (dp[i].getChallenge().equals(
149
									EncryptionManager.EncoderByMd5(pass[i].getText()))) {
150
								
151
								if(passed.get(testId) == null){
152
									passed.put(testId, new HashMap());
153
								}
154
								HashMap thm = (HashMap)passed.get(testId);
155
								thm.put(dp[i].getName(), pass[i].getText());
156
								
157
								pass[i].setEnabled(false);
158
								status[i].setSelection(true);
159
								if (unCorrectList != null
160
										&& unCorrectList.contains(dp[i])) {
161
									unCorrectList.remove(dp[i]);
162
								}
163
							} else {
164
								pass[i].setText("");
165
								if (!unCorrectList.contains(dp[i]))
166
									unCorrectList.add(dp[i]);
167
							}
168
						} catch (Exception er) {
169
							er.printStackTrace();
170
						}
171
					}
172
					// if all status is true, then set ok button can be pressed
173
					if (unCorrectList.size() == 0) {
174
						okPressed();
175
						return;
176
					}
177
178
					StringBuffer toShow = new StringBuffer();
179
					toShow
180
							.append(UiPluginResourceBundle.DatapoolDialog_PASSWORDSHINT);
181
					for (int i = 0; i < unCorrectList.size(); i++) {
182
						toShow.append(((DPLDatapool) unCorrectList.get(i))
183
								.getName().split(UiPluginResourceBundle.DatapoolDialog_SPLITMARK)[0]);
184
						if (i < unCorrectList.size() - 1) {
185
							toShow.append(",\n");
186
						}
187
					}
188
					toShow.append(UiPluginResourceBundle.DatapoolDialog_TRYAGAIN);
189
190
					MessageDialog dialog = new MessageDialog(null,
191
							UiPluginResourceBundle.DatapoolDialog_NOTALLMATCH, // the dialog title
192
							null, toShow.toString(), // text to be displayed
193
							MessageDialog.WARNING, // dialog type
194
							new String[] { UiPluginResourceBundle.DatapoolDialog_OK }, // button labels
195
							0);
196
					dialog.open();
197
				}
198
			});
199
200
			createButton(parent, IDialogConstants.CANCEL_ID,
201
					IDialogConstants.CANCEL_LABEL, false);
202
			okButton.setVisible(false);
203
		}
204
205
		/*
206
		 * (non-Javadoc)
207
		 * 
208
		 * @see org.eclipse.jface.dialogs.Dialog#getButton(int)
209
		 */
210
		protected Button getButton(int id) {
211
			if (id == IDialogConstants.OK_ID)
212
				return okButton;
213
			return super.getButton(id);
214
		}
215
216
		/*
217
		 * (non-Javadoc)
218
		 * 
219
		 * @see org.eclipse.jface.dialogs.Dialog#getOKButton()
220
		 */
221
		protected Button getOKButton() {
222
			return okButton;
223
		}
224
225
		/* modified the content */
226
		protected Control createDialogArea(Composite parent) {
227
			getShell().setText(title);
228
			Composite superComposite = (Composite) super
229
					.createDialogArea(parent);
230
231
			superComposite.setLayout(new FormLayout());
232
233
			FormData formData;
234
235
			Label hint = new Label(superComposite, SWT.NULL);
236
			hint.setText(UiPluginResourceBundle.DatapoolDialog_INPUTPASSHINT);
237
			formData = new FormData();
238
			formData.left = new FormAttachment(superComposite, 5);
239
			formData.top = new FormAttachment(superComposite, 5);
240
			hint.setLayoutData(formData);
241
242
			if (dp != null && dp.length > 0) {
243
244
				name = new Label[dp.length];
245
				pass = new Text[dp.length];
246
				status = new Button[dp.length];
247
248
				name[0] = new Label(superComposite, SWT.BORDER);
249
				formData = new FormData();
250
				formData.left = new FormAttachment(superComposite, 5);
251
				formData.top = new FormAttachment(hint, 10);
252
				name[0].setLayoutData(formData);
253
				name[0].setText(getdpNameLength());
254
				name[0].pack();
255
				dpNameLength = name[0].getSize().x;
256
				oriHeight = name[0].getSize().y;
257
				formData.width = dpNameLength;
258
				formData.height = oriHeight;
259
				name[0].setLayoutData(formData);
260
				name[0].setText(dp[0].getName().split(UiPluginResourceBundle.DatapoolDialog_SPLITMARK)[0] + ":");
261
262
				pass[0] = new Text(superComposite, SWT.PASSWORD | SWT.BORDER);
263
				formData = new FormData();
264
				formData.left = new FormAttachment(name[0], 5);
265
				formData.top = new FormAttachment(hint, 10);
266
				formData.width = 50;
267
				formData.height = oriHeight;
268
				pass[0].setLayoutData(formData);
269
270
				status[0] = new Button(superComposite, SWT.CHECK);
271
				formData = new FormData();
272
				formData.left = new FormAttachment(pass[0], 10);
273
				formData.top = new FormAttachment(hint, 10);
274
				formData.height = oriHeight;
275
				status[0].setLayoutData(formData);
276
				status[0].setSelection(false);
277
				status[0].setEnabled(false);
278
				status[0].setVisible(false);
279
280
				for (int i = 1; i < dp.length; i++) {
281
					name[i] = new Label(superComposite, SWT.BORDER);
282
					formData = new FormData();
283
					formData.left = new FormAttachment(superComposite, 5);
284
					formData.top = new FormAttachment(name[i - 1], 10);
285
					formData.width = dpNameLength;
286
					formData.height = oriHeight;
287
					name[i].setLayoutData(formData);
288
					name[i].setText(dp[i].getName().split(UiPluginResourceBundle.DatapoolDialog_SPLITMARK)[0] + ":");
289
290
					pass[i] = new Text(superComposite, SWT.PASSWORD
291
							| SWT.BORDER);
292
					formData = new FormData();
293
					formData.left = new FormAttachment(name[i], 5);
294
					formData.top = new FormAttachment(name[i - 1], 5);
295
					formData.width = 50;
296
					formData.height = oriHeight;
297
					pass[i].setLayoutData(formData);
298
299
					status[i] = new Button(superComposite, SWT.CHECK);
300
					formData = new FormData();
301
					formData.left = new FormAttachment(pass[i], 10);
302
					formData.top = new FormAttachment(name[i - 1], 5);
303
					formData.height = oriHeight;
304
					status[i].setLayoutData(formData);
305
					status[i].setSelection(false);
306
					status[i].setEnabled(false);
307
					status[i].setVisible(false);
308
				}
309
			}
310
311
			superComposite.pack();
312
			return superComposite;
313
		}
314
315
		private String getdpNameLength() {
316
			
317
			String datapoolName = "";
318
			
319
			for (int counter = 0; counter < dp.length; counter++) {
320
321
				if(dp[counter].getName().length() > datapoolName.length()){
322
					datapoolName = dp[counter].getName();
323
				}
324
			}
325
			
326
			return datapoolName;
327
		}
328
	}
329
330
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/dialog/DatapoolInputKeyDialog.java (+92 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: DatapoolInputKeyDialog.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.ui.datapool.internal.dialog;
13
14
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
15
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.KeyEvent;
18
import org.eclipse.swt.events.KeyListener;
19
import org.eclipse.swt.graphics.Color;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Label;
25
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.swt.widgets.Text;
27
28
/**
29
* It's used to provide dialog for key input function .
30
* 
31
* @author Huang Xin Ying 
32
*/
33
public class DatapoolInputKeyDialog extends DatapoolBaseDialog implements
34
		KeyListener {
35
36
	private String title;
37
38
	private Text logOnField = null;
39
	private Color logOnFieldForeground = null;
40
41
	private String key = "";
42
43
	public DatapoolInputKeyDialog(Shell parentShell, String title) {
44
		super(parentShell);
45
		this.title = title;
46
		// TODO Auto-generated constructor stub
47
	}
48
49
	public void keyPressed(KeyEvent e) {
50
		// TODO Auto-generated method stub
51
52
	}
53
54
	public void keyReleased(KeyEvent e) {
55
		// TODO Auto-generated method stub
56
		if (logOnField != null) {
57
			key = logOnField.getText();
58
		}
59
60
	}
61
62
	protected Control createDialogArea(Composite parent) {
63
		getShell().setText(title);
64
		Composite superComposite = (Composite) super.createDialogArea(parent);
65
		GridData gridData = GridDataUtil.createFill();
66
		gridData.minimumWidth = 250;
67
		superComposite.setLayoutData(gridData);
68
69
		GridLayout gridLayout = new GridLayout();
70
		gridLayout.numColumns = 2;
71
		superComposite.setLayout(gridLayout);
72
73
		Label logOnLabe = new Label(superComposite, SWT.NONE);
74
		logOnLabe.setText(UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE);
75
		logOnField = new Text(superComposite, SWT.SINGLE | SWT.BORDER
76
				| SWT.PASSWORD);
77
		gridData = new GridData(GridData.FILL_HORIZONTAL);
78
		logOnField.setLayoutData(gridData);
79
		logOnField.addKeyListener(this);
80
		logOnFieldForeground = logOnField.getForeground();
81
		if (key != null) {
82
			logOnField.setText(key);
83
		}
84
		superComposite.pack();
85
		return superComposite;
86
	}
87
88
	public String getKey() {
89
		return key;
90
	}
91
92
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/dialog/DatapoolChangeKeyDialog.java (+163 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: DatapoolChangeKeyDialog.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.ui.datapool.internal.dialog;
13
14
import org.eclipse.hyades.edit.datapool.IDatapool;
15
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
16
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
17
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.events.KeyEvent;
20
import org.eclipse.swt.events.KeyListener;
21
import org.eclipse.swt.graphics.Color;
22
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.layout.GridLayout;
24
import org.eclipse.swt.widgets.Combo;
25
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Control;
27
import org.eclipse.swt.widgets.Label;
28
import org.eclipse.swt.widgets.Shell;
29
import org.eclipse.swt.widgets.Text;
30
31
/**
32
* It's used to provide dialog for key change function .
33
* 
34
* @author Huang Xin Ying 
35
*/
36
public class DatapoolChangeKeyDialog extends DatapoolBaseDialog implements
37
		KeyListener {
38
39
	private IDatapool datapool = null;
40
	private String title = null;
41
	private Text oldKeyField = null;
42
	private Text newKeyField = null;
43
	private Text confirmKeyField = null;
44
	private Color oldKeyFieldForeground = null;
45
	private Color newKeyFieldForeground = null;
46
	private Color confirmKeyFieldForeground = null;
47
	private Combo insertionVariables = null;
48
	private Label nameErrorLabel;
49
	private Label typeErrorLabel;
50
51
	private String oldKey = null;
52
	private String newKey = null;
53
	private String confirmKey = null;
54
	private String insertionVariableID = null;
55
	private String insertionVariableName = null;
56
	private int defaultNameCounter = 1;
57
58
	public DatapoolChangeKeyDialog(Shell parentShell, IDatapool datapool,
59
			String title) {
60
		super(parentShell);
61
		this.title = title;
62
		this.datapool = datapool;
63
		// TODO Auto-generated constructor stub
64
	}
65
66
	public void keyPressed(KeyEvent e) {
67
		// TODO Auto-generated method stub
68
69
	}
70
71
	public void keyReleased(KeyEvent e) {
72
		// TODO Auto-generated method stub
73
		if (oldKeyField != null) {
74
			oldKey = oldKeyField.getText();
75
		}
76
		if (newKeyField != null) {
77
			newKey = newKeyField.getText();
78
		}
79
		if (confirmKeyField != null) {
80
			confirmKey = confirmKeyField.getText();
81
		}
82
83
	}
84
85
	protected Control createDialogArea(Composite parent) {
86
		getShell().setText(title);
87
		Composite superComposite = (Composite) super.createDialogArea(parent);
88
		GridData gridData = GridDataUtil.createFill();
89
		gridData.minimumWidth = 250;
90
		superComposite.setLayoutData(gridData);
91
92
		GridLayout gridLayout = new GridLayout();
93
		gridLayout.numColumns = 2;
94
		superComposite.setLayout(gridLayout);
95
		if (title.equals(UiPluginResourceBundle.DatapoolDialog_CHANGEKEYDIALOGTITLE)) {
96
			Label oldKeyLabel = new Label(superComposite, SWT.NONE);
97
			oldKeyLabel.setText(UiPluginResourceBundle.DatapoolDialog_OLDKEY);
98
			oldKeyField = new Text(superComposite, SWT.SINGLE | SWT.BORDER
99
					| SWT.PASSWORD);
100
			gridData = new GridData(GridData.FILL_HORIZONTAL);
101
			oldKeyField.setLayoutData(gridData);
102
			oldKeyField.addKeyListener(this);
103
			oldKeyFieldForeground = oldKeyField.getForeground();
104
		}
105
		Label newKeyLabel = new Label(superComposite, SWT.NONE);
106
		newKeyLabel.setText(UiPluginResourceBundle.DatapoolDialog_NEWKEY);
107
		newKeyField = new Text(superComposite, SWT.SINGLE | SWT.BORDER
108
				| SWT.PASSWORD);
109
		gridData = new GridData(GridData.FILL_HORIZONTAL);
110
		newKeyField.setLayoutData(gridData);
111
		newKeyField.addKeyListener(this);
112
		newKeyFieldForeground = newKeyField.getForeground();
113
114
		Label confirmKeyLabel = new Label(superComposite, SWT.NONE);
115
		confirmKeyLabel.setText(UiPluginResourceBundle.DatapoolDialog_CONFIRMNEWKEY);
116
		confirmKeyField = new Text(superComposite, SWT.SINGLE | SWT.BORDER
117
				| SWT.PASSWORD);
118
		gridData = new GridData(GridData.FILL_HORIZONTAL);
119
		confirmKeyField.setLayoutData(gridData);
120
		confirmKeyField.addKeyListener(this);
121
		confirmKeyFieldForeground = confirmKeyField.getForeground();
122
		
123
		superComposite.pack();
124
		return superComposite;
125
	}
126
127
	public String getOldKey() {
128
		return oldKey;
129
	}
130
131
	public String getNewKey() {
132
		return newKey;
133
	}
134
135
	public String getConfirmKey() {
136
		return confirmKey;
137
	}
138
139
	public int isKeyChangeSuccess(IDatapool datapool) {
140
		int retValue = DatapoolConstant.CHANGEKEYSUCCESS;
141
		if (!DatapoolEncryptManager.isKeyCorrect(datapool, oldKey)) {
142
			retValue = DatapoolConstant.ORIGINTKEYERROR;
143
		} else if (newKey == null || newKey.equals("")) {
144
			retValue = DatapoolConstant.NEWKEYNULL;
145
		} else if (!newKey.equals(confirmKey)) {
146
			retValue = DatapoolConstant.NEWKEYNOTCONFIRM;
147
		}
148
		return retValue;
149
150
	}
151
152
	public int isKeyAssignSuccess() {
153
		int retValue = DatapoolConstant.CHANGEKEYSUCCESS;
154
		if (newKey == null || newKey.equals("")) {
155
			retValue = DatapoolConstant.NEWKEYNULL;
156
		} else if (!newKey.equals(confirmKey)) {
157
			retValue = DatapoolConstant.NEWKEYNOTCONFIRM;
158
		}
159
		return retValue;
160
161
	}
162
163
}
(-)src-common-runner/org/eclipse/hyades/test/common/runner/HyadesRunner.java (+11 lines)
Lines 22-33 Link Here
22
import org.eclipse.hyades.internal.execution.remote.AgentControllerUnavailableException;
22
import org.eclipse.hyades.internal.execution.remote.AgentControllerUnavailableException;
23
import org.eclipse.hyades.internal.execution.remote.CustomCommandHandler;
23
import org.eclipse.hyades.internal.execution.remote.CustomCommandHandler;
24
import org.eclipse.hyades.internal.execution.remote.RemoteComponentSkeleton;
24
import org.eclipse.hyades.internal.execution.remote.RemoteComponentSkeleton;
25
import org.eclipse.hyades.models.common.datapool.util.DPLPasswordCollection;
25
import org.eclipse.hyades.models.common.facades.behavioral.impl.FacadeResourceFactoryImpl;
26
import org.eclipse.hyades.models.common.facades.behavioral.impl.FacadeResourceFactoryImpl;
26
import org.eclipse.hyades.models.common.testprofile.impl.Common_TestprofilePackageImpl;
27
import org.eclipse.hyades.models.common.testprofile.impl.Common_TestprofilePackageImpl;
27
import org.eclipse.hyades.test.common.agent.ComptestAgent;
28
import org.eclipse.hyades.test.common.agent.ComptestAgent;
28
import org.eclipse.hyades.test.common.agent.PrimaryTestAgent;
29
import org.eclipse.hyades.test.common.agent.PrimaryTestAgent;
29
import org.eclipse.hyades.test.common.agent.ServiceCommandHandler;
30
import org.eclipse.hyades.test.common.agent.ServiceCommandHandler;
31
import org.eclipse.hyades.test.common.agent.UnknownTestServiceException;
30
import org.eclipse.hyades.test.common.event.ExecutionEvent;
32
import org.eclipse.hyades.test.common.event.ExecutionEvent;
33
import org.eclipse.hyades.test.common.testservices.resources.DatapoolPasswordProvider;
31
34
32
/**
35
/**
33
 * @author jsutton
36
 * @author jsutton
Lines 234-239 Link Here
234
				}
237
				}
235
			}
238
			}
236
		}
239
		}
240
		//set password to Models
241
		try {
242
			DPLPasswordCollection.getInstance().
243
			setDatapoolPassword(DatapoolPasswordProvider.getDatapoolPassword(testID));
244
		} catch (UnknownTestServiceException e) {			
245
		}
237
246
238
	}
247
	}
239
	
248
	
Lines 246-251 Link Here
246
	};
255
	};
247
	
256
	
248
	public void dispose() {
257
	public void dispose() {
258
		//clear the passwords in Models
259
		DPLPasswordCollection.getInstance().clear();
249
		if (agent != null && agent.isRegistered()) {
260
		if (agent != null && agent.isRegistered()) {
250
			Runtime.getRuntime().removeShutdownHook(disposeOnExitHook);
261
			Runtime.getRuntime().removeShutdownHook(disposeOnExitHook);
251
			agent.deregister();
262
			agent.deregister();
(-)src-common-runner/org/eclipse/hyades/test/common/testservices/resources/DatapoolPasswordProvider.java (+76 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id: DatapoolPasswordProvider.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.common.testservices.resources;
13
14
import java.util.HashMap;
15
16
import org.eclipse.hyades.test.common.agent.ServiceInvoker;
17
import org.eclipse.hyades.test.common.agent.UnconfiguredComptestAgentException;
18
import org.eclipse.hyades.test.common.agent.UnknownTestServiceException;
19
import org.eclipse.osgi.util.NLS;
20
21
/**
22
*  
23
* It's the client of DatapoolPasswordsService ,used to get list of datapool and it's encryption 
24
* password from workbench side.
25
* 
26
* @author Huang Xin Ying 
27
*
28
*/
29
public class DatapoolPasswordProvider{
30
	
31
  protected static final String DATAPOOL_PASSWORD_PROVIDER = "org.eclipse.hyades.test.core.DatapoolPasswordProvider";
32
  
33
  /**
34
   * @param testId
35
   * @return 
36
   */
37
  public static HashMap getDatapoolPassword(String testId) throws UnknownTestServiceException{
38
		String result = null;
39
		Object[] args = {testId};
40
		String buffer = NLS.bind("method=getDatapoolList,args:testId={0}", args);
41
		try{
42
			
43
			result = ServiceInvoker.invokeService(getProviderName(), buffer);
44
			
45
		}catch(UnconfiguredComptestAgentException e) {
46
			throw new UnknownTestServiceException(e);
47
		}
48
		
49
		return parseResult(result);
50
	}	
51
	
52
  /**
53
   * @param result
54
   * @return 
55
   */
56
	private static HashMap parseResult(String result){
57
		if(result == null)
58
			return null;
59
		
60
		HashMap pr = new HashMap();
61
		if(result.contains(";")){
62
			String[] pairs = result.split(";");
63
			for(int i=0;i<pairs.length;i++){
64
				if(pairs[i].contains("=")){
65
					pr.put(pairs[i].split("=")[0], pairs[i].split("=")[1]);
66
				}
67
			}
68
		}
69
		
70
		return pr;
71
	}
72
	
73
	public static String getProviderName(){
74
		return DATAPOOL_PASSWORD_PROVIDER;
75
	}
76
}

Return to bug 202695