2012-08-07 129 views
2

我有一個Joomla網站,也是一個Java/jsp網站。 我正在嘗試爲Joomla創建一個自定義身份驗證插件以從我的jsp應用程序獲取身份驗證詳細信息。Joomla 2.5自定義身份驗證插件通過外部jsp網站進行身份驗證

所以作爲第一次嘗試,我編輯了默認的joomla身份驗證插件類中的onUserAuthenticate()函數。

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; 
    } 
} 

正如我猜測,它應該工作的任何憑據,但事實並非如此..
我已經有一個用戶調用admin現在登錄與用戶名admin工作的任何密碼。但這不是我所期望的。我需要以anything作爲用戶名和anything作爲密碼登錄。

作爲第一次嘗試我需要完全停止訪問默認joomla數據庫的憑據。但驗證腳本仍在尋找本地數據庫。 請幫我解決這個問題..
也很感謝,如果你能建議一個很好的方式與jsp網站溝通。

我要嘗試用SOAP,像這樣:

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

這是從我的JSP應用程序反饋的最佳方式?

回答

2

這不是joomla身份驗證插件正在訪問數據庫(在您編輯後)。如果您查看/plugins/user/joomla/joomla.php,您會在onUserAuthenticate()後面找到onUserLogin()方法。 這是創建用戶會話並填充JUser對象實例的人。

即使你強迫成功登錄用戶仍然會被視爲來賓,所以你也需要破解onUserLogin()。您的SOAP嘗試對我來說很好