Skip to content

Commit 492ef39

Browse files
committed
applying PR apache#4827 Co-authored-by: @sramazzina
1 parent a7fd894 commit 492ef39

File tree

10 files changed

+124
-39
lines changed

10 files changed

+124
-39
lines changed

plugins/misc/mail/src/main/java/org/apache/hop/metadata/mail/MailServerConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public class MailServerConnection extends HopMetadataBase implements IHopMetadat
4444

4545
@HopMetadataProperty private String username;
4646

47-
@HopMetadataProperty private String password;
47+
@HopMetadataProperty(password = true)
48+
private String password;
4849

4950
@HopMetadataProperty private boolean useXOAuth2;
5051

plugins/misc/mail/src/main/java/org/apache/hop/metadata/mail/MailServerConnectionEditor.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public class MailServerConnectionEditor extends MetadataEditor<MailServerConnect
5555

5656
private Button wCheckServerIdentity;
5757

58-
private Label wlCheckServerIdentity;
59-
6058
private LabelTextVar wTrustedHosts;
6159

6260
public MailServerConnectionEditor(
@@ -256,9 +254,9 @@ public void createControl(Composite composite) {
256254
lastControl = wSecureConnectionType;
257255

258256
// Use check server identity
259-
wlCheckServerIdentity = new Label(composite, SWT.RIGHT);
257+
Label wlCheckServerIdentity = new Label(composite, SWT.RIGHT);
260258
wlCheckServerIdentity.setText(
261-
BaseMessages.getString(PKG, "ActionMail.CheckServerIdentity.Label"));
259+
BaseMessages.getString(PKG, "MailServerConnectionDialog.CheckServerIdentity"));
262260
PropsUi.setLook(wlCheckServerIdentity);
263261
FormData fdlCheckServerIdentity = new FormData();
264262
fdlCheckServerIdentity.left = new FormAttachment(0, 0);
@@ -279,20 +277,21 @@ public void widgetSelected(SelectionEvent e) {
279277
setChanged();
280278
}
281279
});
280+
lastControl = wCheckServerIdentity;
282281

283282
// Trusted Hosts line
284283
wTrustedHosts =
285284
new LabelTextVar(
286285
variables,
287286
composite,
288-
BaseMessages.getString(PKG, "ActionMail.TrustedHosts.Label"),
289-
BaseMessages.getString(PKG, "ActionMail.TrustedHosts.Tooltip"));
290-
// wTrustedHosts.addModifyListener(lsMod);
287+
BaseMessages.getString(PKG, "MailServerConnectionDialog.TrustedHosts"),
288+
BaseMessages.getString(PKG, "MailServerConnectionDialog.TrustedHosts.Tooltip"));
291289
FormData fdTrustedHosts = new FormData();
292290
fdTrustedHosts.left = new FormAttachment(0, 0);
293-
fdTrustedHosts.top = new FormAttachment(lastControl, 2 * margin);
291+
fdTrustedHosts.top = new FormAttachment(lastControl, 0);
294292
fdTrustedHosts.right = new FormAttachment(100, 0);
295293
wTrustedHosts.setLayoutData(fdTrustedHosts);
294+
lastControl = wTrustedHosts;
296295

297296
Label wlUseProxy = new Label(composite, SWT.RIGHT);
298297
PropsUi.setLook(wlUseProxy);

plugins/misc/mail/src/main/java/org/apache/hop/pipeline/transforms/mail/MailDialog.java

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ public class MailDialog extends BaseTransformDialog {
193193

194194
private TextVar wMessageOutputField;
195195

196+
private Button wCheckServerIdentity;
197+
private Label wlCheckServerIdentity;
198+
private LabelTextVar wTrustedHosts;
199+
196200
private boolean getPreviousFields = false;
197201

198202
private final MailMeta input;
@@ -730,7 +734,7 @@ public void focusGained(FocusEvent e) {
730734
// ///////////////////////////////////////
731735

732736
// ////////////////////////////////////
733-
// START OF AUTHENTIFICATION GROUP
737+
// START OF AUTHENTICATION GROUP
734738
// ////////////////////////////////////
735739

736740
Group wAuthentificationGroup = new Group(wContentComp, SWT.SHADOW_NONE);
@@ -914,6 +918,45 @@ public void widgetSelected(SelectionEvent e) {
914918
}
915919
});
916920

921+
// Use check server identity
922+
wlCheckServerIdentity = new Label(wAuthentificationGroup, SWT.RIGHT);
923+
wlCheckServerIdentity.setText(BaseMessages.getString(PKG, "Mail.CheckServerIdentity.Label"));
924+
PropsUi.setLook(wlCheckServerIdentity);
925+
FormData fdlCheckServerIdentity = new FormData();
926+
fdlCheckServerIdentity.left = new FormAttachment(0, 0);
927+
fdlCheckServerIdentity.top = new FormAttachment(wSecureConnectionType, 2 * margin);
928+
fdlCheckServerIdentity.right = new FormAttachment(middle, -margin);
929+
wlCheckServerIdentity.setLayoutData(fdlCheckServerIdentity);
930+
wCheckServerIdentity = new Button(wAuthentificationGroup, SWT.CHECK);
931+
PropsUi.setLook(wCheckServerIdentity);
932+
FormData fdCheckServerIdentity = new FormData();
933+
fdCheckServerIdentity.left = new FormAttachment(middle, margin);
934+
fdCheckServerIdentity.top = new FormAttachment(wlCheckServerIdentity, 0, SWT.CENTER);
935+
fdCheckServerIdentity.right = new FormAttachment(100, 0);
936+
wCheckServerIdentity.setLayoutData(fdCheckServerIdentity);
937+
wCheckServerIdentity.addSelectionListener(
938+
new SelectionAdapter() {
939+
@Override
940+
public void widgetSelected(SelectionEvent e) {
941+
setSecureConnectiontype();
942+
input.setChanged();
943+
}
944+
});
945+
946+
// Trusted Hosts line
947+
wTrustedHosts =
948+
new LabelTextVar(
949+
variables,
950+
wAuthentificationGroup,
951+
BaseMessages.getString(PKG, "Mail.TrustedHosts.Label"),
952+
BaseMessages.getString(PKG, "Mail.TrustedHosts.Tooltip"));
953+
wTrustedHosts.addModifyListener(lsMod);
954+
FormData fdTrustedHosts = new FormData();
955+
fdTrustedHosts.left = new FormAttachment(0, 0);
956+
fdTrustedHosts.top = new FormAttachment(wlCheckServerIdentity, 2 * margin);
957+
fdTrustedHosts.right = new FormAttachment(100, 0);
958+
wTrustedHosts.setLayoutData(fdTrustedHosts);
959+
917960
FormData fdAuthentificationGroup = new FormData();
918961
fdAuthentificationGroup.left = new FormAttachment(0, margin);
919962
fdAuthentificationGroup.top = new FormAttachment(wServerGroup, margin);
@@ -2102,6 +2145,7 @@ public void widgetSelected(SelectionEvent arg0) {
21022145
setDynamicZip();
21032146
setZip();
21042147
setUseAuth();
2148+
setSecureConnectiontype();
21052149
activateIsAttachContentField();
21062150
setOutputMessage();
21072151
input.setChanged(changed);
@@ -2376,6 +2420,8 @@ private void setEnabledEncoding() {
23762420
protected void setSecureConnectiontype() {
23772421
wSecureConnectionType.setEnabled(wUseSecAuth.getSelection());
23782422
wlSecureConnectionType.setEnabled(wUseSecAuth.getSelection());
2423+
wTrustedHosts.setEnabled(wUseSecAuth.getSelection());
2424+
wCheckServerIdentity.setEnabled(wUseSecAuth.getSelection());
23792425
}
23802426

23812427
private void setEncodings() {
@@ -2500,6 +2546,7 @@ public void getData() {
25002546
}
25012547

25022548
wUseAuth.setSelection(input.isUsingAuthentication());
2549+
wCheckServerIdentity.setSelection(input.isCheckServerIdentity());
25032550
wUseXOAUTH2.setSelection(input.isUseXOAUTH2());
25042551
wUseSecAuth.setSelection(input.isUsingSecureAuthentication());
25052552
if (input.getAuthenticationUser() != null) {
@@ -2508,7 +2555,9 @@ public void getData() {
25082555
if (input.getAuthenticationPassword() != null) {
25092556
wAuthPass.setText(input.getAuthenticationPassword());
25102557
}
2511-
2558+
if (!Utils.isEmpty(input.getTrustedHosts())) {
2559+
wTrustedHosts.setText(input.getTrustedHosts());
2560+
}
25122561
wOnlyComment.setSelection(input.isOnlySendComment());
25132562

25142563
wUseHTML.setSelection(input.isUseHTML());
@@ -2645,6 +2694,8 @@ private void ok() {
26452694
input.setOnlySendComment(wOnlyComment.getSelection());
26462695
input.setUseHTML(wUseHTML.getSelection());
26472696
input.setUsePriority(wUsePriority.getSelection());
2697+
input.setCheckServerIdentity(wCheckServerIdentity.getSelection());
2698+
input.setTrustedHosts(wTrustedHosts.getText());
26482699

26492700
input.setEncoding(wEncoding.getText());
26502701
input.setPriority(wPriority.getText());

plugins/misc/mail/src/main/java/org/apache/hop/pipeline/transforms/mail/MailMeta.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ public class MailMeta extends BaseTransformMeta<Mail, MailData> {
147147

148148
private String messageOutputField;
149149

150+
private boolean checkServerIdentity;
151+
private String trustedHosts;
152+
150153
public MailMeta() {
151154
super(); // allocate BaseTransformMeta
152155
}
@@ -199,6 +202,9 @@ private void readData(Node transformNode) {
199202
setContactPhone(XmlHandler.getTagValue(transformNode, "contact_phone"));
200203
setComment(XmlHandler.getTagValue(transformNode, "comment"));
201204
setIncludingFiles("Y".equalsIgnoreCase(XmlHandler.getTagValue(transformNode, "include_files")));
205+
setCheckServerIdentity(
206+
"Y".equalsIgnoreCase(XmlHandler.getTagValue(transformNode, "checkServerIdentity")));
207+
setTrustedHosts(XmlHandler.getTagValue(transformNode, "trustedHosts"));
202208
setUsingAuthentication("Y".equalsIgnoreCase(XmlHandler.getTagValue(transformNode, "use_auth")));
203209
setUseXOAUTH2("Y".equalsIgnoreCase(XmlHandler.getTagValue(transformNode, "usexoauth2")));
204210
setUsingSecureAuthentication(
@@ -320,6 +326,10 @@ public String getXml() throws HopException {
320326
.append(CONST_SPACE)
321327
.append(XmlHandler.addTagValue("sourcewildcard", this.sourcewildcard));
322328
retval.append(CONST_SPACE).append(XmlHandler.addTagValue("contact_person", this.contactPerson));
329+
retval
330+
.append(CONST_SPACE)
331+
.append(XmlHandler.addTagValue("checkServerIdentity", checkServerIdentity));
332+
retval.append(CONST_SPACE).append(XmlHandler.addTagValue("trustedHosts", trustedHosts));
323333
retval.append(CONST_SPACE).append(XmlHandler.addTagValue("contact_phone", this.contactPhone));
324334
retval.append(CONST_SPACE).append(XmlHandler.addTagValue("comment", this.comment));
325335
retval.append(CONST_SPACE).append(XmlHandler.addTagValue("include_files", this.includingFiles));
@@ -464,6 +474,22 @@ public void setAttachContentFileNameField(String attachContentFileNameField) {
464474
this.attachContentFileNameField = attachContentFileNameField;
465475
}
466476

477+
public boolean isCheckServerIdentity() {
478+
return checkServerIdentity;
479+
}
480+
481+
public void setCheckServerIdentity(boolean checkServerIdentity) {
482+
this.checkServerIdentity = checkServerIdentity;
483+
}
484+
485+
public String getTrustedHosts() {
486+
return trustedHosts;
487+
}
488+
489+
public void setTrustedHosts(String trustedHosts) {
490+
this.trustedHosts = trustedHosts;
491+
}
492+
467493
public void setDynamicWildcard(String dynamicwildcard) {
468494
this.dynamicWildcard = dynamicwildcard;
469495
}

plugins/misc/mail/src/main/resources/org/apache/hop/metadata/mail/messages/messages_en_US.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ MailServerConnectionDialog.UseProxy=Use proxy?
1313
MailServerConnectionDialog.ProxyUsername=Proxy username
1414
MailServerConnectionDialog.ProxyPassword=Proxy password
1515
MailServerConnectionDialog.ConnectionProtocol=Connection protocol
16+
MailServerConnectionDialog.CheckServerIdentity=Check server identity?
17+
MailServerConnectionDialog.TrustedHosts=Trusted hosts\:
18+
MailServerConnectionDialog.TrustedHosts.Tooltip=Insert the list of trusted hosts separated by a space\
19+
\nExample\: host1 host2 host3

plugins/misc/mail/src/main/resources/org/apache/hop/pipeline/transforms/mail/messages/messages_en_US.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,7 @@ MailMeta.CheckResult.TransformRecevingData2=Transform is receiving info from oth
187187
MailMeta.CheckResult.ZipfilenameEmpty=Attached zipfilename is empty\!
188188
MailMeta.CheckResult.ZipfilenameOk=Attached zipfilename is specified.
189189
MailMeta.keyword=mail
190+
Mail.CheckServerIdentity.Label=Check server identity?
191+
Mail.TrustedHosts.Label=Trusted hosts\:
192+
Mail.TrustedHosts.Tooltip=Insert the list of trusted hosts separated by a space\
193+
\nExample\: host1 host2 host3

plugins/misc/mail/src/main/resources/org/apache/hop/pipeline/transforms/mail/messages/messages_it_IT.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,6 @@ MailMeta.CheckResult.TransformRecevingData=Il transform \u00E8 connesso al prece
177177
MailMeta.CheckResult.TransformRecevingData2=Il transform sta ricevendo informazioni dagli altri transforms.
178178
MailMeta.CheckResult.ZipfilenameEmpty=Il nome file Zip allegato \u00E8 vuoto\!
179179
MailMeta.CheckResult.ZipfilenameOk=Il nome file Zip allegato \u00E8 stato specificato.
180+
Mail.TrustedHosts.Label=Hosts affidabili\:
181+
Mail.TrustedHosts.Tooltip=Riempi la lista degli hosts affidabili separandoli con uno spazio\
182+
\nEsempio\: host1 host2 host3

plugins/misc/mail/src/main/resources/org/apache/hop/workflow/actions/mail/messages/messages_en_US.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,8 @@ ActionMail.ZipFilename.Label=Name of zip archive
126126
ActionMail.ZipFilename.Tooltip=Name of zip archive
127127
ActionMail.ZipFiles.Label=Zip files to single archive
128128
ActionMailDialog.Server.Label=Server
129-
ActionMail.Group.ConnectionGroup.Label=Mail Server Connection
129+
ActionMail.Group.ConnectionGroup.Label=Mail Server Connection
130+
ActionMail.CheckServerIdentity.Label=Check server identity?
131+
ActionMail.TrustedHosts.Label=Trusted hosts\:
132+
ActionMail.TrustedHosts.Tooltip=Insert the list of trusted hosts separated by a space\
133+
\nExample\: host1 host2 host3

plugins/misc/mail/src/main/resources/org/apache/hop/workflow/actions/mail/messages/messages_it_IT.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,6 @@ ActionMail.ZipFilename.Label=Nome dell''archivio ZIP:
124124
ActionMail.ZipFilename.Tooltip=Nome dell''archivio ZIP
125125
ActionMail.ZipFiles.Label=Comprimere i file in un solo archivio?
126126
ActionMailDialog.Server.Label=Server
127+
ActionMail.TrustedHosts.Label=Hosts affidabili\:
128+
ActionMail.TrustedHosts.Tooltip=Riempi la lista degli hosts affidabili separandoli con uno spazio\
129+
\nEsempio\: host1 host2 host3

plugins/misc/mail/src/test/java/org/apache/hop/workflow/actions/mail/WorkflowActionMailLoadSaveTest.java

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,8 @@
1818
package org.apache.hop.workflow.actions.mail;
1919

2020
import java.util.Arrays;
21-
import java.util.HashMap;
2221
import java.util.List;
23-
import java.util.Map;
24-
import java.util.Random;
25-
import org.apache.hop.core.ResultFile;
2622
import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
27-
import org.apache.hop.pipeline.transforms.loadsave.validator.ArrayLoadSaveValidator;
28-
import org.apache.hop.pipeline.transforms.loadsave.validator.IFieldLoadSaveValidator;
29-
import org.apache.hop.pipeline.transforms.loadsave.validator.IntLoadSaveValidator;
30-
import org.apache.hop.pipeline.transforms.loadsave.validator.PrimitiveIntArrayLoadSaveValidator;
31-
import org.apache.hop.pipeline.transforms.loadsave.validator.StringLoadSaveValidator;
3223
import org.apache.hop.workflow.action.loadsave.WorkflowActionLoadSaveTestSupport;
3324
import org.junit.ClassRule;
3425

@@ -73,25 +64,24 @@ protected List<String> listAttributes() {
7364
"replyToAddresses",
7465
"fileType",
7566
"embeddedimages",
76-
"contentids"
77-
);
67+
"contentids");
7868
}
7969

80-
/*
81-
@Override
82-
protected Map<String, IFieldLoadSaveValidator<?>> createAttributeValidatorsMap() {
83-
Map<String, IFieldLoadSaveValidator<?>> validators = new HashMap<>();
84-
validators.put(
85-
"fileType",
86-
new PrimitiveIntArrayLoadSaveValidator(
87-
new IntLoadSaveValidator(ResultFile.fileTypeCode.length)));
70+
/*
71+
@Override
72+
protected Map<String, IFieldLoadSaveValidator<?>> createAttributeValidatorsMap() {
73+
Map<String, IFieldLoadSaveValidator<?>> validators = new HashMap<>();
74+
validators.put(
75+
"fileType",
76+
new PrimitiveIntArrayLoadSaveValidator(
77+
new IntLoadSaveValidator(ResultFile.fileTypeCode.length)));
8878
89-
int entries = new Random().nextInt(20) + 1;
90-
validators.put(
91-
"embeddedimages", new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(), entries));
92-
validators.put(
93-
"contentids", new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(), entries));
94-
return validators;
95-
}
96-
*/
79+
int entries = new Random().nextInt(20) + 1;
80+
validators.put(
81+
"embeddedimages", new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(), entries));
82+
validators.put(
83+
"contentids", new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(), entries));
84+
return validators;
85+
}
86+
*/
9787
}

0 commit comments

Comments
 (0)