Author: sebb
Date: Mon Aug 16 22:15:39 2010
New Revision: 986140
URL: http://svn.apache.org/viewvc?rev=986140&view=rev
Log:
Bug 49603 - Allow accepting expired certificates on Mail Reader Sampler
Added:
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
(with props)
Modified:
jakarta/jmeter/trunk/docs/images/screenshots/mailreader_sampler.png
jakarta/jmeter/trunk/docs/images/screenshots/smtp_sampler.png
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailReaderSampler.java
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
jakarta/jmeter/trunk/xdocs/changes.xml
jakarta/jmeter/trunk/xdocs/images/screenshots/mailreader_sampler.png
jakarta/jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png
jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jakarta/jmeter/trunk/docs/images/screenshots/mailreader_sampler.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/mailreader_sampler.png?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
Binary files - no diff available.
Modified: jakarta/jmeter/trunk/docs/images/screenshots/smtp_sampler.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/smtp_sampler.png?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
Binary files - no diff available.
Modified:
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailReaderSampler.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailReaderSampler.java?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailReaderSampler.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/MailReaderSampler.java
Mon Aug 16 22:15:39 2010
@@ -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.MimeMultipart
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 @@ public class MailReaderSampler extends A
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 static final int ALL_MESSAGES = -1; // special value
+ 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
private volatile boolean busy;
@@ -103,9 +140,48 @@ public class MailReaderSampler extends A
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());
Modified:
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/mail/sampler/gui/MailReaderSamplerGui.java
Mon Aug 16 22:15:39 2010
@@ -39,6 +39,7 @@ import javax.swing.event.ChangeListener;
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 @@ public class MailReaderSamplerGui extend
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 @@ public class MailReaderSamplerGui extend
}
deleteBox.setSelected(mrs.getDeleteMessages());
storeMimeMessageBox.setSelected(mrs.isStoreMimeMessage());
+ securitySettingsPanel.configure(element);
super.configure(element);
}
@@ -160,6 +164,8 @@ public class MailReaderSamplerGui extend
}
mrs.setDeleteMessages(deleteBox.isSelected());
mrs.setStoreMimeMessage(storeMimeMessageBox.isSelected());
+
+ securitySettingsPanel.modifyTestElement(te);
}
/*
@@ -224,18 +230,21 @@ public class MailReaderSamplerGui extend
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);
Modified:
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java
Mon Aug 16 22:15:39 2010
@@ -31,6 +31,7 @@ import javax.mail.MessagingException;
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;
@@ -72,12 +73,6 @@ public class SmtpSampler extends Abstrac
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$
@@ -107,17 +102,17 @@ public class SmtpSampler extends Abstrac
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));
Added:
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java?rev=986140&view=auto
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
(added)
+++
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
Mon Aug 16 22:15:39 2010
@@ -0,0 +1,413 @@
+/*
+ * 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{
+
+ private static final long serialVersionUID = 1L;
+
+ //++JMX attribute names - do not change the values!
+ // These were moved from SMTPSampler, which is why the prefix is still
SMTSampler
+ 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$
+ //--JMX attribute names
+
+ 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());
+ }
+
+}
Propchange:
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SecuritySettingsPanel.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified:
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpPanel.java
Mon Aug 16 22:15:39 2010
@@ -22,20 +22,16 @@ 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 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 @@ public class SmtpPanel extends JPanel {
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 @@ public class SmtpPanel extends JPanel {
private JLabel jlMailServer;
private JLabel jlAttachFile;
private JLabel jlDutPortStandard;
- private JLabel jlTrustStoreToUse;
private JLabel jlPassword;
private JLabel jlSubject;
private JLabel jlUsername;
@@ -108,6 +95,8 @@ public class SmtpPanel extends JPanel {
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
@@ -328,65 +317,6 @@ public class SmtpPanel extends JPanel {
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();
@@ -396,70 +326,7 @@ public class SmtpPanel extends JPanel {
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
@@ -542,10 +409,6 @@ public class SmtpPanel extends JPanel {
cbMessageSizeStats.setSelected(val);
}
- public void setUseNoSecurity(boolean selected) {
- rbUseNone.setSelected(selected);
- }
-
public String getPassword() {
return tfAuthPassword.getText();
}
@@ -604,13 +467,11 @@ public class SmtpPanel extends JPanel {
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);
@@ -631,16 +492,10 @@ public class SmtpPanel extends JPanel {
});
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();
@@ -807,103 +662,11 @@ public class SmtpPanel extends JPanel {
/*
* 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
@@ -1071,35 +834,7 @@ public class SmtpPanel extends JPanel {
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
@@ -1181,47 +916,7 @@ public class SmtpPanel extends JPanel {
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.
@@ -1244,9 +939,8 @@ public class SmtpPanel extends JPanel {
tfMailToBCC.setText("");
tfMailToCC.setText("");
tfSubject.setText("");
- tfTrustStoreToUse.setText("");
- rbUseNone.setSelected(true);
cbSuppressSubject.setSelected(false);
+ securitySettingsPanel.clear();
clearHeaderFields();
validate();
}
@@ -1310,6 +1004,13 @@ public class SmtpPanel extends JPanel {
validate();
return removeButton;
}
+ public SecuritySettingsPanel getSecuritySettingsPanel() {
+ return securitySettingsPanel;
+ }
+
+ public void setSecuritySettingsPanel(SecuritySettingsPanel
securitySettingsPanel) {
+ this.securitySettingsPanel = securitySettingsPanel;
+ }
private void removeHeaderActionPerformed(ActionEvent evt){
final Object source = evt.getSource();
Modified:
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/gui/SmtpSamplerGui.java
Mon Aug 16 22:15:39 2010
@@ -88,15 +88,8 @@ public class SmtpSamplerGui extends Abst
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));
@@ -138,13 +131,9 @@ public class SmtpSamplerGui extends Abst
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());
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Mon Aug 16 22:15:39 2010
@@ -111,6 +111,7 @@ To override the default local language f
<h3>Other samplers</h3>
<ul>
<li>Bug 49622 - Allow sending messages without a subject (SMTP Sampler)</li>
+<li>Bug 49603 - Allow accepting expired certificates on Mail Reader
Sampler</li>
</ul>
<h3>Controllers</h3>
Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/mailreader_sampler.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/mailreader_sampler.png?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
Binary files - no diff available.
Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/smtp_sampler.png?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
Binary files - no diff available.
Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=986140&r1=986139&r2=986140&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Mon Aug 16
22:15:39 2010
@@ -1429,7 +1429,7 @@ This is to allow the setUp/tearDown meth
</p>
</component>
-<component name="Mail Reader Sampler" index="§-num;.1.17" width="399"
height="306" screenshot="mailreader_sampler.png">
+<component name="Mail Reader Sampler" index="§-num;.1.17" width="547"
height="409" screenshot="mailreader_sampler.png">
<description>
<p>
The Mail Reader Sampler can read (and optionally delete) mail messages using
POP3(S) or IMAP(S) protocols.
@@ -1454,6 +1454,16 @@ If so, then the entire raw message is st
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.
@@ -1495,7 +1505,7 @@ In non-GUI mode, JMeter will exit if som
</component>
-<component name="SMTP Sampler" index="§-num;.1.19" width="644"
height="759" screenshot="smtp_sampler.png">
+<component name="SMTP Sampler" index="§-num;.1.19" width="625"
height="777" screenshot="smtp_sampler.png">
<description>
<p>
The SMTP Sampler can send mail messages using SMTP/SMTPS protocol.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]