jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1842280 - in /jmeter/trunk: src/components/org/apache/jmeter/config/ src/core/org/apache/jmeter/util/keystore/ xdocs/ xdocs/usermanual/
Date Fri, 28 Sep 2018 19:50:07 GMT
Author: pmouawad
Date: Fri Sep 28 19:50:06 2018
New Revision: 1842280

URL: http://svn.apache.org/viewvc?rev=1842280&view=rev
Log:
Bug 62766 : Keystore Config : We should load all aliases by default 
Contributed by UbikLoadPack
Bugzilla Id: 62766

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java
    jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigBeanInfo.java
    jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java?rev=1842280&r1=1842279&r2=1842280&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java Fri Sep 28 19:50:06
2018
@@ -70,7 +70,7 @@ public class KeystoreConfig extends Conf
             log.warn("https.use.cached.ssl.context property must be set to false to ensure
Multiple Certificates are used");
         }
         int startIndexAsInt = JMeterUtils.getPropDefault(KEY_STORE_START_INDEX, 0);
-        int endIndexAsInt = JMeterUtils.getPropDefault(KEY_STORE_END_INDEX, 0);
+        int endIndexAsInt = JMeterUtils.getPropDefault(KEY_STORE_END_INDEX, -1);
         
         if(!StringUtils.isEmpty(this.startIndex)) {
             try {
@@ -89,7 +89,7 @@ public class KeystoreConfig extends Conf
                         endIndexAsInt, e, e);
             }
         } 
-        if(startIndexAsInt>endIndexAsInt) {
+        if(endIndexAsInt != -1 && startIndexAsInt>endIndexAsInt) {
             throw new JMeterStopTestException("Keystore Config error : Alias start index
must be lower than Alias end index");
         }
         log.info(

Modified: jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigBeanInfo.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigBeanInfo.java?rev=1842280&r1=1842279&r2=1842280&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigBeanInfo.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigBeanInfo.java Fri Sep
28 19:50:06 2018
@@ -21,6 +21,7 @@ package org.apache.jmeter.config;
 import java.beans.PropertyDescriptor;
 
 import org.apache.jmeter.testbeans.BeanInfoSupport;
+import org.apache.jmeter.util.keystore.JmeterKeyStore;
 
 /**
  * Keystore Configuration BeanInfo
@@ -51,14 +52,14 @@ public class KeystoreConfigBeanInfo exte
 
         p = property(CLIENT_CERT_ALIAS_VAR_NAME);
         p.setValue(NOT_UNDEFINED, Boolean.TRUE);
-        p.setValue(DEFAULT, ""); // $NON-NLS-1$
+        p.setValue(DEFAULT, JmeterKeyStore.DEFAULT_ALIAS_VAR_NAME); // $NON-NLS-1$
 
         p = property(ALIAS_START_INDEX);
         p.setValue(NOT_UNDEFINED, Boolean.TRUE);
-        p.setValue(DEFAULT, ""); // $NON-NLS-1$
+        p.setValue(DEFAULT, "0"); // $NON-NLS-1$
 
         p = property(ALIAS_END_INDEX);
         p.setValue(NOT_UNDEFINED, Boolean.TRUE);
-        p.setValue(DEFAULT, ""); // $NON-NLS-1$       
+        p.setValue(DEFAULT, "-1"); // $NON-NLS-1$
     }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java?rev=1842280&r1=1842279&r2=1842280&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java Fri Sep 28 19:50:06
2018
@@ -48,6 +48,8 @@ public final class JmeterKeyStore {
 
     private static final Logger log = LoggerFactory.getLogger(JmeterKeyStore.class);
 
+    public static final String DEFAULT_ALIAS_VAR_NAME = "certAlias";
+
     private final KeyStore store;
 
     /** first index to consider for a key */
@@ -78,7 +80,7 @@ public final class JmeterKeyStore {
      *             &lt; 0 or <code>endIndex</code> &lt; </code>startIndex</code>
      */
     private JmeterKeyStore(String type, int startIndex, int endIndex, String clientCertAliasVarName)
throws KeyStoreException {
-        if (startIndex < 0 || endIndex < 0 || endIndex < startIndex) {
+        if (startIndex < 0 || (endIndex != -1 && endIndex < startIndex)) {
             throw new IllegalArgumentException("Invalid index(es). Start="+startIndex+",
end="+endIndex);
         }
         this.store = KeyStore.getInstance(type);
@@ -125,7 +127,7 @@ public final class JmeterKeyStore {
             while (aliases.hasMoreElements()) {
                 String alias = aliases.nextElement();
                 if (store.isKeyEntry(alias)) {
-                    if (index >= startIndex && index <= endIndex) {
+                    if (index >= startIndex && (endIndex== -1 || index <= endIndex))
{
                         privateKey = (PrivateKey) store.getKey(alias, pw);
                         if (null == privateKey) {
                             throw new IOException("No key found for alias: " + alias); //
Should not happen
@@ -150,8 +152,8 @@ public final class JmeterKeyStore {
             if (null == privateKey) {
                 throw new IOException("No key(s) found");
             }
-            if (index <= endIndex-startIndex && log.isWarnEnabled()) {
-                log.warn("Did not find all requested aliases. Start={}, end={}, found={}",
+            if (endIndex != -1 && index <= endIndex-startIndex && log.isWarnEnabled())
{
+                log.warn("Did not find as much aliases as configured in indexes Start={},
end={}, found={}",
                         startIndex, endIndex, certsByAlias.size());
             }
         }
@@ -272,7 +274,7 @@ public final class JmeterKeyStore {
      *             when the type of the store is not supported
      */
     public static JmeterKeyStore getInstance(String type) throws KeyStoreException {
-        return getInstance(type, 0, 0, null);
+        return getInstance(type, 0, -1, DEFAULT_ALIAS_VAR_NAME);
     }
 
     /**

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1842280&r1=1842279&r2=1842280&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Sep 28 19:50:06 2018
@@ -92,6 +92,7 @@ Summary
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
 <ul>
+    <li><bug>62766</bug>Keystore Config : We should load all aliases by
default. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
 </ul>
 
 <h3>Functions</h3>

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1842280&r1=1842279&r2=1842280&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Fri Sep 28 19:50:06 2018
@@ -4078,9 +4078,9 @@ This component is typically used in HTTP
 <properties>
   <property name="Name" required="No">Descriptive name for this element that is shown
in the tree. </property>
   <property name="Preload" required="Yes">Wether or not to preload Keystore. Setting
it to <code>true</code> is usually the best option.</property>
-  <property name="Variable name holding certificate alias" required="False">Variable
name that will contain the alias to use for authentication by client certificate. Variable
value will be filled from CSV Data Set for example. In the screenshot, "<code>certificat_ssl</code>"
will also be a variable in CSV Data Set.</property>
+  <property name="Variable name holding certificate alias" required="False">Variable
name that will contain the alias to use for authentication by client certificate. Variable
value will be filled from CSV Data Set for example. In the screenshot, "<code>certificat_ssl</code>"
will also be a variable in CSV Data Set. Defaults to <code>clientCertAliasVarName</code></property>
   <property name="Alias Start Index" required="Yes">The index of the first key to use
in Keystore, 0-based.</property>
-  <property name="Alias End Index" required="Yes">The index of the last key to use
in Keystore, 0-based. When using "<code>Variable name holding certificate alias</code>"
ensure it is large enough so that all keys are loaded at startup.</property>
+  <property name="Alias End Index" required="Yes">The index of the last key to use
in Keystore, 0-based. When using "<code>Variable name holding certificate alias</code>"
ensure it is large enough so that all keys are loaded at startup. Default to -1 which means
load all.</property>
 </properties>
 <note>
 To make JMeter use more than one certificate you need to ensure that:



Mime
View raw message