Project

General

Profile

Need API keys for Tigase 5.2.3 HTTP API

Peter Rajcani
Added about 4 years ago

We need API keys to access HTTP API for Tigase v. 5.2.3:

We get the followiing error when we try to add a user:

PUT http://127.0.0.1:8080/rest/user/test1@mydomain.com
Accept: application/xml
Content-Type: text/xml
Username: admin@mydomain.com
<user>
    <password>test123</password>
</user>
 -- response --
403 To access URI = '/rest/user/test1@mydomain.com' a valid api key is required
Cache-Control:  must-revalidate,no-cache,no-store
Content-Type:  text/html;charset=ISO-8859-1
Content-Length:  1439
Server:  Jetty(8.1.9.v20130131)
Connection:  Keep-Alive
Date:  Mon, 29 Dec 2014 21:47:26 GMT

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 403 To access URI = '/rest/user/test1@tmydomain.com' a valid api key is required</title>
</head>
<body>
<h2>HTTP ERROR: 403</h2>
<p>Problem accessing /rest/user/test1@mydomain.com. Reason:

Powered by Jetty://

Our configuration is as follows:

--comp-class-1 = tigase.muc.MUCComponent
--virt-hosts = mydomain.com
--user-db-uri = jdbc:derby:/opt/tigase-5.2.3-defaultdb/tigasedb
--user-db = derby
--admins = admin@mydomain.com,http@mydomain.com,pubsub@mydomain.com,http@hostname.com
--comp-name-4 = message-archive
--comp-name-3 = proxy
config-type = --gen-config-def
--comp-name-2 = pubsub
--comp-name-1 = muc
--cluster-mode = true
--sm-plugins = +message-archive-xep-0136
--debug = server
--comp-class-4 = tigase.archive.MessageArchiveComponent
--comp-class-3 = tigase.socks5.Socks5ProxyComponent
--comp-class-2 = tigase.pubsub.PubSubComponent
--comp-name-5=rest
--comp-class-5=tigase.http.rest.RestMessageReceiver
--api-keys=open_access

Replies (6)

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam about 4 years ago

You are using Tigase XMPP Server 5.2.3 which contains Tigase HTTP API 1.0.0.

In this version of HTTP API --api-keys enables security for HTTP API and contains list of comma separated API keys. So if you add --api-keys to etc/init.properties file you need to pass one of it comma separated values as api-key HTTP parameter. However if you want same behavior as gives open_access feature (disable security) from Tigase HTTP API 1.1.0-SNAPSHOT (which is part of Tigase XMPP Server 7.0.0-SNAPSHOT), you need to omit --api-keys from etc/init.properties

Added by Peter Rajcani about 4 years ago

Thanks for the clarification. I did as you suggested - removed the --api-keys from init.properties, but I still get an error whet trying to create a user in v. 5.2.3:

PUT http://127.0.0.1:8080/rest/user/test1@mydomain.com

Accept: application/xml

Content-Type: text/xml

Username: admin@mydomain.com

<password>test1</password>

-- response --

500 Internal Server Error

Transfer-Encoding: chunked

Date: Tue, 30 Dec 2014 21:05:32 GMT

Cache-Control: proxy-revalidate

Connection: Keep-Alive

There are no issues with v. 7.0.0-SNAPSHOT.

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam about 4 years ago

It is hard to tell what failed. Information about actual error should be available in Tigase XMPP Server logs, could you post (or attach) part of Tigase XMPP Server logs when error occured?

Added by Peter Rajcani about 4 years ago

Here is the server response:

Error 500 Server Error

HTTP ERROR: 500

Problem accessing /rest/user/test1@tigasetest.com. Reason:

<hr /><i><small>Powered by Jetty://</small></i>

Log is attached

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam about 4 years ago

In log I found

Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database /opt/tigase-5.2.3-defaultdb/tigasedb.
    at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
    at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.privGetJBMSLockOnDB(Unknown Source)
    at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.getJBMSLockOnDB(Unknown Source)
    at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.boot(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
    at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
    at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
    at org.apache.derby.impl.store.raw.RawStore.boot(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
    at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
    at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
    at org.apache.derby.impl.store.access.RAMAccessManager.boot(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
    at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
    at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
    at org.apache.derby.impl.db.BasicDatabase.bootStore(Unknown Source)
    at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
    at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(Unknown Source)
    at org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(Unknown Source)
    at org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source)
    at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
    at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
    at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:233)
    at tigase.db.jdbc.DataRepositoryImpl.initRepo(DataRepositoryImpl.java:483)
    at tigase.db.jdbc.DataRepositoryImpl.initRepository(DataRepositoryImpl.java:335)
    at tigase.db.RepositoryFactory.getDataRepository(RepositoryFactory.java:393)
    at tigase.db.jdbc.JDBCRepository.initRepository(JDBCRepository.java:814)
    at tigase.db.RepositoryFactory.getUserRepository(RepositoryFactory.java:502)
    at tigase.conf.ConfiguratorAbstract.addUserRepo(ConfiguratorAbstract.java:955)
    at tigase.conf.ConfiguratorAbstract.setProperties(ConfiguratorAbstract.java:875)
    at tigase.conf.ConfiguratorAbstract.setup(ConfiguratorAbstract.java:550)
    at tigase.conf.ConfiguratorAbstract.componentAdded(ConfiguratorAbstract.java:182)
    at tigase.conf.Configurator.componentAdded(Configurator.java:50)
    at tigase.conf.Configurator.componentAdded(Configurator.java:33)
    at tigase.server.AbstractComponentRegistrator.addComponent(AbstractComponentRegistrator.java:115)
    at tigase.server.MessageRouter.addRegistrator(MessageRouter.java:141)
    at tigase.server.MessageRouter.setConfig(MessageRouter.java:696)
    at tigase.server.XMPPServer.start(XMPPServer.java:142)
    at tigase.server.XMPPServer.main(XMPPServer.java:112)

which means there is some issue with opening DerbyDB located at /opt/tigase-5.2.3-defaultdb/tigasedb in embedded mode. I this this issue is related to one of 3 things:

  • same database is used by other instance of Tigase XMPP Server

  • database is opened by other application (in embedded mode only 1 application can be accessing database)

  • database was not closed properly last time, which let's it think it is already opened

Due to this issue not only HTTP API is not working properly but whole server is not working as it should.

Added by Peter Rajcani about 4 years ago

Thanks for the response. At this point we decided to go with 7.0.0 version and MySQL database. We have already configured the server and it is working fine.

    (1-6/6)