use of jakarta.jms.JMSSecurityException in project openmq by eclipse-ee4j.
the class DirectConnectionFactory method _createConnectionId.
// ///////////////////////////////////////////////////////////////////////
// end jakarta.jms.TopicConnectionFactory
// ///////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////
// MQ methods
// ///////////////////////////////////////////////////////////////////////
/**
* Create a connection with the jmsservice and return a connectionId. Used by the methods implementing
* jakarta.jms.Connection, jakarta.jms.QueueConnection, and jakarta.jms.TopicConnection
*
* @param username The username that should be used to authenticate the creation of the connection with the jmsservice
* @param password The password that should be used to authenticate the creation of the connection with the jmsservice
*
* @return The connectionId to be used by the DirectConnection object that is returned by the JMS API method
*
* @throws JMSSecurityException if the specified user identity does not authenticate successfully with the JMS server
* @throws JMSException if any JMS server error occurred
*/
private long _createConnectionId(String username, String password) throws JMSException {
JMSServiceReply reply;
long connectionId = 0L;
if (this.jmsservice == null) {
if (this.ra != null) {
this.jmsservice = this.ra._getJMSService();
}
if (this.jmsservice == null) {
// Ultimate fallback :)
this.jmsservice = ResourceAdapter._getRAJMSService();
}
}
assert (this.jmsservice != null);
try {
reply = jmsservice.createConnection(username, password);
try {
connectionId = reply.getJMQConnectionID();
} catch (NoSuchFieldException nsfe) {
String exerrmsg = _lgrMID_EXC + "JMSServiceException:Missing JMQConnectionID";
JMSException jmse = new JMSException(exerrmsg);
jmse.initCause(nsfe);
_loggerJF.severe(exerrmsg);
throw jmse;
}
} catch (JMSServiceException jse) {
JMSServiceReply.Status status = jse.getJMSServiceReply().getStatus();
JMSException jmsse;
String failure_cause;
boolean security_exception = true;
switch(status) {
case INVALID_LOGIN:
failure_cause = "authentication failure.";
break;
case FORBIDDEN:
failure_cause = "authorization failure.";
break;
default:
failure_cause = "unkown JMSService server error.";
security_exception = false;
}
String exerrmsg = "createConnection on JMSService:" + jmsservice.getJMSServiceID() + " failed for username:" + username + " due to " + failure_cause;
_loggerJF.severe(exerrmsg);
jmsse = (security_exception ? new JMSSecurityException(exerrmsg, jse.getJMSServiceReply().getErrorCode()) : new JMSException(exerrmsg, jse.getJMSServiceReply().getErrorCode()));
jmsse.initCause(jse);
throw jmsse;
}
return connectionId;
}
Aggregations