// otherwise check if it is a valid user in the JBMS system.
//
// NOTE: We always expect an authentication service per database
// and one at the system level.
//
AuthenticationService authenticationService = null;
try {
// Retrieve appropriate authentication service handle
if (dbname == null)
authenticationService =
getLocalDriver().getAuthenticationService();
else
authenticationService =
getTR().getDatabase().getAuthenticationService();
} catch (StandardException se) {
throw Util.generateCsSQLException(se);
}
// check that we do have a authentication service
// it is _always_ expected.
if (authenticationService == null)
{
String failedString = MessageService.getTextMessage(
(dbname == null) ? MessageId.AUTH_NO_SERVICE_FOR_SYSTEM : MessageId.AUTH_NO_SERVICE_FOR_DB);
throw newSQLException(SQLState.LOGIN_FAILED, failedString);
}
if (dbname != null) {
checkUserIsNotARole();
}
// Let's authenticate now
if (!authenticationService.authenticate(
dbname,
userInfo
)) {
throw newSQLException(SQLState.NET_CONNECT_AUTH_FAILED,