针对外部服务验证OpenFire

时间:2014-09-09 14:59:11

标签: java authentication xmpp openfire

我正在尝试使用外部服务验证OpenFire登录请求。我已经使用自定义AuthProvider实现(下面)成功完成了此操作。但是,这仅适用于WEB UI。当客户端通过Spark客户端连接时,它似乎仍然执行旧方法(用户名,令牌,摘要)而不仅仅是用户名,密码。还需要对我的java类进行哪些其他更改才能让它做我需要它做的事情?此外,您可以看到我有一个从未在Spark客户端尝试连接时执行的PrintWriter,这也告诉我它没有被重定向到此身份验证功能。在你提问之前,我已经修改了Spark客户端来执行connection.login(String,String)函数而不是connection.login(String,String)。

感谢您的帮助。

DMAUth.java:

package org.jivesoftware.openfire.auth;

import java.io.PrintWriter;

import org.jivesoftware.openfire.user.UserNotFoundException;

public class DMAuth implements AuthProvider {

    public boolean isPlainSupported() {
        // TODO Auto-generated method stub
        return true;
    }

    public boolean isDigestSupported() {
        // TODO Auto-generated method stub
        return false;
    }

    public void authenticate(String username, String password)
            throws UnauthorizedException, ConnectionException,
            InternalUnauthenticatedException {
        try {
        PrintWriter writer = new PrintWriter("log.txt", "UTF-8");
        writer.println("Username: "+username);
        writer.println("Password: "+password);
        writer.close();
        }
        catch (Exception e) {

        }

    }

    public String getPassword(String username) throws UserNotFoundException,
            UnsupportedOperationException {
        // TODO Auto-generated method stub
        return null;
    }

    public void setPassword(String username, String password)
            throws UserNotFoundException, UnsupportedOperationException {
        // TODO Auto-generated method stub

    }

    public boolean supportsPasswordRetrieval() {
        // TODO Auto-generated method stub
        return false;
    }

}

info.log中显示的错误:

2014.09.09 11:05:08 org.jivesoftware.openfire.nio.ConnectionHandler - ConnectionHandler reports IOException for session: (SOCKET, R: /192.168.10.155:55212, L: /192.168.10.157:5222, S: 0.0.0.0/0.0.0$
java.io.IOException: Broken pipe
        at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
        at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
        at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
        at sun.nio.ch.IOUtil.write(IOUtil.java:65)
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)
        at org.apache.mina.transport.socket.nio.SocketIoProcessor.doFlush(SocketIoProcessor.java:414)
        at org.apache.mina.transport.socket.nio.SocketIoProcessor.doFlush(SocketIoProcessor.java:332)
        at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$500(SocketIoProcessor.java:45)
        at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:488)
        at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

0 个答案:

没有答案