lobtx opened a new pull request, #2847:
URL: https://github.com/apache/activemq/pull/2847

   Fixes #2194.
   
   The resource adapter declares the `BasicPassword` authentication mechanism 
with `PasswordCredential`, but `ActiveMQManagedConnectionFactory` never looked 
at the `Subject` given by the application server. With container-managed 
sign-on (e.g. WildFly), the user name and password were ignored and the 
connection was made with the request info or factory credentials.
   
   Now, `createManagedConnection` and `matchManagedConnections` take the 
`PasswordCredential` of the `Subject` that belongs to this factory 
(`getManagedConnectionFactory()` equals this one, as the spec says) and use its 
user name and password. The request info given by the caller is copied, not 
modified. Without a `Subject`, or without a credential for this factory, 
nothing changes.
   
   `matchManagedConnections` still returns null when the request info is not an 
`ActiveMQConnectionRequestInfo`, like before. If the private credentials of the 
Subject cannot be read (security manager without the 
`PrivateCredentialPermission`), a warning is logged and the request info 
credentials are used, like before.
   
   When the Subject has a credential for this factory, it takes precedence over 
the user name and password of the request info, so `createConnection(user, 
password)` on a connection factory with container-managed sign-on uses the 
container credentials.
   
   Added `ManagedConnectionFactorySubjectTest` (broker that accepts only known 
users): credentials from the Subject, Subject over request info, credential of 
another factory ignored, matching with the same / another Subject, Subject 
whose credentials cannot be read. The 3 first tests fail without the fix (`User 
name [null] or password is invalid`). All activemq-ra tests pass.
   
   I also tested it in WildFly 42 (Elytron `authentication-context` on the 
connection definitions) with the activemq-rar of main and the same rar with 
only the activemq-ra jar replaced, against a broker that accepts only two users:
   
   | Case | main | with this PR |
   |---|---|---|
   | container-managed sign-on, `createConnection()` (cf1 = app1, cf2 = app2) | 
rejected, `User name [defaultUser]` | OK, broker sees `app1` / `app2` |
   | JTA transaction commit / rollback on cf1 | fails | OK |
   | no container security, credentials in the connection definition | OK | OK 
(unchanged) |
   | no container security, `createConnection(user, password)` | OK | OK 
(unchanged) |
   | 30 sends in a row on cf1 | fails | OK, 1 physical connection reused |
   | 40 parallel sends on cf1 and cf2 | fails | OK, each pool only connects 
with its own user |


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to