jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1196306 - in /jmeter/trunk: src/components/org/apache/jmeter/config/ src/core/org/apache/jmeter/util/ src/core/org/apache/jmeter/util/keystore/ xdocs/images/screenshots/ xdocs/usermanual/
Date Tue, 01 Nov 2011 21:51:46 GMT
Author: pmouawad
Date: Tue Nov  1 21:51:46 2011
New Revision: 1196306

URL: http://svn.apache.org/viewvc?rev=1196306&view=rev
Log:
Bug 52033 - Allowing multiple certificates (JKS)
Added Keystore Config to enable configuring:
- Preload
- Start alias index
- End alias index

Added:
    jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java   (with props)
    jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigBeanInfo.java   (with
props)
    jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigResources.properties
  (with props)
    jmeter/trunk/xdocs/images/screenshots/keystore_config.png   (with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java
    jmeter/trunk/src/core/org/apache/jmeter/util/keystore/DefaultKeyStore.java
    jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Added: 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=1196306&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java Tue Nov  1 21:51:46
2011
@@ -0,0 +1,130 @@
+/*
+ * 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.config;
+
+import org.apache.jmeter.engine.event.LoopIterationEvent;
+import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.testelement.TestListener;
+import org.apache.jmeter.util.SSLManager;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+/**
+ * Configure Keystore
+ */
+public class KeystoreConfig extends ConfigTestElement implements TestBean, TestListener {
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -5781402012242794890L;
+    private Logger log = LoggingManager.getLoggerForClass();
+
+    private String startIndex;
+    private String endIndex;
+    private String preload;
+    
+    /**
+     * 
+     */
+    public KeystoreConfig() {
+        super();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void testEnded() {
+        testEnded(null);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void testEnded(String host) {
+        log.info("Destroying Keystore");         
+        SSLManager.getInstance().destroyKeystore();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void testIterationStart(LoopIterationEvent event) {
+        // NOOP        
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void testStarted() {
+        testStarted(null);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void testStarted(String host) {
+        log.info("Configuring Keystore with (preload:"+preload+", startIndex:"+
+                startIndex+", endIndex:"+endIndex);
+        SSLManager.getInstance().configureKeystore(Boolean.valueOf(preload),
+        		Integer.parseInt(startIndex), 
+                Integer.parseInt(endIndex));
+    }
+
+    /**
+     * @return the endIndex
+     */
+    public String getEndIndex() {
+        return endIndex;
+    }
+
+    /**
+     * @param endIndex the endIndex to set
+     */
+    public void setEndIndex(String endIndex) {
+        this.endIndex = endIndex;
+    }
+
+    /**
+     * @return the startIndex
+     */
+    public String getStartIndex() {
+        return startIndex;
+    }
+
+    /**
+     * @param startIndex the startIndex to set
+     */
+    public void setStartIndex(String startIndex) {
+        this.startIndex = startIndex;
+    }
+
+    /**
+     * @return the preload
+     */
+    public String getPreload() {
+        return preload;
+    }
+
+    /**
+     * @param preload the preload to set
+     */
+    public void setPreload(String preload) {
+        this.preload = preload;
+    }
+}

Propchange: jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1196306&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigBeanInfo.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigBeanInfo.java Tue Nov
 1 21:51:46 2011
@@ -0,0 +1,59 @@
+/*
+ * 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.config;
+
+import java.beans.PropertyDescriptor;
+
+import org.apache.jmeter.testbeans.BeanInfoSupport;
+
+/**
+ * Keystore Configuration BeanInfo
+ */
+public class KeystoreConfigBeanInfo extends BeanInfoSupport {
+
+    private static final String ALIASES_GROUP = "aliases";
+    private static final String ALIAS_END_INDEX = "startIndex";
+    private static final String ALIAS_START_INDEX = "endIndex";
+    private static final String PRELOAD = "preload";
+
+    /**
+     * Constructor
+     */
+    public KeystoreConfigBeanInfo() {
+        super(KeystoreConfig.class);
+
+        createPropertyGroup(ALIASES_GROUP, new String[] { 
+                PRELOAD, ALIAS_START_INDEX, ALIAS_END_INDEX });
+
+        PropertyDescriptor p = property(PRELOAD);
+        p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+        p.setValue(DEFAULT, "true"); // $NON-NLS-1$
+        p.setValue(NOT_EXPRESSION, Boolean.TRUE);
+        p.setValue(NOT_OTHER, Boolean.TRUE);
+        p.setValue(TAGS, new String[]{"True", "False"}); // $NON-NLS-1$ $NON-NLS-2$
+
+        p = property(ALIAS_START_INDEX);
+        p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+        p.setValue(DEFAULT, ""); // $NON-NLS-1$
+
+        p = property(ALIAS_END_INDEX);
+        p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+        p.setValue(DEFAULT, ""); // $NON-NLS-1$       
+    }
+}

Propchange: jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigBeanInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigResources.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigResources.properties?rev=1196306&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigResources.properties
(added)
+++ jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigResources.properties
Tue Nov  1 21:51:46 2011
@@ -0,0 +1,10 @@
+displayName=Keystore Configuration
+# Groups
+aliases.displayName=Aliases selection configuration
+# fields
+preload.displayName=Preload
+preload.shortDescription=Preload Keystore before test
+startIndex.displayName=Alias Start index
+startIndex.shortDescription=First index of Alias in Keystore
+endIndex.displayName=Alias End index
+endIndex.shortDescription=Last index of Alias in Keystore

Propchange: jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfigResources.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java?rev=1196306&r1=1196305&r2=1196306&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java Tue Nov  1 21:51:46 2011
@@ -74,6 +74,10 @@ public abstract class SSLManager {
     /** Have the password available */
     protected String defaultpw = System.getProperty(KEY_STORE_PASSWORD);
 
+    private int keystoreAliasStartIndex;
+
+    private int keystoreAliasEndIndex;
+
     /**
      * Resets the SSLManager so that we can create a new one with a new keystore
      */
@@ -91,7 +95,7 @@ public abstract class SSLManager {
             Security.addProvider(provider);
         }
     }
-
+    
     /**
      * Opens and initializes the KeyStore. If the password for the KeyStore is
      * not set, this method will prompt you to enter it. Unfortunately, there is
@@ -118,7 +122,8 @@ public abstract class SSLManager {
                 this.keyStore = null;
                 throw new RuntimeException("Could not create keystore: "+e.getMessage());
             }
-
+            this.keyStore.setAliasStartIndex(keystoreAliasStartIndex);
+            this.keyStore.setAliasEndIndex(keystoreAliasEndIndex);
             FileInputStream fileInputStream = null;
             try {
                 File initStore = new File(fileName);
@@ -135,7 +140,7 @@ public abstract class SSLManager {
                     this.keyStore.load(null, "");
                 }
             } catch (Exception e) {
-                log.error("Problem loading keystore: " +e.getMessage());
+                log.error("Problem loading keystore: " +e.getMessage(), e);
             } finally {
                 JOrphanUtils.closeQuietly(fileInputStream);
             }
@@ -272,4 +277,25 @@ public abstract class SSLManager {
     public static final boolean isSSLSupported() {
         return SSLManager.isSSLSupported;
     }
+
+    /**
+     * Configure Keystore
+     * @param preload 
+     * @param startIndex 
+     * @param endIndex 
+     */
+    public void configureKeystore(boolean preload, int startIndex, int endIndex) {
+        this.keystoreAliasStartIndex = startIndex;
+        this.keystoreAliasEndIndex = endIndex;
+        if(preload) {
+            keyStore = getKeyStore();
+        }
+    }
+
+    /**
+     * Destroy Keystore
+     */
+    public void destroyKeystore() {
+        keyStore=null;
+    }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/keystore/DefaultKeyStore.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/keystore/DefaultKeyStore.java?rev=1196306&r1=1196305&r2=1196306&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/keystore/DefaultKeyStore.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/keystore/DefaultKeyStore.java Tue Nov  1
21:51:46 2011
@@ -47,16 +47,13 @@ public class DefaultKeyStore extends Jme
     private static final String KEY_STORE_START_INDEX = "https.keyStoreStartIndex"; // $NON-NLS-1$
     private static final String KEY_STORE_END_INDEX   = "https.keyStoreEndIndex"; // $NON-NLS-1$
 
-    private static final int startIndex;
-    private static final int endIndex;
-
-    static {
-        startIndex = JMeterUtils.getPropDefault(KEY_STORE_START_INDEX, 0);
-        endIndex = JMeterUtils.getPropDefault(KEY_STORE_END_INDEX, 0);
-    }
+    private int startIndex;
+    private int endIndex;
 
     public DefaultKeyStore(String type) throws Exception {
         this.store = KeyStore.getInstance(type);
+        startIndex = JMeterUtils.getPropDefault(KEY_STORE_START_INDEX, 0);
+        endIndex = JMeterUtils.getPropDefault(KEY_STORE_END_INDEX, 0);
     }
 
     /** {@inheritDoc} */
@@ -179,4 +176,32 @@ public class DefaultKeyStore extends Jme
         }
     }
 
+    /**
+     * @return the startIndex
+     */
+    public int getAliasStartIndex() {
+        return startIndex;
+    }
+
+    /**
+     * @param startIndex the startIndex to set
+     */
+    public void setAliasStartIndex(int startIndex) {
+        this.startIndex = startIndex;
+    }
+
+    /**
+     * @return the endIndex
+     */
+    public int getAliasEndIndex() {
+        return endIndex;
+    }
+
+    /**
+     * @param endIndex the endIndex to set
+     */
+    public void setAliasEndIndex(int endIndex) {
+        this.endIndex = endIndex;
+    }
+
 }

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=1196306&r1=1196305&r2=1196306&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 Tue Nov  1 21:51:46
2011
@@ -57,4 +57,24 @@ public abstract class JmeterKeyStore {
         // JAVA 1.4 now handles all keystore types, so just use default
         return new DefaultKeyStore(type);
     }
+    
+    /**
+     * @param startIndex the startIndex to set
+     */
+    public abstract void setAliasStartIndex(int startIndex);
+
+    /**
+     * @return the endIndex
+     */
+    public abstract int getAliasEndIndex();
+
+    /**
+     * @param endIndex the endIndex to set
+     */
+    public abstract void setAliasEndIndex(int endIndex);
+    
+    /**
+     * @return int index of start alias in keystore
+     */
+    public abstract int getAliasStartIndex();
 }
\ No newline at end of file

Added: jmeter/trunk/xdocs/images/screenshots/keystore_config.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/images/screenshots/keystore_config.png?rev=1196306&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jmeter/trunk/xdocs/images/screenshots/keystore_config.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1196306&r1=1196305&r2=1196306&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Tue Nov  1 21:51:46 2011
@@ -3331,7 +3331,21 @@ OR<br/>jdbc:oracle:thin:@(description=(a
 </component>
 
 
-<component name="Login Config Element" index="&sect-num;.4.9"  width="352" height="112"
screenshot="login-config.png">
+<component name="Keystore Config Element" index="&sect-num;.4.9"  width="352" height="112"
screenshot="keystore_config.png">
+<description><p>The Keystore Config Element lets you configure how Keystore will
be loaded and which keys it will use.
+This component is typically used in HTTPs scenarios where you don't want to take into account
keystore initialization into account in response time.</p>
+</description>
+
+<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.</property>
+  <property name="Alias Start Index" required="Yes">The index of the first key to use
in Keystore.</property>
+  <property name="Alias End Index" required="Yes">The index of the last key to use
in Keystore.</property>
+</properties>
+
+</component>
+
+<component name="Login Config Element" index="&sect-num;.4.10"  width="352" height="112"
screenshot="login-config.png">
 <description><p>The Login Config Element lets you add or override username and
password settings in samplers that use username and password as part of their setup.</p>
 </description>
 
@@ -3343,21 +3357,19 @@ OR<br/>jdbc:oracle:thin:@(description=(a
 
 </component>
 
-
-
-<component name="LDAP Request Defaults" index="&sect-num;.4.10"  width="465" height="375"
screenshot="ldap_defaults.png">
+<component name="LDAP Request Defaults" index="&sect-num;.4.11"  width="465" height="375"
screenshot="ldap_defaults.png">
 <description><p>The LDAP Request Defaults component lets you set default values
for LDAP testing.  See the <complink name="LDAP Request"/>.</p>
 </description>
 
 </component>
 
-<component name="LDAP Extended Request Defaults" index="&sect-num;.4.11"  width="597"
height="545" screenshot="ldapext_defaults.png">
+<component name="LDAP Extended Request Defaults" index="&sect-num;.4.12"  width="597"
height="545" screenshot="ldapext_defaults.png">
 <description><p>The LDAP Extended Request Defaults component lets you set default
values for extended LDAP testing.  See the <complink name="LDAP Extended Request"/>.</p>
 </description>
 
 </component>
 
-<component name="TCP Sampler Config" index="&sect-num;.4.12"  width="747" height="251"
screenshot="tcpsamplerconfig.png">
+<component name="TCP Sampler Config" index="&sect-num;.4.13"  width="747" height="251"
screenshot="tcpsamplerconfig.png">
 <description>
         <p>
 	The TCP Sampler Config provides default data for the TCP Sampler
@@ -3376,7 +3388,7 @@ OR<br/>jdbc:oracle:thin:@(description=(a
 </properties>
 </component>
 
-<component name="User Defined Variables" index="&sect-num;.4.13"  width="690" height="394"
screenshot="user_defined_variables.png">
+<component name="User Defined Variables" index="&sect-num;.4.14"  width="690" height="394"
screenshot="user_defined_variables.png">
 <description><p>The User Defined Variables element lets you define an <b>initial
set of variables</b>, just as in the <complink name="Test Plan" />.
 <b>
 Note that all the UDV elements in a test plan - no matter where they are - are processed
at the start.
@@ -3426,7 +3438,7 @@ You can reference variables defined in e
 </properties>
 </component>
 
-<component name="Random Variable" index="&sect-num;.4.14"  width="411" height="306"
screenshot="random_variable.png">
+<component name="Random Variable" index="&sect-num;.4.15"  width="411" height="306"
screenshot="random_variable.png">
 <description>
 <p>
 The Random Variable Config Element is used to generate random numeric strings and store them
in variable for use later.
@@ -3458,7 +3470,7 @@ however the minimum and maximum values c
 
 </component>
 
-<component name="Counter" index="&sect-num;.4.15"  width="399" height="244" screenshot="counter.png">
+<component name="Counter" index="&sect-num;.4.16"  width="399" height="244" screenshot="counter.png">
 <description><p>Allows the user to create a counter that can be referenced anywhere
 in the Thread Group.  The counter config lets the user configure a starting point, a maximum,
 and the increment.  The counter will loop from the start to the max, and then start over
@@ -3487,7 +3499,7 @@ with the start, continuing on like that 
 </properties>
 </component>
 
-<component name="Simple Config Element" index="&sect-num;.4.16"  width="393" height="245"
screenshot="simple_config_element.png">
+<component name="Simple Config Element" index="&sect-num;.4.17"  width="393" height="245"
screenshot="simple_config_element.png">
 <description><p>The Simple Config Element lets you add or override arbitrary
values in samplers.  You can choose the name of the value
 and the value itself.  Although some adventurous users might find a use for this element,
it's here primarily for developers as a basic
 GUI that they can use while developing new JMeter components.</p>



Mime
View raw message