View | Details | Raw Unified | Return to bug 51691
Collapse All | Expand All

(-)src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java (-2 / +6 lines)
Lines 224-229 Link Here
224
        updateConfig(USE_TEXT_RSC);
224
        updateConfig(USE_TEXT_RSC);
225
        iterations.setText("1"); // $NON-NLS-1$
225
        iterations.setText("1"); // $NON-NLS-1$
226
        useAuth.setSelected(false);
226
        useAuth.setSelected(false);
227
        jmsUser.setEnabled(false);
228
        jmsPwd.setEnabled(false);
227
        destSetup.setText(DEST_SETUP_STATIC);
229
        destSetup.setText(DEST_SETUP_STATIC);
228
    }
230
    }
229
231
Lines 249-254 Link Here
249
        updateConfig(sampler.getConfigChoice());
251
        updateConfig(sampler.getConfigChoice());
250
        iterations.setText(sampler.getIterations());
252
        iterations.setText(sampler.getIterations());
251
        useAuth.setSelected(sampler.isUseAuth());
253
        useAuth.setSelected(sampler.isUseAuth());
254
        jmsUser.setEnabled(useAuth.isSelected());
255
        jmsPwd.setEnabled(useAuth.isSelected());
252
        destSetup.setText(sampler.isDestinationStatic() ? DEST_SETUP_STATIC : DEST_SETUP_DYNAMIC);
256
        destSetup.setText(sampler.isDestinationStatic() ? DEST_SETUP_STATIC : DEST_SETUP_DYNAMIC);
253
    }
257
    }
254
258
Lines 265-272 Link Here
265
            jndiICF.setEnabled(!useProperties.isSelected());
269
            jndiICF.setEnabled(!useProperties.isSelected());
266
            urlField.setEnabled(!useProperties.isSelected());
270
            urlField.setEnabled(!useProperties.isSelected());
267
        } else if (event.getSource() == useAuth) {
271
        } else if (event.getSource() == useAuth) {
268
            jmsUser.setEnabled(!useAuth.isSelected());
272
            jmsUser.setEnabled(useAuth.isSelected());
269
            jmsPwd.setEnabled(!useAuth.isSelected());
273
            jmsPwd.setEnabled(useAuth.isSelected());
270
        }
274
        }
271
    }
275
    }
272
276
(-)src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSSubscriberGui.java (-2 / +6 lines)
Lines 203-208 Link Here
203
        jmsPwd.setText(sampler.getPassword());
203
        jmsPwd.setText(sampler.getPassword());
204
        iterations.setText(sampler.getIterations());
204
        iterations.setText(sampler.getIterations());
205
        useAuth.setSelected(sampler.isUseAuth());
205
        useAuth.setSelected(sampler.isUseAuth());
206
        jmsUser.setEnabled(useAuth.isSelected());
207
        jmsPwd.setEnabled(useAuth.isSelected());
206
        readResponse.setSelected(sampler.getReadResponseAsBoolean());
208
        readResponse.setSelected(sampler.getReadResponseAsBoolean());
207
        clientChoice.setText(sampler.getClientChoice());
209
        clientChoice.setText(sampler.getClientChoice());
208
        stopBetweenSamples.setSelected(sampler.isStopBetweenSamples());
210
        stopBetweenSamples.setSelected(sampler.isStopBetweenSamples());
Lines 224-229 Link Here
224
        iterations.setText("1"); // $NON-NLS-1$
226
        iterations.setText("1"); // $NON-NLS-1$
225
        timeout.setText("");
227
        timeout.setText("");
226
        useAuth.setSelected(false);
228
        useAuth.setSelected(false);
229
        jmsUser.setEnabled(false);
230
        jmsPwd.setEnabled(false);
227
        readResponse.setSelected(true);
231
        readResponse.setSelected(true);
228
        clientChoice.setText(RECEIVE_RSC);
232
        clientChoice.setText(RECEIVE_RSC);
229
        stopBetweenSamples.setSelected(false);
233
        stopBetweenSamples.setSelected(false);
Lines 239-246 Link Here
239
            jndiICF.setEnabled(!useProperties.isSelected());
243
            jndiICF.setEnabled(!useProperties.isSelected());
240
            urlField.setEnabled(!useProperties.isSelected());
244
            urlField.setEnabled(!useProperties.isSelected());
241
        } else if (event.getSource() == useAuth) {
245
        } else if (event.getSource() == useAuth) {
242
            jmsUser.setEnabled(!useAuth.isSelected());
246
            jmsUser.setEnabled(useAuth.isSelected());
243
            jmsPwd.setEnabled(!useAuth.isSelected());
247
            jmsPwd.setEnabled(useAuth.isSelected());
244
        }
248
        }
245
    }
249
    }
246
    
250
    
(-)src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java (-1 / +10 lines)
Lines 19-24 Link Here
19
package org.apache.jmeter.protocol.jms;
19
package org.apache.jmeter.protocol.jms;
20
20
21
import java.util.Enumeration;
21
import java.util.Enumeration;
22
import java.util.Map;
22
23
23
import javax.jms.Connection;
24
import javax.jms.Connection;
24
import javax.jms.Destination;
25
import javax.jms.Destination;
Lines 148-154 Link Here
148
            throw new NamingException("Lookup failed: "+e.toString());
149
            throw new NamingException("Lookup failed: "+e.toString());
149
        }
150
        }
150
        if (objfac instanceof javax.jms.ConnectionFactory) {
151
        if (objfac instanceof javax.jms.ConnectionFactory) {
151
            return ((javax.jms.ConnectionFactory) objfac).createConnection();
152
            Map<String, Object> env = (Map<String, Object>)ctx.getEnvironment();
153
            if(env.containsKey(Context.SECURITY_PRINCIPAL)) {
154
                String username = (String)env.get(Context.SECURITY_PRINCIPAL);
155
                String password = (String)env.get(Context.SECURITY_CREDENTIALS);
156
                return ((javax.jms.ConnectionFactory) objfac).createConnection(username, password);                
157
            }
158
            else {
159
                return ((javax.jms.ConnectionFactory) objfac).createConnection();
160
            }
152
        }
161
        }
153
        throw new NamingException("Expected javax.jms.ConnectionFactory, found "+objfac.getClass().getName());
162
        throw new NamingException("Expected javax.jms.ConnectionFactory, found "+objfac.getClass().getName());
154
    }
163
    }
(-)src/protocol/jms/org/apache/jmeter/protocol/jms/client/InitialContextFactory.java (-2 / +30 lines)
Lines 26-31 Link Here
26
import javax.naming.InitialContext;
26
import javax.naming.InitialContext;
27
import javax.naming.NamingException;
27
import javax.naming.NamingException;
28
28
29
import org.apache.commons.lang.StringUtils;
29
import org.apache.jorphan.logging.LoggingManager;
30
import org.apache.jorphan.logging.LoggingManager;
30
import org.apache.log.Logger;
31
import org.apache.log.Logger;
31
32
Lines 52-58 Link Here
52
     */
53
     */
53
    public static synchronized Context lookupContext(String initialContextFactory, 
54
    public static synchronized Context lookupContext(String initialContextFactory, 
54
            String providerUrl, boolean useAuth, String securityPrincipal, String securityCredentials) throws NamingException {
55
            String providerUrl, boolean useAuth, String securityPrincipal, String securityCredentials) throws NamingException {
55
        Context ctx = MAP.get(initialContextFactory + providerUrl);
56
        String cacheKey = createKey(initialContextFactory ,providerUrl, securityPrincipal, securityCredentials);
57
        Context ctx = MAP.get(cacheKey);
56
        if (ctx == null) {
58
        if (ctx == null) {
57
            Properties props = new Properties();
59
            Properties props = new Properties();
58
            props.setProperty(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
60
            props.setProperty(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
Lines 70-81 Link Here
70
            } catch (Exception e) {
72
            } catch (Exception e) {
71
                throw new NamingException(e.toString());
73
                throw new NamingException(e.toString());
72
            }
74
            }
73
            MAP.put(initialContextFactory + providerUrl, ctx);
75
            MAP.put(cacheKey, ctx);
74
        }
76
        }
75
        return ctx;
77
        return ctx;
76
    }
78
    }
77
79
78
    /**
80
    /**
81
     * Create cache key
82
     * @param initialContextFactory
83
     * @param providerUrl
84
     * @param securityPrincipal
85
     * @param securityCredentials
86
     * @return
87
     */
88
    private static String createKey(String initialContextFactory,
89
            String providerUrl, String securityPrincipal,
90
            String securityCredentials) {
91
       StringBuilder builder = new StringBuilder();
92
       builder.append(initialContextFactory);
93
       builder.append("#");
94
       builder.append(providerUrl);
95
       builder.append("#");
96
       if(!StringUtils.isEmpty(securityPrincipal)) {
97
           builder.append(securityPrincipal);
98
           builder.append("#");
99
       }
100
       if(!StringUtils.isEmpty(securityCredentials)) {
101
           builder.append(securityCredentials);
102
       }
103
       return builder.toString();
104
    }
105
106
    /**
79
     * Initialize the JNDI initial context
107
     * Initialize the JNDI initial context
80
     *
108
     *
81
     * @param useProps if true, create a new InitialContext; otherwise use the other parameters to call
109
     * @param useProps if true, create a new InitialContext; otherwise use the other parameters to call

Return to bug 51691