Project

General

Profile

Domain settings are not read from init.properties

Titas Lapinskas
Added almost 5 years ago

Hello

I have a need to make XMPP server to import users from several locations thus I created custom Auth and User classes which checks several locations. Some methods are not implemented yet, I just added logging to it so that I could see do it passes what I expect. It was very surprized to see this output:

2014-04-30 14:17:38.238 [main]             ConfiguratorAbstract.parseArgs()   CONFIG:   Added default config parameter: (config-type=--gen-config-def)
2014-04-30 14:17:38.238 [main]             ConfiguratorAbstract.parseArgs()   CONFIG:   Added default config parameter: (--monitoring=jmx:9955)
2014-04-30 14:17:38.239 [main]             ConfiguratorAbstract.parseArgs()   CONFIG:   Added default config parameter: (--debug=server)
2014-04-30 14:17:38.239 [main]             ConfiguratorAbstract.parseArgs()   CONFIG:   Added default config parameter: (--user-db=tigase.db.CustomUserRepositoryImpl)
2014-04-30 14:17:38.240 [main]             ConfiguratorAbstract.parseArgs()   CONFIG:   Added default config parameter: (--auth-db=tigase.db.CustomAuthProvider)
2014-04-30 14:17:38.240 [main]             ConfiguratorAbstract.parseArgs()   CONFIG:   Added default config parameter: (--user-db-uri=hardcoded)
2014-04-30 14:17:38.240 [main]             ConfiguratorAbstract.parseArgs()   CONFIG:   Added default config parameter: (--auth-db-uri=hardcoded)
2014-04-30 14:17:38.240 [main]             ConfiguratorAbstract.parseArgs()   CONFIG:   Added default config parameter: (--admins=admin@mydomain.chat)
2014-04-30 14:17:38.241 [main]             ConfiguratorAbstract.parseArgs()   CONFIG:   Added default config parameter: (--virt-hosts=mydomain.chat)
2014-04-30 14:17:38.309 [main]             MonitoringSetup.initMonitoring()   CONFIG:   Installing monitoring services: jmx:9955

So all items are read from init.properties and then output of my not fully implemented methods:

addUser:

2014-04-30 14:17:40.498 [main]             UserRepoRepository.setProperties()  SEVERE:  Problem with adding 'vhost-manager' user to the database
java.lang.UnsupportedOperationException: Not supported yet.

getData:

2014-04-30 14:17:40.502 [main]             UserRepoRepository.reload()        SEVERE:   Problem with loading items list from the database.
java.lang.UnsupportedOperationException: Not supported yet.DEBUG: getData  : , p1 = vhost-manager, p2 = vhosts-lists

I checked code 'vhost-manager' is hardcoded domain in class VHostRepoDefaults. But I expected a call will be made and domain I wrote will be passes: mydomain.chat

Just in case here is full my init.properties file:

config-type=--gen-config-def
--admins=admin@mydomain.chat
--virt-hosts=mydomain.chat
--debug=server
--monitoring=jmx:9955
  1. Here comes settings for Tigase chat room custom authentication
--user-db=tigase.db.simcom.CustomUserRepositoryImpl
--auth-db=tigase.db.simcom.CustomAuthProvider
--user-db-uri=hardcoded
--auth-db-uri=hardcoded

Do I need any additional settings in order configured domain to be used instead of default one?

Or does that mean Tigase always want to extract domain info from database even if that was defined in init.properties ?

My sources won't allow adding a user from Tigase, I want to have that control in other side.

Thank you in advance.


Replies (7)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 5 years ago

'vhost-manager' is not a domain. It is an ID of the component which tries to use user-db (UserRepository) to store and retrieve it's operational data. UserRepository is an abstract DB layer which is used by many components and modules in Tigase, not just to store user's data.

From what I understand, you do not need to implement UserRepository, you may stick to the default implementation and you only need to implement AuthRepository which retrieves user login data from different locations.

Added by Titas Lapinskas almost 5 years ago

Thank you for the answer.

Initially I always thought about implementing only AuthRepository, but I noticed that it doesn't have a method for retrieving usernames.

It has methods for adding, removing, authorizing, logout, even return count of the users.

And methods isUserValid.

I haven't used XMPP earlier so might be wrong, but I was thinking it should be like Skype or Lync: you do some general search, you get a list of contacts and then add them to your roster.

Checking other interfaces I saw that UserRepository has method for returning usernames (getUsers) so started working on it.

I'll try switching to default UserRepository implementation then, hopefully I'll get something running and when I'll see how it works from client side.

Thank you once again.

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 5 years ago

Titas Lapinskas wrote:

Thank you for the answer.

Initially I always thought about implementing only AuthRepository, but I noticed that it doesn't have a method for retrieving usernames.

It has methods for adding, removing, authorizing, logout, even return count of the users.

And methods isUserValid.

I haven't used XMPP earlier so might be wrong, but I was thinking it should be like Skype or Lync: you do some general search, you get a list of contacts and then add them to your roster.

Indeed, the XMPP is more focused on users privacy and security. Searching and adding is kind of a feature which has a negative affect on user's privacy and it would greatly help all sorts of spammers to get a list of all users on the installation. That's said, there is an extension ** Jabber Search but not all XMPP servers implement it and very few deployments actually activate it.

Therefore my suggestion is to stay with a default UserRepository if possible and look at the jabber search extension instead. We do not have a support for it yet but maybe implementing this extension for Tigase would be more beneficial to you than implementing own UserRepository.

Added by Titas Lapinskas almost 5 years ago

Hi again,

I did as you suggested regarding UserRepository:

So my init.properties right now is:

config-type=--gen-config-def
--admins=admin@ts200.chat
--virt-hosts=ts200.chat
--debug=server,db
--monitoring=jmx:9955

# Here are settings for Tigase chat rooms - auth mechanism settings
--user-db=pgsql
--user-db-uri=jdbc:postgresql://localhost/tigasedb?user=xxxx&password=xxxxx
--auth-db=tigase.db.ts200.XmlRpcTS200AuthProvider
--auth-db-uri=http://localhost/xml-rpc

tigase.db.ts200.XmlRpcTS200AuthProvider is an implementation of AuthRepository

I implemented as follows:

public String getResourceUri()  - fully
public long getUsersCount()  - return -1  (copy from LDAP impl)
public long getUsersCount(String domain)  - return -1 (copy from LDAP impl)
 public void queryAuth(Map<String, Object> authProps) {                      // COPY from LDAP IMPL
        String protocol = (String) authProps.get(PROTOCOL_KEY);

        if (protocol.equals(PROTOCOL_VAL_NONSASL)) {
            authProps.put(RESULT_KEY, non_sasl_mechs);
        }

        if (protocol.equals(PROTOCOL_VAL_SASL)) {
            authProps.put(RESULT_KEY, sasl_mechs);
        }
    }

public void initRepository(String resource_uri, Map<String, String> params) throws DBInitException    - fully, in log I see that it is invoked and successfully ends
public void updatePassword(BareJID user, String password) throws UserNotFoundException, TigaseDBException  - throws exception
public void removeUser(BareJID user) throws UserNotFoundException, TigaseDBException - throws exception
public void addUser(BareJID user, String password) throws UserExistsException, TigaseDBException  - throws exception
public boolean digestAuth(BareJID user, String digest, String id, String alg) throws UserNotFoundException,  - throws exception
public void logout(BareJID user) throws UserNotFoundException, TigaseDBException   - for now throws exception, will change later
public boolean otherAuth(Map<String, Object> authProps) throws UserNotFoundException,    - fully
public boolean plainAuth(BareJID user, String password) throws UserNotFoundException,  - fully

Each method has log statement at the start so that I get logged that it was invoked.


(Had a bit different init.properties then)

I started Tigase, no exceptions and entries appeared in tig_pairs, tig_users, tig_nodes. Not working. AuthRepository fails.

I restarted it several times until I came to init.properties I showed earlier.

Finally I got log message that InitRepository in my AuthRepository implementation was invoked and successfully finished.

and here what i see in log after that:

2014-05-05 15:40:50.482 [pool-3-thread-1] ConnectionManager$1.run() FINE: Reconnecting service for component: c2s, to remote host: localhost on port: 5,222

2014-05-05 15:40:50.483 [pool-3-thread-1] ConnectionManager$1.run() FINE: Reconnecting service for component: c2s, to remote host: localhost on port: 5,223

2014-05-05 15:40:50.488 [pool-5-thread-1] ConnectionManager$1.run() FINE: Reconnecting service for component: s2s, to remote host: localhost on port: 5,269

2014-05-05 15:40:50.489 [pool-2-thread-1] ConnectionManager$1.run() FINE: Reconnecting service for component: bosh, to remote host: localhost on port: 5,280

2014-05-05 15:40:50.491 [pool-8-thread-1] ConnectionManager$1.run() FINE: Reconnecting service for component: ws2s, to remote host: localhost on port: 5,290

(SOME PAUSE)

2014-05-05 15:41:44.424 [hostnames] JDBCRepository.getNodeNID() FINEST: select nid as nid1 from tig_nodes where (uid = 2) AND (parent_nid is null) AND (node = 'root')

2014-05-05 15:41:44.425 [hostnames] JDBCRepository.getData() FINEST: Loading data for key: vhosts-lists, user: vhost-manager, node: null, def: null, found nid: 2

2014-05-05 15:41:44.426 [hostnames] JDBCRepository.getData() FINEST: Found data:

2014-05-05 15:41:44.427 [hostnames] JDBCRepository.getNodeNID() FINEST: select nid as nid1 from tig_nodes where (uid = 2) AND (parent_nid is null) AND (node = 'root')

2014-05-05 15:41:44.427 [hostnames] JDBCRepository.setData() FINEST: Saving data setting data, user_id: vhost-manager, subnode: null, key: vhosts-lists, uid: 2, nid: 2, value:

2014-05-05 15:41:44.429 [hostnames] ConfigRepository.addItem() INFO: No repoChangeListener for: Domain: ts200.chat, enabled: true, anonym: true, register: true, maxusers: 0, tls: false, s2sSecret: VALID GUID, domainFilter: ALL

2014-05-05 15:41:44.429 [hostnames] UserRepoRepository.reload() CONFIG: All loaded items: {ts200.chat=Domain: ts200.chat, enabled: true, anonym: true, register: true, maxusers: 0, tls: false, s2sSecret: VALID GUID, domainFilter: ALL}

I ran Psi to connect to admin account. It is offline and log doesn't have indication of neither plainAuth nor otherAuth being invoked.

I searched forums, the only reference to repoChangeListener was about Mac OSX problem. I am running Linux CentOS6 with tigase-server-5.2.1-b3461-dist-max

Looking at the code I see nothing very obvious from ConfigRepository class.

The only changes in code I introduced was a new package tigase.db.ts200 (which contains code needed for my specific user authorization).

Just in case you need this:

select * from tig_pairs

nid;uid;pkey;pval

;1;"schema-version";"5.1"

2;2;"vhosts-lists";""

select * from tig_users

uid;user_id;user_pw;acc_create_time;last_login;last_logout;online_status;failed_logins;account_status

1;"db-properties";"";"2014-04-23 13:43:40.811542";"";"";0;0;1

2;"vhost-manager";"";"2014-05-05 09:24:31.86636";"";"";0;0;1

select * from tig_nodes

nid;parent_nid;uid;node

1;;1;"root"

2;;2;"root"

Other tables are empty.

Thank you in advance.

Added by Titas Lapinskas almost 5 years ago

Hi again,

tried playing more with it. I turned on all standard mechanism of the Tigase for Auth and User repos. Here is current init.properties

config-type=--gen-config-def
--admins=admin@ts200.chat
--virt-hosts=ts200.chat
--debug=server,db
--monitoring=jmx:9955

# Here comes settings for Tigase chat rooms
# which DB to use
--user-db=pgsql
--user-db-uri=jdbc:postgresql://localhost/tigasedb?user=xxxx&password=xxxx
--auth-db=pgsql
--auth-db-uri=jdbc:postgresql://localhost/tigasedb?user=xxxx&password=xxxx

Still getting errors:

2014-05-06 13:52:05.968 [hostnames] JDBCRepository.getNodeNID() FINEST: select nid as nid1 from tig_nodes where (uid = 2) AND (parent_nid is null) AND (node = 'root')

2014-05-06 13:52:05.970 [hostnames] JDBCRepository.getData() FINEST: Loading data for key: vhosts-lists, user: vhost-manager, node: null, def: null, found nid: 2

2014-05-06 13:52:05.970 [hostnames] JDBCRepository.getData() FINEST: Found data:

2014-05-06 13:52:05.971 [hostnames] JDBCRepository.getNodeNID() FINEST: select nid as nid1 from tig_nodes where (uid = 2) AND (parent_nid is null) AND (node = 'root')

2014-05-06 13:52:05.972 [hostnames] JDBCRepository.setData() FINEST: Saving data setting data, user_id: vhost-manager, subnode: null, key: vhosts-lists, uid: 2, nid: 2, value:

2014-05-06 13:52:05.974 [hostnames] ConfigRepository.addItem() INFO: No repoChangeListener for: Domain: ts200.chat, enabled: true, anonym: true, register: true, maxusers: 0, tls: false, s2sSecret: 59a8e878-3a48-4d5a-aa80-cfe871149ab4, domainFilter: ALL

2014-05-06 13:52:05.974 [hostnames] UserRepoRepository.reload() CONFIG: All loaded items: {ts200.chat=Domain: ts200.chat, enabled: true, anonym: true, register: true, maxusers: 0, tls: false, s2sSecret: 59a8e878-3a48-4d5a-aa80-cfe871149ab4, domainFilter: ALL}

2014-05-06 13:53:05.968 [hostnames] JDBCRepository.getData() FINEST: Loading data for key: vhosts-lists, user: vhost-manager, node: null, def: null, found nid: 2

2014-05-06 13:53:05.969 [hostnames] JDBCRepository.getData() FINEST: Found data:

Any suggestions?

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 5 years ago

What kind of errors did you get? The log entries you attached are not errors. These are just normal logs signaling that Tigase started and loaded vhost configuration.

When you connect with Psi to Tigase you should see lots of log entries from connection manager way before it hits your database. If there is nothing, then you most likely do not connect with Psi. Does Psi show any error? What error?

Are you sure Psi attempts to connect to this installation?

Added by Titas Lapinskas almost 5 years ago

Ignore this.

My client (Psi) was requiring password. Even if I had admin acc without password (for test) it still excepted password and when no password was provided it didn't sent anything to server. That's why I had no log entries.

Solved and working now.

Thanks for you answers.

    (1-7/7)