activemq-ra ignores Subject PasswordCredential in ManagedConnectionFactory authentication flow
- Dominant language
- Java
- Stars
- 2.5k
- Forks
- 1.5k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 79
Description
## Summary
`activemq-ra` advertises `BasicPassword` authentication with `jakarta.resource.spi.security.PasswordCredential`, but `ActiveMQManagedConnectionFactory` does not extract credentials from the `Subject` provided by the application server.
Because of that, when a JCA container such as JBoss / WildFly passes username and password via `Subject` instead of `ActiveMQConnectionRequestInfo`, the adapter ignores them and falls back to CRI or factory defaults.
## Relevant code
`activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java`
```java
@Override
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
ActiveMQConnectionRequestInfo amqInfo = getInfo();
if (connectionRequestInfo instanceof ActiveMQConnectionRequestInfo) {
amqInfo = (ActiveMQConnectionRequestInfo) connectionRequestInfo;
}
try {
return new ActiveMQManagedConnection(subject, makeConnection(amqInfo), amqInfo);
} catch (JMSException e) {
throw new ResourceException("Could not create connection.", e);
}
}
```
`makeConnection(...)` uses only `ActiveMQConnectionRequestInfo.getUserName()` / `getPassword()`, and there appears to be no `PasswordCredential` handling anywhere in `activemq-ra`.
## Spec reference
Jakarta Connectors 2.1, “Contract for the Application Server”:
https://jakarta.ee/specifications/connectors/2.1/jakarta-connectors-spec-2.1#contract-for-the-application-server
Given the declared authentication mechanism, the adapter should honor credentials supplied by the application server through `Subject` / `PasswordCredential`.
## Expected behavior
When `Subject` contains a matching `PasswordCredential`, the adapter should use it when creating and matching managed connections.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java, focusing on createManagedConnection and the makeConnection flow. Read the Jakarta Connectors authentication contract and inspect how managed connections are created and matched. Done means Subject PasswordCredential values are honored instead of falling back to CRI or factory defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100