use of javax.resource.spi.SecurityException in project activemq-artemis by apache.
the class ActiveMQRACredential method getCredential.
/**
* Get credentials
*
* @param mcf The managed connection factory
* @param subject The subject
* @param info The connection request info
* @return The credentials
* @throws SecurityException Thrown if the credentials can't be retrieved
*/
public static ActiveMQRACredential getCredential(final ManagedConnectionFactory mcf, final Subject subject, final ConnectionRequestInfo info) throws SecurityException {
if (ActiveMQRACredential.trace) {
ActiveMQRALogger.LOGGER.trace("getCredential(" + mcf + ", " + subject + ", " + info + ")");
}
ActiveMQRACredential jc = new ActiveMQRACredential();
if (subject == null && info != null) {
jc.setUserName(((ActiveMQRAConnectionRequestInfo) info).getUserName());
jc.setPassword(((ActiveMQRAConnectionRequestInfo) info).getPassword());
} else if (subject != null) {
PasswordCredential pwdc = GetCredentialAction.getCredential(subject, mcf);
if (pwdc == null) {
throw new SecurityException("No password credentials found");
}
jc.setUserName(pwdc.getUserName());
jc.setPassword(new String(pwdc.getPassword()));
} else {
throw new SecurityException("No Subject or ConnectionRequestInfo set, could not get credentials");
}
return jc;
}
Aggregations