2
votes

I have a Joomla website and also a Java/jsp website. I am trying to create a custom authentication plugin for Joomla to get authentication detail from my jsp application.

So as the first try, I edited my the onUserAuthenticate() function in default joomla authentication plugin class.

function onUserAuthenticate($credentials, $options, &$response)
{
    $response->type = 'joomla';
    // Joomla does not like blank passwords
    if (empty($credentials['password'])) {
        $response->status = JAuthentication::STATUS_FAILURE;
        $response->error_message = JText::_('JGLOBAL_AUTH_EMPTY_PASS_NOT_ALLOWED');
        return false;
    }else{
        $response->status = JAuthentication::STATUS_SUCCESS;
        return true;
    }
}

As I guessed, it should be working for any credentials, But it wasn't..
I already had a user called admin and the login is now working for any password with the username admin. But this is not what I expected. I need to login with anything as username and anything as the password.

As the first try I needed to completely stop accessing the default joomla database for credentials. But authentication script is still looking for the local DB. Please help me to solve this problem..
And also appreciate if you can suggest a good way communication with the jsp site.

I am going to try with SOAP, like this way:

   $credentials = array(
      'memberNumber' => $credentials['username'],
      'password'     => $credentials['password']
      );
   $client = new SoapClient('http://example.com/soap.wsdl', $credentials);

Is this the best way to get the feedback from my jsp application?

1

1 Answers

2
votes

It's not joomla Authentication plugin that is accessing the database (after your edit). If you look into /plugins/user/joomla/joomla.php you'll find a method onUserLogin() which is triggered just after onUserAuthenticate(). This is the one that creates user session and populates JUser object instance.

Even that you forced a successful login user will still be treated as a guest, so you'll need to crack on the onUserLogin() too. Your SOAP attempt looks good for me