小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

XMPP Openfire集成windows身份認(rèn)證

 WindySky 2016-02-25

OpenFire可以很方便的集成已有數(shù)據(jù)庫類別的系統(tǒng)的用戶認(rèn)證,通常的應(yīng)用中還會遇到和Windows的身份認(rèn)證集成,下面對方法總結(jié)一下:

 

一、集成本地Windows用戶管理

此方法用openfire本身已經(jīng)實(shí)現(xiàn)的NativeAuthProvider類進(jìn)行驗(yàn)證,設(shè)置步驟如下:

1. 安裝openfire 3.7.0;

2. 將openfire_3_7_0\openfire\resources\nativeAuth\win32-x86\下的shaj.dll文件復(fù)制到Java\jdk1.6.0_23\bin\下;

3. 運(yùn)行openfire.exe;

4. 點(diǎn)擊Launch Admin,配置好后,在打開的瀏覽器中輸入正確的管理員帳戶和密碼,登錄;

5. 在“服務(wù)器—服務(wù)器管理器—系統(tǒng)屬性”中,將“provider.auth.className”的屬性值修改為“org.jivesoftware.openfire.auth.NativeAuthProvider”并保存屬性

6. 至此,再登錄openfire服務(wù)器必須用正確的本機(jī)windows用戶名及密碼。由于默認(rèn)只有用戶名admin為管理員,建議在windows下新建admin用戶或增加openfire的管理員帳戶。

 

二、集成Windows AD

通過JAAS的開源庫,我們也可以自己實(shí)現(xiàn)一個AD認(rèn)證的Provider

1. 下載waffle http://waffle./

2、編譯Provider的實(shí)現(xiàn)類并包含guava-r07.jar、jna.jar、platform.jar、waffle-jna.jar,形成一個jar包,并復(fù)制到openfire_3_7_0\openfire\lib下

3、Openfire的provider.auth.className設(shè)置為我們實(shí)現(xiàn)的類即可

具體的實(shí)現(xiàn)如下

import waffle.windows.auth.impl.WindowsAuthProviderImpl;

public class NTLMAuthProvider implements AuthProvider {
    private static final Logger Log = LoggerFactory.getLogger(NTLMAuthProvider.class);

    public NTLMAuthProvider() {

    }
    public void authenticate(String username, String password) throws UnauthorizedException {
        if (username.contains("@")) {
            // Check that the specified domain matches the server's domain
            int index = username.indexOf("@");
            String domain = username.substring(index + 1);
            if (domain.equals(XMPPServer.getInstance().getServerInfo().getXMPPDomain())) {
                username = username.substring(0, index);
            } else {
                // Unknown domain. Return authentication failed.
                throw new UnauthorizedException();
            }
        }
        try {
            WindowsAuthProviderImpl wapi=new WindowsAuthProviderImpl();
            wapi.logonUser(username,password);
        }
        catch (Exception e) {
            throw new UnauthorizedException(e);
        }
    }

    public void authenticate(String username, String token, String digest) throws UnauthorizedException {
        throw new UnsupportedOperationException();
    }

    public boolean isPlainSupported() {
        return true;
    }

    public boolean isDigestSupported() {
        return false;
    }

    public String getPassword(String username) throws UserNotFoundException, UnsupportedOperationException {      
        throw new UnsupportedOperationException();
    }

    public void setPassword(String username, String password) throws UserNotFoundException {
        throw new UnsupportedOperationException();
    }

    public boolean supportsPasswordRetrieval() {
        return false;
    }
}

 

關(guān)鍵解讀

以上的實(shí)現(xiàn)主要就是依據(jù)Java的JAAS規(guī)范,然后讀取Windows賬戶和AD服務(wù)信息,實(shí)現(xiàn)用戶的驗(yàn)證。

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多