You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2013/08/02 22:57:18 UTC

svn commit: r1509856 - in /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http: control/AuthManager.java gui/AuthPanel.java

Author: pmouawad
Date: Fri Aug  2 20:57:17 2013
New Revision: 1509856

URL: http://svn.apache.org/r1509856
Log:
Bug 53480 - Add Kerberos support to Http Sampler (HttpClient4)
Add ability to clear kerberos subjects on each Main Loop iteration
Bugzilla Id: 53480

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java?rev=1509856&r1=1509855&r2=1509856&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java Fri Aug  2 20:57:17 2013
@@ -44,7 +44,10 @@ import org.apache.http.impl.auth.SPNegoS
 import org.apache.http.impl.client.AbstractHttpClient;
 import org.apache.jmeter.config.ConfigElement;
 import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.engine.event.LoopIterationEvent;
 import org.apache.jmeter.protocol.http.util.HTTPConstants;
+import org.apache.jmeter.testelement.TestIterationListener;
+import org.apache.jmeter.testelement.TestStateListener;
 import org.apache.jmeter.testelement.property.CollectionProperty;
 import org.apache.jmeter.testelement.property.PropertyIterator;
 import org.apache.jmeter.testelement.property.TestElementProperty;
@@ -61,11 +64,13 @@ import org.apache.log.Logger;
  * user a username to use and pass the appropriate password.
  *
  */
-public class AuthManager extends ConfigTestElement implements Serializable {
+public class AuthManager extends ConfigTestElement implements TestStateListener, TestIterationListener, Serializable {
     private static final long serialVersionUID = 234L;
 
     private static final Logger log = LoggingManager.getLoggerForClass();
 
+    private static final String CLEAR = "AuthManager.clearEachIteration";// $NON-NLS-1$
+
     private static final String AUTH_LIST = "AuthManager.auth_list"; //$NON-NLS-1$
 
     private static final String[] COLUMN_RESOURCE_NAMES = {
@@ -89,6 +94,8 @@ public class AuthManager extends ConfigT
 
     private static final Credentials USE_JAAS_CREDENTIALS = new NullCredentials();
 
+    private static final boolean DEFAULT_CLEAR_VALUE = false;
+
     public enum Mechanism {
         BASIC_DIGEST, KERBEROS;
     }
@@ -342,6 +349,18 @@ public class AuthManager extends ConfigT
     }
 
     /**
+     *
+     * @return true if kerberos auth must be cleared on each mail loop iteration 
+     */
+    public boolean getClearEachIteration() {
+        return getPropertyAsBoolean(CLEAR, DEFAULT_CLEAR_VALUE);
+    }
+
+    public void setClearEachIteration(boolean clear) {
+        setProperty(CLEAR, clear, DEFAULT_CLEAR_VALUE);
+    }
+
+    /**
      * Return the number of records.
      */
     public int getAuthCount() {
@@ -382,4 +401,34 @@ public class AuthManager extends ConfigT
             }
         }
     }
+
+    /** {@inheritDoc} */
+    @Override
+    public void testStarted() {
+        kerberosManager.clearSubjects();
+    }
+    
+    /** {@inheritDoc} */
+    @Override
+    public void testEnded() {
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void testStarted(String host) {
+        testStarted();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void testEnded(String host) {
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void testIterationStart(LoopIterationEvent event) {
+        if (getClearEachIteration()) {
+            kerberosManager.clearSubjects();
+        }
+    }
 }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java?rev=1509856&r1=1509855&r2=1509856&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java Fri Aug  2 20:57:17 2013
@@ -28,6 +28,7 @@ import java.io.IOException;
 import javax.swing.BorderFactory;
 import javax.swing.DefaultCellEditor;
 import javax.swing.JButton;
+import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JFileChooser;
 import javax.swing.JPanel;
@@ -51,6 +52,7 @@ import org.apache.jmeter.protocol.http.c
 import org.apache.jmeter.testelement.TestElement;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.gui.GuiUtils;
+import org.apache.jorphan.gui.layout.VerticalLayout;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
 
@@ -74,6 +76,8 @@ public class AuthPanel extends AbstractC
 
     private InnerTableModel tableModel;
 
+    private JCheckBox clearEachIteration;
+
     /**
      * A table to show the authentication information.
      */
@@ -99,6 +103,7 @@ public class AuthPanel extends AbstractC
     public TestElement createTestElement() {
         AuthManager authMan = tableModel.manager;
         configureTestElement(authMan);
+        authMan.setClearEachIteration(clearEachIteration.isSelected());
         return (TestElement) authMan.clone();
     }
 
@@ -110,8 +115,10 @@ public class AuthPanel extends AbstractC
     @Override
     public void modifyTestElement(TestElement el) {
         GuiUtils.stopTableEditing(authTable);
-        el.clear();
-        el.addTestElement((TestElement) tableModel.manager.clone());
+        AuthManager authManager = (AuthManager) el;
+        authManager.clear();
+        authManager.addTestElement((TestElement) tableModel.manager.clone());
+        authManager.setClearEachIteration(clearEachIteration.isSelected());
         configureTestElement(el);
     }
 
@@ -125,6 +132,7 @@ public class AuthPanel extends AbstractC
         tableModel.clearData();
         deleteButton.setEnabled(false);
         saveButton.setEnabled(false);
+        clearEachIteration.setSelected(false);
     }
 
     @Override
@@ -132,6 +140,7 @@ public class AuthPanel extends AbstractC
         super.configure(el);
         tableModel.manager.clear();
         tableModel.manager.addTestElement((AuthManager) el.clone());
+        clearEachIteration.setSelected(((AuthManager) el).getClearEachIteration());
         if (tableModel.getRowCount() != 0) {
             deleteButton.setEnabled(true);
             saveButton.setEnabled(true);
@@ -150,7 +159,22 @@ public class AuthPanel extends AbstractC
         setLayout(new BorderLayout());
         setBorder(makeBorder());
 
-        add(makeTitlePanel(), BorderLayout.NORTH);
+        JPanel northPanel = new JPanel();
+        northPanel.setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
+        northPanel.add(makeTitlePanel());
+
+        JPanel optionsPane = new JPanel();
+        optionsPane.setBorder(BorderFactory.createTitledBorder(
+                BorderFactory.createEtchedBorder(),
+                JMeterUtils.getResString("auth_manager_options"))); // $NON-NLS-1$
+        optionsPane.setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
+        clearEachIteration = 
+                new JCheckBox(JMeterUtils.getResString("auth_manager_clear_per_iter"), false); //$NON-NLS-1$
+        optionsPane.add(clearEachIteration);
+        northPanel.add(optionsPane);
+        add(northPanel, BorderLayout.NORTH);
+
+        
         add(createAuthTablePanel(), BorderLayout.CENTER);
     }