ASF Bugzilla – Attachment 25787 Details for
Bug 49603
Allow accepting expired certificates on Mail Reader Sampler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Adds security settings to Mail Reader Sampler
patch.txt (text/plain), 49.26 KB, created by
Luciana Moreira
on 2010-07-20 09:52:00 UTC
(
hide
)
Description:
Adds security settings to Mail Reader Sampler
Filename:
MIME Type:
Creator:
Luciana Moreira
Created:
2010-07-20 09:52:00 UTC
Size:
49.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P jmeterSVN >Index: src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java >=================================================================== >--- src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java (revision 0) >+++ src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java (revision 0) >@@ -0,0 +1,411 @@ >+/* >+ * Licensed to the Apache Software Foundation (ASF) under one or more >+ * contributor license agreements. See the NOTICE file distributed with >+ * this work for additional information regarding copyright ownership. >+ * The ASF licenses this file to You under the Apache License, Version 2.0 >+ * (the "License"); you may not use this file except in compliance with >+ * the License. You may obtain a copy of the License at >+ * >+ * http://www.apache.org/licenses/LICENSE-2.0 >+ * >+ * Unless required by applicable law or agreed to in writing, software >+ * distributed under the License is distributed on an "AS IS" BASIS, >+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >+ * See the License for the specific language governing permissions and >+ * limitations under the License. >+ * >+ */ >+ >+package org.apache.jmeter.protocol.smtp.sampler.gui; >+ >+import java.awt.GridBagConstraints; >+import java.awt.GridBagLayout; >+import java.awt.event.ActionEvent; >+import java.awt.event.ActionListener; >+import java.awt.event.ItemEvent; >+import java.awt.event.ItemListener; >+ >+import javax.swing.BorderFactory; >+import javax.swing.ButtonGroup; >+import javax.swing.JCheckBox; >+import javax.swing.JLabel; >+import javax.swing.JPanel; >+import javax.swing.JRadioButton; >+import javax.swing.JTextField; >+ >+import org.apache.jmeter.testelement.TestElement; >+import org.apache.jmeter.util.JMeterUtils; >+ >+public class SecuritySettingsPanel extends JPanel{ >+ >+ public final static String USE_SSL = "SecuritySettingsPanel.useSSL"; // $NON-NLS-1$ >+ public final static String USE_STARTTLS = "SecuritySettingsPanel.useStartTLS"; // $NON-NLS-1$ >+ public final static String SSL_TRUST_ALL_CERTS = "SecuritySettingsPanel.trustAllCerts"; // $NON-NLS-1$ >+ public final static String ENFORCE_STARTTLS = "SecuritySettingsPanel.enforceStartTLS"; // $NON-NLS-1$ >+ public final static String USE_LOCAL_TRUSTSTORE = "SecuritySettingsPanel.useLocalTrustStore"; // $NON-NLS-1$ >+ public final static String TRUSTSTORE_TO_USE = "SecuritySettingsPanel.trustStoreToUse"; // $NON-NLS-1$ >+ >+ >+ private static final long serialVersionUID = 1L; >+ >+ private ButtonGroup bgSecuritySettings; >+ >+ private JRadioButton rbUseNone; >+ >+ private JRadioButton rbUseSSL; >+ >+ private JRadioButton rbUseStartTLS; >+ >+ private JCheckBox cbTrustAllCerts; >+ >+ private JCheckBox cbEnforceStartTLS; >+ >+ private JCheckBox cbUseLocalTrustStore; >+ >+ private JLabel jlTrustStoreToUse; >+ >+ private JTextField tfTrustStoreToUse; >+ >+ >+ public SecuritySettingsPanel() { >+ super(); >+ init(); >+ } >+ >+ public void init(){ >+ this.setLayout(new GridBagLayout()); >+ this.setBorder(BorderFactory.createTitledBorder( >+ BorderFactory.createEtchedBorder(), >+ JMeterUtils.getResString("smtp_security_settings"))); // $NON-NLS-1$ >+ >+ GridBagConstraints gridBagConstraints = new GridBagConstraints(); >+ gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); >+ gridBagConstraints.fill = GridBagConstraints.NONE; >+ gridBagConstraints.anchor = GridBagConstraints.WEST; >+ gridBagConstraints.weightx = 0.5; >+ >+ rbUseNone = new JRadioButton(JMeterUtils.getResString("smtp_usenone")); // $NON-NLS-1$ >+ rbUseSSL = new JRadioButton(JMeterUtils.getResString("smtp_usessl")); // $NON-NLS-1$ >+ rbUseStartTLS = new JRadioButton(JMeterUtils.getResString("smtp_usestarttls")); // $NON-NLS-1$ >+ >+ cbTrustAllCerts = new JCheckBox(JMeterUtils.getResString("smtp_trustall")); // $NON-NLS-1$ >+ cbEnforceStartTLS = new JCheckBox(JMeterUtils.getResString("smtp_enforcestarttls")); // $NON-NLS-1$ >+ cbUseLocalTrustStore = new JCheckBox(JMeterUtils.getResString("smtp_usetruststore")); // $NON-NLS-1$ >+ >+ jlTrustStoreToUse = new JLabel(JMeterUtils.getResString("smtp_truststore")); // $NON-NLS-1$ >+ >+ tfTrustStoreToUse = new JTextField(20); >+ >+ rbUseNone.setSelected(true); >+ bgSecuritySettings = new ButtonGroup(); >+ bgSecuritySettings.add(rbUseNone); >+ bgSecuritySettings.add(rbUseSSL); >+ bgSecuritySettings.add(rbUseStartTLS); >+ >+ gridBagConstraints.gridx = 0; >+ gridBagConstraints.gridy = 0; >+ this.add(rbUseNone, gridBagConstraints); >+ >+ gridBagConstraints.gridx = 1; >+ gridBagConstraints.gridy = 0; >+ this.add(rbUseSSL, gridBagConstraints); >+ >+ gridBagConstraints.gridx = 2; >+ gridBagConstraints.gridy = 0; >+ this.add(rbUseStartTLS, gridBagConstraints); >+ >+ rbUseNone.addItemListener(new ItemListener() { >+ public void itemStateChanged(ItemEvent evt) { >+ rbSecuritySettingsItemStateChanged(evt); >+ } >+ }); >+ rbUseSSL.addItemListener(new ItemListener() { >+ public void itemStateChanged(ItemEvent evt) { >+ rbSecuritySettingsItemStateChanged(evt); >+ } >+ }); >+ rbUseStartTLS.addItemListener(new ItemListener() { >+ public void itemStateChanged(ItemEvent evt) { >+ rbSecuritySettingsItemStateChanged(evt); >+ } >+ }); >+ >+ cbTrustAllCerts.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); >+ cbTrustAllCerts.setMargin(new java.awt.Insets(0, 0, 0, 0)); >+ cbTrustAllCerts.setEnabled(false); >+ cbTrustAllCerts.setToolTipText(JMeterUtils.getResString("smtp_trustall_tooltip")); // $NON-NLS-1$ >+ cbTrustAllCerts.addActionListener(new ActionListener() { >+ public void actionPerformed(ActionEvent evt) { >+ cbTrustAllCertsActionPerformed(evt); >+ } >+ }); >+ >+ gridBagConstraints.gridx = 0; >+ gridBagConstraints.gridy = 1; >+ this.add(cbTrustAllCerts, gridBagConstraints); >+ >+ cbEnforceStartTLS.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); >+ cbEnforceStartTLS.setMargin(new java.awt.Insets(0, 0, 0, 0)); >+ cbEnforceStartTLS.setEnabled(false); >+ cbEnforceStartTLS.addActionListener(new ActionListener() { >+ public void actionPerformed(ActionEvent evt) { >+ cbEnforceStartTLSActionPerformed(evt); >+ } >+ }); >+ cbEnforceStartTLS.setToolTipText(JMeterUtils.getResString("smtp_enforcestarttls_tooltip")); // $NON-NLS-1$ >+ >+ gridBagConstraints.gridx = 2; >+ gridBagConstraints.gridy = 1; >+ this.add(cbEnforceStartTLS, gridBagConstraints); >+ >+ cbUseLocalTrustStore.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); >+ cbUseLocalTrustStore.setMargin(new java.awt.Insets(0, 0, 0, 0)); >+ cbUseLocalTrustStore.setEnabled(false); >+ cbUseLocalTrustStore.addActionListener(new ActionListener() { >+ public void actionPerformed(ActionEvent evt) { >+ cbUseLocalTrustStoreActionPerformed(evt); >+ } >+ }); >+ >+ cbUseLocalTrustStore.setToolTipText(JMeterUtils.getResString("smtp_usetruststore_tooltip")); // $NON-NLS-1$ >+ >+ gridBagConstraints.gridx = 1; >+ gridBagConstraints.gridy = 1; >+ gridBagConstraints.gridwidth = 2; >+ this.add(cbUseLocalTrustStore, gridBagConstraints); >+ >+ gridBagConstraints.gridx = 0; >+ gridBagConstraints.gridy = 2; >+ gridBagConstraints.gridwidth = 1; >+ jlTrustStoreToUse.setToolTipText(JMeterUtils.getResString("smtp_truststore_tooltip")); >+ this.add(jlTrustStoreToUse, gridBagConstraints); >+ >+ gridBagConstraints.gridx = 1; >+ gridBagConstraints.gridy = 2; >+ tfTrustStoreToUse.setToolTipText(JMeterUtils.getResString("smtp_truststore_tooltip")); >+ this.add(tfTrustStoreToUse, gridBagConstraints); >+ } >+ >+ /** >+ * ActionPerformed-method for checkbox "useLocalTrustStore" >+ * >+ * @param evt >+ * ActionEvent to be handled >+ */ >+ private void cbUseLocalTrustStoreActionPerformed( >+ ActionEvent evt) { >+ final boolean selected = cbUseLocalTrustStore.isSelected(); >+ tfTrustStoreToUse.setEditable(selected); // must follow the checkbox setting >+ if (selected) { >+ cbTrustAllCerts.setSelected(false); // not compatible >+ } >+ } >+ /** >+ * ActionPerformed-method for checkbox "cbTrustAllCerts" >+ * >+ * @param evt >+ * ActionEvent to be handled >+ */ >+ private void cbTrustAllCertsActionPerformed( >+ ActionEvent evt) { >+ final boolean selected = cbTrustAllCerts.isSelected(); >+ if (selected) { >+ cbUseLocalTrustStore.setSelected(false); // not compatible >+ tfTrustStoreToUse.setEditable(false); // must follow the checkbox setting >+ } >+ } >+ >+ /** >+ * ActionPerformed-method for checkbox "enforceStartTLS", empty method >+ * header >+ * >+ * @param evt >+ * ActionEvent to be handled >+ */ >+ private void cbEnforceStartTLSActionPerformed(ActionEvent evt) { >+ } >+ >+ /** >+ * ItemStateChanged-method for radiobutton "securitySettings" >+ * >+ * @param evt >+ * ItemEvent to be handled >+ */ >+ private void rbSecuritySettingsItemStateChanged(ItemEvent evt) { >+ final Object source = evt.getSource(); >+ if (source == rbUseNone) { >+ cbTrustAllCerts.setEnabled(false); >+ cbTrustAllCerts.setSelected(false); >+ cbEnforceStartTLS.setEnabled(false); >+ cbEnforceStartTLS.setSelected(false); >+ cbUseLocalTrustStore.setSelected(false); >+ cbUseLocalTrustStore.setEnabled(false); >+ tfTrustStoreToUse.setEditable(false); >+ } else if (source == rbUseSSL) { >+ cbTrustAllCerts.setEnabled(true); >+ cbEnforceStartTLS.setEnabled(false); >+ cbEnforceStartTLS.setSelected(false); >+ cbUseLocalTrustStore.setEnabled(true); >+ tfTrustStoreToUse.setEditable(false); >+ } else if (source == rbUseStartTLS) { >+ cbTrustAllCerts.setEnabled(true); >+ cbTrustAllCerts.setSelected(false); >+ cbEnforceStartTLS.setEnabled(true); >+ cbUseLocalTrustStore.setEnabled(true); >+ cbUseLocalTrustStore.setSelected(false); >+ tfTrustStoreToUse.setEditable(false); >+ } >+ } >+ /** >+ * Returns if SSL is used to secure the SMTP-connection (checkbox) >+ * >+ * @return true if SSL is used to secure the SMTP-connection >+ */ >+ public boolean isUseSSL() { >+ return rbUseSSL.isSelected(); >+ } >+ >+ /** >+ * Sets SSL to be used to secure the SMTP-connection (checkbox) >+ * >+ * @param useSSL >+ * Use SSL to secure the connection >+ */ >+ public void setUseSSL(boolean useSSL) { >+ rbUseSSL.setSelected(useSSL); >+ } >+ >+ /** >+ * Returns if StartTLS is used to secure the connection (checkbox) >+ * >+ * @return true if StartTLS is used to secure the connection >+ */ >+ public boolean isUseStartTLS() { >+ return rbUseStartTLS.isSelected(); >+ } >+ >+ /** >+ * Sets StartTLS to be used to secure the SMTP-connection (checkbox) >+ * >+ * @param useStartTLS >+ * Use StartTLS to secure the connection >+ */ >+ public void setUseStartTLS(boolean useStartTLS) { >+ rbUseStartTLS.setSelected(useStartTLS); >+ } >+ >+ /** >+ * Returns if StartTLS is enforced (normally, SMTP uses plain >+ * SMTP-connection as fallback if "250-STARTTLS" isn't sent from the >+ * mailserver) (checkbox) >+ * >+ * @return true if StartTLS is enforced >+ */ >+ public boolean isEnforceStartTLS() { >+ return cbEnforceStartTLS.isSelected(); >+ } >+ >+ /** >+ * Enforces StartTLS to secure the SMTP-connection (checkbox) >+ * >+ * @param enforceStartTLS >+ * Enforce the use of StartTLS to secure the connection >+ * @see #isEnforceStartTLS() >+ */ >+ public void setEnforceStartTLS(boolean enforceStartTLS) { >+ cbEnforceStartTLS.setSelected(enforceStartTLS); >+ } >+ /** >+ * Returns if local (pre-installed) truststore is used to avoid >+ * SSL-connection-exceptions (checkbox) >+ * >+ * @return true if a local truststore is used >+ */ >+ public boolean isUseLocalTrustStore() { >+ return cbUseLocalTrustStore.isSelected(); >+ } >+ >+ /** >+ * Set the use of a local (pre-installed) truststore to avoid >+ * SSL-connection-exceptions (checkbox) >+ * >+ * @param useLocalTrustStore >+ * Use local keystore >+ */ >+ public void setUseLocalTrustStore(boolean useLocalTrustStore) { >+ cbUseLocalTrustStore.setSelected(useLocalTrustStore); >+ tfTrustStoreToUse.setEditable(useLocalTrustStore); // ensure correctly set on initial display >+ } >+ >+ /** >+ * Returns the path to the local (pre-installed) truststore to be used to >+ * avoid SSL-connection-exceptions >+ * >+ * @return Path to local truststore >+ */ >+ public String getTrustStoreToUse() { >+ return tfTrustStoreToUse.getText(); >+ } >+ >+ /** >+ * Set the path to local (pre-installed) truststore to be used to avoid >+ * SSL-connection-exceptions >+ * >+ * @param trustStoreToUse >+ * Path to local truststore >+ */ >+ public void setTrustStoreToUse(String trustStoreToUse) { >+ tfTrustStoreToUse.setText(trustStoreToUse); >+ } >+ public void setUseNoSecurity(boolean selected) { >+ rbUseNone.setSelected(selected); >+ } >+ /** >+ * Returns if all certificates are blindly trusted (using according >+ * SocketFactory) (checkbox) >+ * >+ * @return true if all certificates are blindly trusted >+ */ >+ public boolean isTrustAllCerts() { >+ return cbTrustAllCerts.isSelected(); >+ } >+ >+ /** >+ * Enforces JMeter to trust all certificates, no matter what CA is issuer >+ * (checkbox) >+ * >+ * @param trustAllCerts >+ * Trust all certificates >+ * @see #isTrustAllCerts() >+ */ >+ public void setTrustAllCerts(boolean trustAllCerts) { >+ cbTrustAllCerts.setSelected(trustAllCerts); >+ } >+ >+ public void clear() { >+ tfTrustStoreToUse.setText(""); >+ rbUseNone.setSelected(true); >+ } >+ >+ public void configure(TestElement element) { >+ setUseSSL(element.getPropertyAsBoolean(USE_SSL)); >+ setUseStartTLS(element.getPropertyAsBoolean(USE_STARTTLS)); >+ if(!element.getPropertyAsBoolean(USE_STARTTLS) && !element.getPropertyAsBoolean(USE_SSL)){ >+ setUseNoSecurity(true); >+ } >+ setTrustAllCerts(element.getPropertyAsBoolean(SSL_TRUST_ALL_CERTS)); >+ setEnforceStartTLS(element.getPropertyAsBoolean(ENFORCE_STARTTLS)); >+ setUseLocalTrustStore(element.getPropertyAsBoolean(USE_LOCAL_TRUSTSTORE)); >+ setTrustStoreToUse(element.getPropertyAsString(TRUSTSTORE_TO_USE)); >+ } >+ >+ public void modifyTestElement(TestElement te) { >+ te.setProperty(USE_SSL, Boolean.toString(isUseSSL())); >+ te.setProperty(USE_STARTTLS, Boolean.toString(isUseStartTLS())); >+ te.setProperty(SSL_TRUST_ALL_CERTS, Boolean.toString(isTrustAllCerts())); >+ te.setProperty(ENFORCE_STARTTLS, Boolean.toString(isEnforceStartTLS())); >+ te.setProperty(USE_LOCAL_TRUSTSTORE, Boolean.toString(isUseLocalTrustStore())); >+ te.setProperty(TRUSTSTORE_TO_USE, getTrustStoreToUse()); >+ } >+ >+} >Index: src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailReaderSampler.java >=================================================================== >--- src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailReaderSampler.java (revision 964795) >+++ src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailReaderSampler.java (working copy) >@@ -18,6 +18,7 @@ > package org.apache.jmeter.protocol.mail.sampler; > > import java.io.ByteArrayOutputStream; >+import java.io.File; > import java.io.IOException; > import java.io.InputStream; > import java.io.UnsupportedEncodingException; >@@ -37,10 +38,14 @@ > import javax.mail.internet.MimeUtility; > > import org.apache.commons.io.IOUtils; >+import org.apache.jmeter.protocol.smtp.sampler.gui.SecuritySettingsPanel; >+import org.apache.jmeter.protocol.smtp.sampler.protocol.LocalTrustStoreSSLSocketFactory; >+import org.apache.jmeter.protocol.smtp.sampler.protocol.TrustAllSSLSocketFactory; > import org.apache.jmeter.samplers.AbstractSampler; > import org.apache.jmeter.samplers.Entry; > import org.apache.jmeter.samplers.Interruptible; > import org.apache.jmeter.samplers.SampleResult; >+import org.apache.jmeter.services.FileServer; > import org.apache.jmeter.testelement.property.BooleanProperty; > import org.apache.jmeter.testelement.property.IntegerProperty; > import org.apache.jmeter.testelement.property.StringProperty; >@@ -71,8 +76,40 @@ > private static final String RFC_822_DEFAULT_ENCODING = "iso-8859-1"; // RFC 822 uses ascii per default > > public static final String DEFAULT_PROTOCOL = "pop3"; // $NON-NLS-1$ >+ >+ // Use the actual class so the name must be correct. >+ private static final String TRUST_ALL_SOCKET_FACTORY = TrustAllSSLSocketFactory.class.getName(); >+ >+ public boolean isUseLocalTrustStore() { >+ return getPropertyAsBoolean(SecuritySettingsPanel.USE_LOCAL_TRUSTSTORE); >+ } >+ >+ public String getTrustStoreToUse() { >+ return getPropertyAsString(SecuritySettingsPanel.TRUSTSTORE_TO_USE); >+ } >+ >+ >+ public boolean isUseSSL() { >+ return getPropertyAsBoolean(SecuritySettingsPanel.USE_SSL); >+ } >+ >+ >+ public boolean isUseStartTLS() { >+ return getPropertyAsBoolean(SecuritySettingsPanel.USE_STARTTLS); >+ } >+ >+ >+ public boolean isTrustAllCerts() { >+ return getPropertyAsBoolean(SecuritySettingsPanel.SSL_TRUST_ALL_CERTS); >+ } >+ >+ >+ public boolean isEnforceStartTLS() { >+ return getPropertyAsBoolean(SecuritySettingsPanel.ENFORCE_STARTTLS); > >- public static final int ALL_MESSAGES = -1; // special value >+ } >+ >+ public static final int ALL_MESSAGES = -1; // special value > > private volatile boolean busy; > >@@ -103,9 +140,48 @@ > try { > // Create empty properties > Properties props = new Properties(); >+ >+ if (isUseStartTLS()) { >+ props.setProperty("mail.pop3s.starttls.enable", "true"); >+ if (isEnforceStartTLS()){ >+ // Requires JavaMail 1.4.2+ >+ props.setProperty("mail.pop3s.starttls.require", "true"); >+ } >+ } >+ >+ if (isTrustAllCerts()) { >+ if (isUseSSL()) { >+ props.setProperty("mail.pop3s.ssl.socketFactory.class", TRUST_ALL_SOCKET_FACTORY); >+ props.setProperty("mail.pop3s.ssl.socketFactory.fallback", "false"); >+ } else if (isUseStartTLS()) { >+ props.setProperty("mail.pop3s.ssl.socketFactory.class", TRUST_ALL_SOCKET_FACTORY); >+ props.setProperty("mail.pop3s.ssl.socketFactory.fallback", "false"); >+ } >+ } else if (isUseLocalTrustStore()){ >+ File truststore = new File(getTrustStoreToUse()); >+ log.info("load local truststore - try to load truststore from: "+truststore.getAbsolutePath()); >+ if(!truststore.exists()){ >+ log.info("load local truststore -Failed to load truststore from: "+truststore.getAbsolutePath()); >+ truststore = new File(FileServer.getFileServer().getBaseDir(), getTrustStoreToUse()); >+ log.info("load local truststore -Attempting to read truststore from: "+truststore.getAbsolutePath()); >+ if(!truststore.exists()){ >+ log.info("load local truststore -Failed to load truststore from: "+truststore.getAbsolutePath() + ". Local truststore not available, aborting execution."); >+ throw new IOException("Local truststore file not found. Also not available under : " + truststore.getAbsolutePath()); >+ } >+ } >+ if (isUseSSL()) { >+ // Requires JavaMail 1.4.2+ >+ props.put("mail.pop3s.ssl.socketFactory", new LocalTrustStoreSSLSocketFactory(truststore)); >+ props.put("mail.pop3s.ssl.socketFactory.fallback", "false"); >+ } else if (isUseStartTLS()) { >+ // Requires JavaMail 1.4.2+ >+ props.put("mail.pop3s.ssl.socketFactory", new LocalTrustStoreSSLSocketFactory(truststore)); >+ props.put("mail.pop3s.ssl.socketFactory.fallback", "false"); >+ } >+ } > > // Get session >- Session session = Session.getDefaultInstance(props, null); >+ Session session = Session.getInstance(props, null); > > // Get the store > Store store = session.getStore(getServerType()); >Index: src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java >=================================================================== >--- src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java (revision 964795) >+++ src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java (working copy) >@@ -87,15 +87,8 @@ > smtpPanel.setUseEmlMessage(element.getPropertyAsBoolean(SmtpSampler.USE_EML)); > smtpPanel.setEmlMessage(element.getPropertyAsString(SmtpSampler.EML_MESSAGE_TO_SEND)); > >- smtpPanel.setUseSSL(element.getPropertyAsBoolean(SmtpSampler.USE_SSL)); >- smtpPanel.setUseStartTLS(element.getPropertyAsBoolean(SmtpSampler.USE_STARTTLS)); >- if(!element.getPropertyAsBoolean(SmtpSampler.USE_STARTTLS) && !element.getPropertyAsBoolean(SmtpSampler.USE_SSL)){ >- smtpPanel.setUseNoSecurity(true); >- } >- smtpPanel.setTrustAllCerts(element.getPropertyAsBoolean(SmtpSampler.SSL_TRUST_ALL_CERTS)); >- smtpPanel.setEnforceStartTLS(element.getPropertyAsBoolean(SmtpSampler.ENFORCE_STARTTLS)); >- smtpPanel.setUseLocalTrustStore(element.getPropertyAsBoolean(SmtpSampler.USE_LOCAL_TRUSTSTORE)); >- smtpPanel.setTrustStoreToUse(element.getPropertyAsString(SmtpSampler.TRUSTSTORE_TO_USE)); >+ SecuritySettingsPanel secPanel = smtpPanel.getSecuritySettingsPanel(); >+ secPanel.configure(element); > > smtpPanel.setUseAuth(element.getPropertyAsBoolean(SmtpSampler.USE_AUTH)); > smtpPanel.setUsername(element.getPropertyAsString(SmtpSampler.USERNAME)); >@@ -136,13 +129,9 @@ > te.setProperty(SmtpSampler.INCLUDE_TIMESTAMP, Boolean.toString(smtpPanel.isIncludeTimestamp())); > te.setProperty(SmtpSampler.MESSAGE, smtpPanel.getBody()); > te.setProperty(SmtpSampler.ATTACH_FILE, smtpPanel.getAttachments()); >- >- te.setProperty(SmtpSampler.USE_SSL, Boolean.toString(smtpPanel.isUseSSL())); >- te.setProperty(SmtpSampler.USE_STARTTLS, Boolean.toString(smtpPanel.isUseStartTLS())); >- te.setProperty(SmtpSampler.SSL_TRUST_ALL_CERTS, Boolean.toString(smtpPanel.isTrustAllCerts())); >- te.setProperty(SmtpSampler.ENFORCE_STARTTLS, Boolean.toString(smtpPanel.isEnforceStartTLS())); >- te.setProperty(SmtpSampler.USE_LOCAL_TRUSTSTORE, Boolean.toString(smtpPanel.isUseLocalTrustStore())); >- te.setProperty(SmtpSampler.TRUSTSTORE_TO_USE, smtpPanel.getTrustStoreToUse()); >+ >+ SecuritySettingsPanel secPanel = smtpPanel.getSecuritySettingsPanel(); >+ secPanel.modifyTestElement(te); > > te.setProperty(SmtpSampler.USE_EML, smtpPanel.isUseEmlMessage()); > te.setProperty(SmtpSampler.EML_MESSAGE_TO_SEND, smtpPanel.getEmlMessage()); >Index: src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java >=================================================================== >--- src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java (revision 964795) >+++ src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java (working copy) >@@ -22,20 +22,16 @@ > import java.awt.GridBagLayout; > import java.awt.event.ActionEvent; > import java.awt.event.ActionListener; >-import java.awt.event.ItemEvent; >-import java.awt.event.ItemListener; > import java.util.HashMap; > import java.util.Iterator; > import java.util.Map; > > import javax.swing.BorderFactory; >-import javax.swing.ButtonGroup; > import javax.swing.JButton; > import javax.swing.JCheckBox; > import javax.swing.JFileChooser; > import javax.swing.JLabel; > import javax.swing.JPanel; >-import javax.swing.JRadioButton; > import javax.swing.JTextArea; > import javax.swing.JTextField; > >@@ -58,17 +54,9 @@ > private JTextField tfMailFrom; > private JButton browseButton; > private JButton emlBrowseButton; >- private JCheckBox cbTrustAllCerts; >- private JCheckBox cbEnforceStartTLS; > private JCheckBox cbUseAuth; >- private JCheckBox cbUseLocalTrustStore; >- private JRadioButton rbUseNone; >- private JRadioButton rbUseSSL; >- private JRadioButton rbUseStartTLS; >- private ButtonGroup bgSecuritySettings; > private JTextField tfMailServer; > private JTextField tfMailServerPort; >- private JTextField tfTrustStoreToUse; > private JTextField tfMailTo; > private JTextField tfMailToCC; > private JTextField tfMailToBCC; >@@ -84,7 +72,6 @@ > private JLabel jlMailServer; > private JLabel jlAttachFile; > private JLabel jlDutPortStandard; >- private JLabel jlTrustStoreToUse; > private JLabel jlPassword; > private JLabel jlSubject; > private JLabel jlUsername; >@@ -107,6 +94,8 @@ > private Map<JTextField, JTextField> headerFields = new HashMap<JTextField, JTextField>(); > private Map<JButton,JTextField> removeButtons = new HashMap<JButton, JTextField>(); > private int headerGridY = 0; >+ >+ private SecuritySettingsPanel securitySettingsPanel; > > /** > * Creates new form SmtpPanel, standard constructer. Calls >@@ -308,65 +297,6 @@ > tfAuthUsername.setEditable(selected); // ensure correctly set on initial display > } > >- /** >- * Returns if SSL is used to secure the SMTP-connection (checkbox) >- * >- * @return true if SSL is used to secure the SMTP-connection >- */ >- public boolean isUseSSL() { >- return rbUseSSL.isSelected(); >- } >- >- /** >- * Sets SSL to be used to secure the SMTP-connection (checkbox) >- * >- * @param useSSL >- * Use SSL to secure the connection >- */ >- public void setUseSSL(boolean useSSL) { >- rbUseSSL.setSelected(useSSL); >- } >- >- /** >- * Returns if StartTLS is used to secure the connection (checkbox) >- * >- * @return true if StartTLS is used to secure the connection >- */ >- public boolean isUseStartTLS() { >- return rbUseStartTLS.isSelected(); >- } >- >- /** >- * Sets StartTLS to be used to secure the SMTP-connection (checkbox) >- * >- * @param useStartTLS >- * Use StartTLS to secure the connection >- */ >- public void setUseStartTLS(boolean useStartTLS) { >- rbUseStartTLS.setSelected(useStartTLS); >- } >- >- /** >- * Returns if StartTLS is enforced (normally, SMTP uses plain >- * SMTP-connection as fallback if "250-STARTTLS" isn't sent from the >- * mailserver) (checkbox) >- * >- * @return true if StartTLS is enforced >- */ >- public boolean isEnforceStartTLS() { >- return cbEnforceStartTLS.isSelected(); >- } >- >- /** >- * Enforces StartTLS to secure the SMTP-connection (checkbox) >- * >- * @param enforceStartTLS >- * Enforce the use of StartTLS to secure the connection >- * @see #isEnforceStartTLS() >- */ >- public void setEnforceStartTLS(boolean enforceStartTLS) { >- cbEnforceStartTLS.setSelected(enforceStartTLS); >- } > > public boolean isEnableDebug() { > return cbEnableDebug.isSelected(); >@@ -376,70 +306,7 @@ > cbEnableDebug.setSelected(selected); > } > >- /** >- * Returns if all certificates are blindly trusted (using according >- * SocketFactory) (checkbox) >- * >- * @return true if all certificates are blindly trusted >- */ >- public boolean isTrustAllCerts() { >- return cbTrustAllCerts.isSelected(); >- } >- >- /** >- * Enforces JMeter to trust all certificates, no matter what CA is issuer >- * (checkbox) >- * >- * @param trustAllCerts >- * Trust all certificates >- * @see #isTrustAllCerts() >- */ >- public void setTrustAllCerts(boolean trustAllCerts) { >- cbTrustAllCerts.setSelected(trustAllCerts); >- } >- >- /** >- * Returns if local (pre-installed) truststore is used to avoid >- * SSL-connection-exceptions (checkbox) >- * >- * @return true if a local truststore is used >- */ >- public boolean isUseLocalTrustStore() { >- return cbUseLocalTrustStore.isSelected(); >- } >- >- /** >- * Set the use of a local (pre-installed) truststore to avoid >- * SSL-connection-exceptions (checkbox) >- * >- * @param useLocalTrustStore >- * Use local keystore >- */ >- public void setUseLocalTrustStore(boolean useLocalTrustStore) { >- cbUseLocalTrustStore.setSelected(useLocalTrustStore); >- tfTrustStoreToUse.setEditable(useLocalTrustStore); // ensure correctly set on initial display >- } >- >- /** >- * Returns the path to the local (pre-installed) truststore to be used to >- * avoid SSL-connection-exceptions >- * >- * @return Path to local truststore >- */ >- public String getTrustStoreToUse() { >- return tfTrustStoreToUse.getText(); >- } >- >- /** >- * Set the path to local (pre-installed) truststore to be used to avoid >- * SSL-connection-exceptions >- * >- * @param trustStoreToUse >- * Path to local truststore >- */ >- public void setTrustStoreToUse(String trustStoreToUse) { >- tfTrustStoreToUse.setText(trustStoreToUse); >- } >+ > > /** > * Returns if an .eml-message is sent instead of the content of message-text >@@ -522,10 +389,6 @@ > cbMessageSizeStats.setSelected(val); > } > >- public void setUseNoSecurity(boolean selected) { >- rbUseNone.setSelected(selected); >- } >- > public String getPassword() { > return tfAuthPassword.getText(); > } >@@ -584,13 +447,11 @@ > jlDutPortStandard = new JLabel(JMeterUtils.getResString("smtp_default_port")); // $NON-NLS-1$ > jlUsername = new JLabel(JMeterUtils.getResString("smtp_username")); // $NON-NLS-1$ > jlPassword = new JLabel(JMeterUtils.getResString("smtp_password")); // $NON-NLS-1$ >- jlTrustStoreToUse = new JLabel(JMeterUtils.getResString("smtp_truststore")); // $NON-NLS-1$ > jlSubject = new JLabel(JMeterUtils.getResString("smtp_subject")); // $NON-NLS-1$ > jlMessage = new JLabel(JMeterUtils.getResString("smtp_message")); // $NON-NLS-1$ > > tfMailServer = new JTextField(30); > tfMailServerPort = new JTextField(6); >- tfTrustStoreToUse = new JTextField(20); > tfMailFrom = new JTextField(25); > tfMailTo = new JTextField(25); > tfMailToCC = new JTextField(25); >@@ -604,16 +465,10 @@ > taMessage = new JTextArea(5, 20); > > cbUseAuth = new JCheckBox(JMeterUtils.getResString("smtp_useauth")); // $NON-NLS-1$ >- rbUseNone = new JRadioButton(JMeterUtils.getResString("smtp_usenone")); // $NON-NLS-1$ >- rbUseSSL = new JRadioButton(JMeterUtils.getResString("smtp_usessl")); // $NON-NLS-1$ >- rbUseStartTLS = new JRadioButton(JMeterUtils.getResString("smtp_usestarttls")); // $NON-NLS-1$ > >- cbTrustAllCerts = new JCheckBox(JMeterUtils.getResString("smtp_trustall")); // $NON-NLS-1$ >- cbEnforceStartTLS = new JCheckBox(JMeterUtils.getResString("smtp_enforcestarttls")); // $NON-NLS-1$ > cbIncludeTimestamp = new JCheckBox(JMeterUtils.getResString("smtp_timestamp")); // $NON-NLS-1$ > cbMessageSizeStats = new JCheckBox(JMeterUtils.getResString("smtp_messagesize")); // $NON-NLS-1$ > cbEnableDebug = new JCheckBox(JMeterUtils.getResString("smtp_enabledebug")); // $NON-NLS-1$ >- cbUseLocalTrustStore = new JCheckBox(JMeterUtils.getResString("smtp_usetruststore")); // $NON-NLS-1$ > cbUseEmlMessage = new JCheckBox(JMeterUtils.getResString("smtp_eml")); // $NON-NLS-1$ > > attachmentFileChooser = new JFileChooser(); >@@ -780,103 +635,11 @@ > /* > * Security Settings > */ >- JPanel panelSecuritySettings = new JPanel(new GridBagLayout()); >- panelSecuritySettings.setBorder(BorderFactory.createTitledBorder( >- BorderFactory.createEtchedBorder(), >- JMeterUtils.getResString("smtp_security_settings"))); // $NON-NLS-1$ >- >- rbUseNone.setSelected(true); >- bgSecuritySettings = new ButtonGroup(); >- bgSecuritySettings.add(rbUseNone); >- bgSecuritySettings.add(rbUseSSL); >- bgSecuritySettings.add(rbUseStartTLS); >- >- gridBagConstraints.gridx = 0; >- gridBagConstraints.gridy = 0; >- panelSecuritySettings.add(rbUseNone, gridBagConstraints); >- >- gridBagConstraints.gridx = 1; >- gridBagConstraints.gridy = 0; >- panelSecuritySettings.add(rbUseSSL, gridBagConstraints); >- >- gridBagConstraints.gridx = 2; >- gridBagConstraints.gridy = 0; >- panelSecuritySettings.add(rbUseStartTLS, gridBagConstraints); >- >- rbUseNone.addItemListener(new ItemListener() { >- public void itemStateChanged(ItemEvent evt) { >- rbSecuritySettingsItemStateChanged(evt); >- } >- }); >- rbUseSSL.addItemListener(new ItemListener() { >- public void itemStateChanged(ItemEvent evt) { >- rbSecuritySettingsItemStateChanged(evt); >- } >- }); >- rbUseStartTLS.addItemListener(new ItemListener() { >- public void itemStateChanged(ItemEvent evt) { >- rbSecuritySettingsItemStateChanged(evt); >- } >- }); >- >- cbTrustAllCerts.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); >- cbTrustAllCerts.setMargin(new java.awt.Insets(0, 0, 0, 0)); >- cbTrustAllCerts.setEnabled(false); >- cbTrustAllCerts.setToolTipText(JMeterUtils.getResString("smtp_trustall_tooltip")); // $NON-NLS-1$ >- cbTrustAllCerts.addActionListener(new ActionListener() { >- public void actionPerformed(ActionEvent evt) { >- cbTrustAllCertsActionPerformed(evt); >- } >- }); >- >- gridBagConstraints.gridx = 0; >- gridBagConstraints.gridy = 1; >- panelSecuritySettings.add(cbTrustAllCerts, gridBagConstraints); >- >- cbEnforceStartTLS.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); >- cbEnforceStartTLS.setMargin(new java.awt.Insets(0, 0, 0, 0)); >- cbEnforceStartTLS.setEnabled(false); >- cbEnforceStartTLS.addActionListener(new ActionListener() { >- public void actionPerformed(ActionEvent evt) { >- cbEnforceStartTLSActionPerformed(evt); >- } >- }); >- cbEnforceStartTLS.setToolTipText(JMeterUtils.getResString("smtp_enforcestarttls_tooltip")); // $NON-NLS-1$ >- >- gridBagConstraints.gridx = 2; >- gridBagConstraints.gridy = 1; >- panelSecuritySettings.add(cbEnforceStartTLS, gridBagConstraints); >- >- cbUseLocalTrustStore.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); >- cbUseLocalTrustStore.setMargin(new java.awt.Insets(0, 0, 0, 0)); >- cbUseLocalTrustStore.setEnabled(false); >- cbUseLocalTrustStore.addActionListener(new ActionListener() { >- public void actionPerformed(ActionEvent evt) { >- cbUseLocalTrustStoreActionPerformed(evt); >- } >- }); >- >- cbUseLocalTrustStore.setToolTipText(JMeterUtils.getResString("smtp_usetruststore_tooltip")); // $NON-NLS-1$ >- >- gridBagConstraints.gridx = 1; >- gridBagConstraints.gridy = 1; >- gridBagConstraints.gridwidth = 2; >- panelSecuritySettings.add(cbUseLocalTrustStore, gridBagConstraints); >- >- gridBagConstraints.gridx = 0; >- gridBagConstraints.gridy = 2; >- gridBagConstraints.gridwidth = 1; >- jlTrustStoreToUse.setToolTipText(JMeterUtils.getResString("smtp_truststore_tooltip")); >- panelSecuritySettings.add(jlTrustStoreToUse, gridBagConstraints); >- >- gridBagConstraints.gridx = 1; >- gridBagConstraints.gridy = 2; >- tfTrustStoreToUse.setToolTipText(JMeterUtils.getResString("smtp_truststore_tooltip")); >- panelSecuritySettings.add(tfTrustStoreToUse, gridBagConstraints); >+ securitySettingsPanel = new SecuritySettingsPanel(); > > gridBagConstraintsMain.gridx = 0; > gridBagConstraintsMain.gridy = 3; >- add(panelSecuritySettings, gridBagConstraintsMain); >+ add(securitySettingsPanel, gridBagConstraintsMain); > > /* > * (non-Javadoc) Message Settings >@@ -1037,35 +800,7 @@ > tfAuthPassword.setEditable(cbUseAuth.isSelected()); > } > >- /** >- * ActionPerformed-method for checkbox "useLocalTrustStore" >- * >- * @param evt >- * ActionEvent to be handled >- */ >- private void cbUseLocalTrustStoreActionPerformed( >- ActionEvent evt) { >- final boolean selected = cbUseLocalTrustStore.isSelected(); >- tfTrustStoreToUse.setEditable(selected); // must follow the checkbox setting >- if (selected) { >- cbTrustAllCerts.setSelected(false); // not compatible >- } >- } > >- /** >- * ActionPerformed-method for checkbox "cbTrustAllCerts" >- * >- * @param evt >- * ActionEvent to be handled >- */ >- private void cbTrustAllCertsActionPerformed( >- ActionEvent evt) { >- final boolean selected = cbTrustAllCerts.isSelected(); >- if (selected) { >- cbUseLocalTrustStore.setSelected(false); // not compatible >- tfTrustStoreToUse.setEditable(false); // must follow the checkbox setting >- } >- } > > /** > * ActionPerformed-method for filechoser "attachmentFileChoser", creates >@@ -1147,47 +882,7 @@ > emlFileChooser.showOpenDialog(this); > } > >- /** >- * ActionPerformed-method for checkbox "enforceStartTLS", empty method >- * header >- * >- * @param evt >- * ActionEvent to be handled >- */ >- private void cbEnforceStartTLSActionPerformed(ActionEvent evt) { >- } > >- /** >- * ItemStateChanged-method for radiobutton "securitySettings" >- * >- * @param evt >- * ItemEvent to be handled >- */ >- private void rbSecuritySettingsItemStateChanged(ItemEvent evt) { >- final Object source = evt.getSource(); >- if (source == rbUseNone) { >- cbTrustAllCerts.setEnabled(false); >- cbTrustAllCerts.setSelected(false); >- cbEnforceStartTLS.setEnabled(false); >- cbEnforceStartTLS.setSelected(false); >- cbUseLocalTrustStore.setSelected(false); >- cbUseLocalTrustStore.setEnabled(false); >- tfTrustStoreToUse.setEditable(false); >- } else if (source == rbUseSSL) { >- cbTrustAllCerts.setEnabled(true); >- cbEnforceStartTLS.setEnabled(false); >- cbEnforceStartTLS.setSelected(false); >- cbUseLocalTrustStore.setEnabled(true); >- tfTrustStoreToUse.setEditable(false); >- } else if (source == rbUseStartTLS) { >- cbTrustAllCerts.setEnabled(true); >- cbTrustAllCerts.setSelected(false); >- cbEnforceStartTLS.setEnabled(true); >- cbUseLocalTrustStore.setEnabled(true); >- cbUseLocalTrustStore.setSelected(false); >- tfTrustStoreToUse.setEditable(false); >- } >- } > > /** > * Reset all the Gui fields. >@@ -1210,8 +905,7 @@ > tfMailToBCC.setText(""); > tfMailToCC.setText(""); > tfSubject.setText(""); >- tfTrustStoreToUse.setText(""); >- rbUseNone.setSelected(true); >+ securitySettingsPanel.clear(); > clearHeaderFields(); > validate(); > } >@@ -1293,4 +987,11 @@ > validate(); > } > } >+ public SecuritySettingsPanel getSecuritySettingsPanel() { >+ return securitySettingsPanel; >+ } >+ >+ public void setSecuritySettingsPanel(SecuritySettingsPanel securitySettingsPanel) { >+ this.securitySettingsPanel = securitySettingsPanel; >+ } > } >\ No newline at end of file >Index: src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java >=================================================================== >--- src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java (revision 964795) >+++ src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java (working copy) >@@ -31,6 +31,7 @@ > import javax.mail.internet.AddressException; > import javax.mail.internet.InternetAddress; > >+import org.apache.jmeter.protocol.smtp.sampler.gui.SecuritySettingsPanel; > import org.apache.jmeter.protocol.smtp.sampler.protocol.SendMailCommand; > import org.apache.jmeter.protocol.smtp.sampler.tools.CounterOutputStream; > import org.apache.jmeter.samplers.AbstractSampler; >@@ -65,18 +66,13 @@ > public final static String RECEIVER_BCC = "SMTPSampler.receiverBCC"; // $NON-NLS-1$ > > public final static String SUBJECT = "SMTPSampler.subject"; // $NON-NLS-1$ >+ public final static String EMPTY_SUBJECT = "SMTPSampler.emptySubject"; // $NON-NLS-1$ > public final static String MESSAGE = "SMTPSampler.message"; // $NON-NLS-1$ > public final static String INCLUDE_TIMESTAMP = "SMTPSampler.include_timestamp"; // $NON-NLS-1$ > public final static String ATTACH_FILE = "SMTPSampler.attachFile"; // $NON-NLS-1$ > public final static String MESSAGE_SIZE_STATS = "SMTPSampler.messageSizeStatistics"; // $NON-NLS-1$ > public static final String HEADER_FIELDS = "SMTPSampler.headerFields"; // $NON-NLS-1$ > >- public final static String USE_SSL = "SMTPSampler.useSSL"; // $NON-NLS-1$ >- public final static String USE_STARTTLS = "SMTPSampler.useStartTLS"; // $NON-NLS-1$ >- public final static String SSL_TRUST_ALL_CERTS = "SMTPSampler.trustAllCerts"; // $NON-NLS-1$ >- public final static String ENFORCE_STARTTLS = "SMTPSampler.enforceStartTLS"; // $NON-NLS-1$ >- public final static String USE_LOCAL_TRUSTSTORE = "SMTPSampler.useLocalTrustStore"; // $NON-NLS-1$ >- public final static String TRUSTSTORE_TO_USE = "SMTPSampler.trustStoreToUse"; // $NON-NLS-1$ > public final static String USE_EML = "SMTPSampler.use_eml"; // $NON-NLS-1$ > public final static String EML_MESSAGE_TO_SEND = "SMTPSampler.emlMessageToSend"; // $NON-NLS-1$ > public static final String ENABLE_DEBUG = "SMTPSampler.enableDebug"; // $NON-NLS-1$ >@@ -106,17 +102,17 @@ > instance.setSmtpServer(getPropertyAsString(SmtpSampler.SERVER)); > instance.setSmtpPort(getPropertyAsString(SmtpSampler.SERVER_PORT)); > >- instance.setUseSSL(getPropertyAsBoolean(USE_SSL)); >- instance.setUseStartTLS(getPropertyAsBoolean(USE_STARTTLS)); >- instance.setTrustAllCerts(getPropertyAsBoolean(SSL_TRUST_ALL_CERTS)); >- instance.setEnforceStartTLS(getPropertyAsBoolean(ENFORCE_STARTTLS)); >+ instance.setUseSSL(getPropertyAsBoolean(SecuritySettingsPanel.USE_SSL)); >+ instance.setUseStartTLS(getPropertyAsBoolean(SecuritySettingsPanel.USE_STARTTLS)); >+ instance.setTrustAllCerts(getPropertyAsBoolean(SecuritySettingsPanel.SSL_TRUST_ALL_CERTS)); >+ instance.setEnforceStartTLS(getPropertyAsBoolean(SecuritySettingsPanel.ENFORCE_STARTTLS)); > > instance.setUseAuthentication(getPropertyAsBoolean(USE_AUTH)); > instance.setUsername(getPropertyAsString(USERNAME)); > instance.setPassword(getPropertyAsString(PASSWORD)); > >- instance.setUseLocalTrustStore(getPropertyAsBoolean(USE_LOCAL_TRUSTSTORE)); >- instance.setTrustStoreToUse(getPropertyAsString(TRUSTSTORE_TO_USE)); >+ instance.setUseLocalTrustStore(getPropertyAsBoolean(SecuritySettingsPanel.USE_LOCAL_TRUSTSTORE)); >+ instance.setTrustStoreToUse(getPropertyAsString(SecuritySettingsPanel.TRUSTSTORE_TO_USE)); > instance.setEmlMessage(getPropertyAsString(EML_MESSAGE_TO_SEND)); > instance.setUseEmlMessage(getPropertyAsBoolean(USE_EML)); > >@@ -135,12 +131,20 @@ > instance.setReceiverTo(getPropNameAsAddresses(receiverTo)); > instance.setReceiverCC(getPropNameAsAddresses(receiverCC)); > instance.setReceiverBCC(getPropNameAsAddresses(receiverBcc)); >- >- instance.setSubject(getPropertyAsString(SUBJECT) >- + (getPropertyAsBoolean(INCLUDE_TIMESTAMP) ? >- " <<< current timestamp: " + new Date().getTime() + " >>>" >- : "" >- )); >+ >+ if(getPropertyAsBoolean(EMPTY_SUBJECT)){ >+ instance.setSubject(null); >+ }else{ >+ String subject = getPropertyAsString(SUBJECT); >+ if (getPropertyAsBoolean(INCLUDE_TIMESTAMP)){ >+ StringBuffer sb = new StringBuffer(subject); >+ sb.append(" <<< current timestamp: "); >+ sb.append(new Date().getTime()); >+ sb.append(" >>>"); >+ subject = sb.toString(); >+ } >+ instance.setSubject(subject); >+ } > > if (!getPropertyAsBoolean(USE_EML)) { // part is only needed if we > // don't send an .eml-file >Index: src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java >=================================================================== >--- src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java (revision 964795) >+++ src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java (working copy) >@@ -39,6 +39,7 @@ > import org.apache.jmeter.gui.util.HorizontalPanel; > import org.apache.jmeter.gui.util.VerticalPanel; > import org.apache.jmeter.protocol.mail.sampler.MailReaderSampler; >+import org.apache.jmeter.protocol.smtp.sampler.gui.SecuritySettingsPanel; > import org.apache.jmeter.samplers.gui.AbstractSamplerGui; > import org.apache.jmeter.testelement.TestElement; > import org.apache.jmeter.util.JMeterUtils; >@@ -95,6 +96,8 @@ > private final String STOREMIME = JMeterUtils.getResString("mail_reader_storemime");// $NON-NLS-1$ > > private static final String INBOX = "INBOX"; // $NON-NLS-1$ >+ >+ private SecuritySettingsPanel securitySettingsPanel; > > public MailReaderSamplerGui() { > init(); >@@ -126,6 +129,7 @@ > } > deleteBox.setSelected(mrs.getDeleteMessages()); > storeMimeMessageBox.setSelected(mrs.isStoreMimeMessage()); >+ securitySettingsPanel.configure(element); > super.configure(element); > } > >@@ -160,6 +164,8 @@ > } > mrs.setDeleteMessages(deleteBox.isSelected()); > mrs.setStoreMimeMessage(storeMimeMessageBox.isSelected()); >+ >+ securitySettingsPanel.modifyTestElement(te); > } > > /* >@@ -224,18 +230,21 @@ > > storeMimeMessageBox = new JCheckBox(STOREMIME); > >+ securitySettingsPanel = new SecuritySettingsPanel(); >+ > JPanel settings = new VerticalPanel(); > settings.add(Box.createVerticalStrut(5)); > settings.add(settingsPanel); > settings.add(numMessagesPanel); > settings.add(deleteBox); > settings.add(storeMimeMessageBox); >+ settings.add(securitySettingsPanel); > > add(makeTitlePanel(), BorderLayout.NORTH); > add(settings, BorderLayout.CENTER); > } > >- private void addField(JPanel panel, JLabel label, JComponent field, GridBagConstraints gbc) { >+ private void addField(JPanel panel, JLabel label, JComponent field, GridBagConstraints gbc) { > gbc.fill=GridBagConstraints.NONE; > gbc.anchor = GridBagConstraints.LINE_END; > panel.add(label, gbc); >Index: xdocs/usermanual/component_reference.xml >=================================================================== >--- xdocs/usermanual/component_reference.xml (revision 964795) >+++ xdocs/usermanual/component_reference.xml (working copy) >@@ -1454,6 +1454,16 @@ > If not, the message headers are stored as Response Headers. > A few headers are stored (Date, To, From, Subject) in the body. > </property> >+<property name="Use no security features" required="">Indicates that the connection to the server does not use any security protocol.</property> >+<property name="Use SSL" required="">Indicates that the connection to the server must use the SSL protocol.</property> >+<property name="Use StartTLS" required="">Indicates that the connection to the server should attempt to start the TLS protocol.</property> >+<property name="Enforce StartTLS" required="">If the server does not start the TLS protocol the connection will be terminated.</property> >+<property name="Trust All Certificates" required="">When selected it will accept all certificates independent of the CA.</property> >+<property name="Use local truststore" required="">When selected it will only accept certificates that are locally trusted.</property> >+<property name="Local truststore" required="">Path to file containing the trusted certificates. >+Relative paths are resolved against the current directory. >+<br />Failing that, against the directory containing the test script (JMX file). >+</property> > </properties> > <p> > Messages are stored as subsamples of the main sampler.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 49603
: 25787