openfire使用者管理_初始化Message Service器使用者資訊

來源:互聯網
上載者:User

系統開發階段就即將結束,使用者整合是個大問題。期間網上查詢了一翻,各種複製粘貼,冗餘資訊量太多太多,甚感悲痛。。。。

有些成功分享,一是講可以通過修改ofProperty表,將Message Service器中的預設使用者表【ofUser】替換為自訂使用者表,可以是公司原使用者表;

二是按照OPenfire的使用者整合管理Custom Database Integration Guide官網的說明,修改設定檔。

都試了一遍,哎,失敗。。。

還好,發現了作者為Justin Hunt開發了一個外掛程式User Service,用起來還是蠻方便的,這裡做簡單介紹。

第一步,下載userservice.jar,添加到Plugin中,研讀相關說明,講的很詳細,也有樣本;

第二步,設定安全密鑰,在server->server
setting->User service中進行配置,並啟動其服務;

第三步,建立使用者,發送HTTP請求到使用者服務中心【submit
HTTP requests to the userservice service】

/** * init Openfire User via httpRequest dml@2012.9.14 *  * @param url */private static void httpExecute(String url) {// 構造HttpClient的執行個體HttpClient httpClient = new HttpClient();// 設定 Http 連線逾時為5秒httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);// 建立GET方法的執行個體GetMethod getMethod = new GetMethod(url);// 設定 get 請求逾時為 5 秒getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 5000);// 使用系統提供的預設的恢複策略getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new DefaultHttpMethodRetryHandler());try {// 執行getMethodint statusCode = httpClient.executeMethod(getMethod);if (statusCode != HttpStatus.SC_OK) {log.warning("Method failed: " + getMethod.getStatusLine());}// 讀取內容 ,第一種方式擷取byte[] responseBody = getMethod.getResponseBody();// 處理內容log.info(new String(responseBody));} catch (HttpException e) {// 發生致命的異常,可能是協議不對或者返回的內容有問題log.info("Please check your provided http address!");e.printStackTrace();} catch (IOException e) {// 發生網路異常e.printStackTrace();} finally {// 釋放串連getMethod.releaseConnection();}}

以上代碼需匯入HttpClient.jar包,url為傳入參數,自行定義,格式見user service協助【http://example.com:9090/plugins/userService/userservice?type=add&secret=bigsecret&username=kafka&password=drowssap&name=f】

第四步,添加組資訊,組資訊直接添加到ofGroupUser表中即可,這裡不做贅述了。

第五步,重啟openfire伺服器,進行測試。。。




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.