You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2007/02/09 01:28:07 UTC
svn commit: r505096 - in /jakarta/jmeter/branches/rel-2-2: bin/testfiles/
src/core/org/apache/jmeter/resources/
src/protocol/http/org/apache/jmeter/protocol/http/control/
src/protocol/http/org/apache/jmeter/protocol/http/gui/
test/src/org/apache/jmeter...
Author: sebb
Date: Thu Feb 8 16:28:06 2007
New Revision: 505096
URL: http://svn.apache.org/viewvc?view=rev&rev=505096
Log:
Add Domain and Realm to Authorisation Manager
Modified:
jakarta/jmeter/branches/rel-2-2/bin/testfiles/TestAuth.txt
jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/Authorization.java
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java
jakarta/jmeter/branches/rel-2-2/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml
Modified: jakarta/jmeter/branches/rel-2-2/bin/testfiles/TestAuth.txt
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/bin/testfiles/TestAuth.txt?view=diff&rev=505096&r1=505095&r2=505096
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/bin/testfiles/TestAuth.txt (original)
+++ jakarta/jmeter/branches/rel-2-2/bin/testfiles/TestAuth.txt Thu Feb 8 16:28:06 2007
@@ -7,3 +7,4 @@
http://a.b.c/1/1 login11 password11
http://a.b.c/22 login22 password22
http://a.b.c/ login password
+http://d.e.f/ user pass domain realm
Modified: jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties?view=diff&rev=505096&r1=505095&r2=505096
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jakarta/jmeter/branches/rel-2-2/src/core/org/apache/jmeter/resources/messages.properties Thu Feb 8 16:28:06 2007
@@ -503,6 +503,7 @@
ramp_up=Ramp-Up Period (in seconds)\:
random_control_title=Random Controller
random_order_control_title=Random Order Controller
+realm=Realm
read_response_message=Read response is not checked. To see the response, please check the box in the sampler.
read_response_note=If read response is unchecked, the sampler will not read the response
read_response_note2=or set the SampleResult. This improves performance, but it means
Modified: jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java?view=diff&rev=505096&r1=505095&r2=505096
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java (original)
+++ jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java Thu Feb 8 16:28:06 2007
@@ -48,18 +48,29 @@
* format of the authorization file is: URL user pass where URL is an HTTP URL,
* user a username to use and pass the appropriate password.
*
- * @author <a href="mailto:luta.raphael@networks.vivendi.com">Raphael Luta</a>
- * @version $Revision$
+ * author <a href="mailto:luta.raphael@networks.vivendi.com">Raphael Luta</a>
*/
public class AuthManager extends ConfigTestElement implements ConfigElement, Serializable {
private static final Logger log = LoggingManager.getLoggerForClass();
private final static String AUTH_LIST = "AuthManager.auth_list";
- private final static int columnCount = 3;
+ private final static String[] columnNames = {
+ JMeterUtils.getResString("auth_base_url"),
+ JMeterUtils.getResString("username"),
+ JMeterUtils.getResString("password"),
+ JMeterUtils.getResString("domain"),
+ JMeterUtils.getResString("realm"),
+ };
+
+ // Column numbers - must agree with order above
+ public final static int COL_URL = 0;
+ public final static int COL_USERNAME = 1;
+ public final static int COL_PASSWORD = 2;
+ public final static int COL_DOMAIN = 3;
+ public final static int COL_REALM = 4;
- private final static String[] columnNames = { JMeterUtils.getResString("auth_base_url"),
- JMeterUtils.getResString("username"), JMeterUtils.getResString("password") };
+ private final static int columnCount = columnNames.length;
/**
* Default Constructor.
@@ -76,8 +87,8 @@
/**
* Update an authentication record.
*/
- public void set(int index, String url, String user, String pass) {
- Authorization auth = new Authorization(url, user, pass);
+ public void set(int index, String url, String user, String pass, String domain, String realm) {
+ Authorization auth = new Authorization(url, user, pass, domain, realm);
if (index >= 0) {
getAuthObjects().set(index, new TestElementProperty(auth.getName(), auth));
} else {
@@ -202,7 +213,7 @@
return false;
}
- public void uncompile() {
+ public void uncompile() {// TODO is this used?
}
/**
@@ -248,7 +259,13 @@
String url = st.nextToken();
String user = st.nextToken();
String pass = st.nextToken();
- Authorization auth = new Authorization(url, user, pass);
+ String domain = "";
+ String realm = "";
+ if (st.hasMoreTokens()){// Allow for old format file without the extra columnns
+ domain = st.nextToken();
+ realm = st.nextToken();
+ }
+ Authorization auth = new Authorization(url, user, pass,domain,realm);
getAuthObjects().addItem(auth);
} catch (Exception e) {
reader.close();
@@ -274,6 +291,7 @@
// Needs to be package protected for Unit test
static boolean isSupportedProtocol(URL url) {
- return url.getProtocol().toUpperCase().equals("HTTP") || url.getProtocol().toUpperCase().equals("HTTPS");
+ String protocol = url.getProtocol().toUpperCase();
+ return protocol.equals("HTTP") || protocol.equals("HTTPS");
}
}
Modified: jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/Authorization.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/Authorization.java?view=diff&rev=505096&r1=505095&r2=505096
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/Authorization.java (original)
+++ jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/control/Authorization.java Thu Feb 8 16:28:06 2007
@@ -27,8 +27,7 @@
/**
* This class is an Authorization encapsulator.
*
- * @author <a href="mailto:luta.raphael@networks.vivendi.net">Raphael Luta</a>
- * @version $Revision$
+ * author <a href="mailto:luta.raphael@networks.vivendi.net">Raphael Luta</a>
*/
public class Authorization extends AbstractTestElement implements Serializable {
private static String URL = "Authorization.url";
@@ -37,13 +36,19 @@
private static String PASSWORD = "Authorization.password";
+ private static String DOMAIN = "Authorization.domain";
+
+ private static String REALM = "Authorization.realm";
+
/**
* create the authorization
*/
- Authorization(String url, String user, String pass) {
+ Authorization(String url, String user, String pass, String domain, String realm) {
setURL(url);
setUser(user);
setPass(pass);
+ setDomain(domain);
+ setRealm(realm);
}
public boolean expectsModification() {
@@ -54,9 +59,11 @@
setURL("");
setUser("");
setPass("");
+ setDomain("");
+ setRealm("");
}
- public String getClassLabel() {
+ public String getClassLabel() {// TODO Is this used?
return "Authorization";
}
@@ -87,8 +94,25 @@
setProperty(PASSWORD, pass);
}
+ public synchronized String getDomain() {
+ return getPropertyAsString(DOMAIN);
+ }
+
+ public synchronized void setDomain(String domain) {
+ setProperty(DOMAIN, domain);
+ }
+
+ public synchronized String getRealm() {
+ return getPropertyAsString(REALM);
+ }
+
+ public synchronized void setRealm(String realm) {
+ setProperty(REALM, realm);
+ }
+
+ // Used for saving entries to a file
public String toString() {
- return getURL() + "\t" + getUser() + "\t" + getPass();
+ return getURL() + "\t" + getUser() + "\t" + getPass() + "\t" + getDomain() + "\t" + getRealm();
}
public String toBasicHeader(){
Modified: jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java?view=diff&rev=505096&r1=505095&r2=505096
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java (original)
+++ jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/gui/AuthPanel.java Thu Feb 8 16:28:06 2007
@@ -54,8 +54,6 @@
* Handles input for determining if authentication services are required for a
* Sampler. It also understands how to get AuthManagers for the files that the
* user selects.
- *
- * @version $Revision$ Last updated: $Date$
*/
public class AuthPanel extends AbstractConfigGui implements ActionListener {
transient private static Logger log = LoggingManager.getLoggerForClass();
@@ -209,7 +207,7 @@
}
} catch (IOException ex) {
log.error("", ex);
- } catch (NullPointerException err) {
+ } catch (NullPointerException err) {// TODO WHY?
}
} else if (action.equals(SAVE_COMMAND)) {
try {
@@ -219,7 +217,7 @@
}
} catch (IOException ex) {
log.error("", ex);
- } catch (NullPointerException err) {
+ } catch (NullPointerException err) {// TODO WHY?
}
}
}
@@ -230,13 +228,13 @@
authTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
authTable.setPreferredScrollableViewportSize(new Dimension(100, 70));
- TableColumn passwordColumn = authTable.getColumnModel().getColumn(2);
+ TableColumn passwordColumn = authTable.getColumnModel().getColumn(AuthManager.COL_PASSWORD);
passwordColumn.setCellEditor(new DefaultCellEditor(new JPasswordField()));
passwordColumn.setCellRenderer(new PasswordCellRenderer());
JPanel panel = new JPanel(new BorderLayout(0, 5));
- panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils
- .getResString("auths_stored")));
+ panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
+ JMeterUtils.getResString("auths_stored")));
panel.add(new JScrollPane(authTable));
panel.add(createButtonPanel(), BorderLayout.SOUTH);
return panel;
@@ -326,26 +324,44 @@
public Object getValueAt(int row, int column) {
Authorization auth = manager.getAuthObjectAt(row);
- if (column == 0) {
- return auth.getURL();
- } else if (column == 1) {
- return auth.getUser();
- } else if (column == 2) {
- return auth.getPass();
+ switch (column){
+ case AuthManager.COL_URL:
+ return auth.getURL();
+ case AuthManager.COL_USERNAME:
+ return auth.getUser();
+ case AuthManager.COL_PASSWORD:
+ return auth.getPass();
+ case AuthManager.COL_DOMAIN:
+ return auth.getDomain();
+ case AuthManager.COL_REALM:
+ return auth.getRealm();
+ default:
+ return null;
}
- return null;
}
public void setValueAt(Object value, int row, int column) {
Authorization auth = manager.getAuthObjectAt(row);
log.debug("Setting auth value: " + value);
- if (column == 0) {
- auth.setURL((String) value);
- } else if (column == 1) {
- auth.setUser((String) value);
- } else if (column == 2) {
- auth.setPass((String) value);
- }
+ switch (column){
+ case AuthManager.COL_URL:
+ auth.setURL((String) value);
+ break;
+ case AuthManager.COL_USERNAME:
+ auth.setUser((String) value);
+ break;
+ case AuthManager.COL_PASSWORD:
+ auth.setPass((String) value);
+ break;
+ case AuthManager.COL_DOMAIN:
+ auth.setDomain((String) value);
+ break;
+ case AuthManager.COL_REALM:
+ auth.setRealm((String) value);
+ break;
+ default:
+ break;
+ }
}
}
Modified: jakarta/jmeter/branches/rel-2-2/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java?view=diff&rev=505096&r1=505095&r2=505096
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java (original)
+++ jakarta/jmeter/branches/rel-2-2/test/src/org/apache/jmeter/protocol/http/control/TestAuthManager.java Thu Feb 8 16:28:06 2007
@@ -23,14 +23,6 @@
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.testelement.property.CollectionProperty;
-/**
- * This class provides a way to provide Authorization in jmeter requests. The
- * format of the authorization file is: URL user pass where URL is an HTTP URL,
- * user a username to use and pass the appropriate password.
- *
- * @author <a href="mailto:luta.raphael@networks.vivendi.com">Raphael Luta</a>
- * @version $Revision$
- */
public class TestAuthManager extends JMeterTestCase {
public TestAuthManager(String name) {
super(name);
@@ -49,7 +41,7 @@
CollectionProperty ao = am.getAuthObjects();
assertEquals(0, ao.size());
am.addFile("testfiles/TestAuth.txt");
- assertEquals(5, ao.size());
+ assertEquals(6, ao.size());
Authorization at;
at = am.getAuthForURL(new URL("http://a.b.c/"));
assertEquals("login", at.getUser());
@@ -57,5 +49,12 @@
at = am.getAuthForURL(new URL("http://a.b.c/1"));
assertEquals("login1", at.getUser());
assertEquals("password1", at.getPass());
+ assertEquals("", at.getDomain());
+ assertEquals("", at.getRealm());
+ at = am.getAuthForURL(new URL("http://d.e.f/"));
+ assertEquals("user", at.getUser());
+ assertEquals("pass", at.getPass());
+ assertEquals("domain", at.getDomain());
+ assertEquals("realm", at.getRealm());
}
}
Modified: jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml?view=diff&rev=505096&r1=505095&r2=505096
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml Thu Feb 8 16:28:06 2007
@@ -1890,12 +1890,15 @@
"http://jakarta.apache.org/restricted/ant/myPage.html", the Authorization Manager sends the login
information for the user named, "jmeter".</property>
<property name="Username" required="Yes">The username to authorize.</property>
- <property name="Password" required="Yes">The password to authorize.</property>
+ <property name="Password" required="Yes">The password for the user.</property>
+ <property name="Domain" required="No">The domain to use for NTLM.</property>
+ <property name="Realm" required="No">The realm to use for NTLM.</property>
</properties>
<note>
-For NTLM authentication, enter the user name in the form domain\user[@realm]. This is an experimental feature and may be changed at a later date.
-This should work with the Http Client sampler on all platforms, but with the default Http sampler only on Windows.
-The realm portion is optional, and only applies to the HttpClient sampler.
+The Realm only applies to the HttpClient sampler.
+In JMeter 2.2, the domain and realm did not have separate columns, and were encoded as part of
+the user name in the form: [domain\]username[@realm].
+This was an experimental feature and has been removed.
</note>
<b>Controls:</b>
<ul>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org