Project

General

Profile

"Can not access user repository" error

Keren Meir
Added over 5 years ago

Hi,

I upgrade my tigase version to 5.2.0 beta 3, and added a few changes.

Before the upgrade, it works good. Now, after the upgrade I have one problem.

My changes are:

In "handleLogin" function in SessionManager class I added the last line:

public void handleLogin(BareJID userId, XMPPResourceConnection conn) {
        if (log.isLoggable(Level.FINEST)) {
            log.log(Level.FINEST, "handleLogin called for: {0}, conn_id: {1}", new Object[] {
                    userId,
                    conn });
        }
        registerNewSession(userId, conn);
        conn.setContactHash();
    }

The function "setContactHash" located in XMPPResourceConnection:

public void setContactHash() {
        try {
            this.contactHash = this.getData(null, CONTACTHASH_KEY, "FF");
        } catch (NotAuthorizedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (TigaseDBException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

the "getData" function has an exception:

tigase.xmpp.NotAuthorizedException: Can not access user repository.
    at tigase.xmpp.RepositoryAccess.getData(RepositoryAccess.java:282)
    at tigase.xmpp.XMPPResourceConnection.setContactHash(XMPPResourceConnection.java:989)
    at tigase.server.xmppsession.SessionManager.handleLogin(SessionManager.java:468)
    at tigase.cluster.SessionManagerClustered.handleLogin(SessionManagerClustered.java:210)
    at tigase.xmpp.XMPPResourceConnection.authorizeJID(XMPPResourceConnection.java:165)
    at tigase.xmpp.impl.SaslAuth.process(SaslAuth.java:342)
    at tigase.server.xmppsession.SessionManager$ProcessorWorkerThread.process(SessionManager.java:2665)
    at tigase.util.WorkerThread.run(WorkerThread.java:132)

What can be the problem?

(I'm using java 1.7, tigase 5.2.0 beta 3, all other calls to "getData" works good!)

Thanks


Replies (3)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 5 years ago

This is because an internal state within XMPPResourceConnection is set to authorized only after the handleLogin method completes without any errors. Before the state is set to authorized you cannot call database for that connection. The behavior of previous version was incorrect, I think.

If you really want/need to modify Tigase's own code I suggest to do it in the handleResoueceBind instead. But the correct way to add a custom functionality would be to write own plugin which is called on, resource bind for example and then do your stuff in there. This way you do not have to modify Tigase code and have much less hassle on code update to a new version.

Added by Keren Meir over 5 years ago

Thanks.

According to the plugin- I added some plugins (to tigase.xmpp.impl) but the trigger of these plugins is a packet that sent/received with specific tag.

How can I add plugin to the login process? what is the trigger of this plugin and where exactly I put it?

Thanks again

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 5 years ago

You are correct. Plugins are triggered by a XMPP stanza, not an event. This is why I suggested to make it a plugin triggered by resource bind stanza. You know that the user is already properly authenticated but he cannot yet communicate with other users. So this would be pretty much the same as handleLogin.

Alternatively, if you really want it to be a part of the login process you could write a plugin which extends the user authentication plugin and once authentication is completed you can do your stuff.

    (1-3/3)