How to Give everyone read and write access to a pubsub feed - iphone

I want to give everyone who subscribes to a node the ability to both read and write to that node.
Joe created the node "test5" in the code below. When Mark tries to post, I get an error.
I am using XMPPFramework for iphone. I receive the following error IQ. It appears that openfire is telling me that I can't publish an item b/c I don't have access? What is the default access model, open?
Doesn't that mean that anyone can subscribe to the node "test5", and anyone can publish items to it?
The JID of the fake user who originally created node "tes5" is "mark#joes-macbook-air.local"
Could the unauthorized message posting be b/c mark is not the owner of node titled "test5"?
What if I want mark to be able to post to this feed as well?
<iq xmlns="jabber:client" type="error" from="pubsub.joes-macbook-air.local" to="joe#joes-macbook-air.local/838f75ba"><pubsub xmlns="http://jabber.org/protocol/pubsub">
<publish node="test5"><item><body>Helpl me</body></item></publish>
</pubsub><error code="403" type="auth">
<forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</iq>
Update: I made the subscriber a "publisher". This is done by altering the publish_model of the node.

This depends on the node configurations in your pubsub service. Particularly the access mode of your node. In the XEP-0060 the access models section gives a good explanation on the different access methods. (1) The one you need in your case will be the "Open" which is defined as "Any entity may subscribe to the node (i.e., without the necessity for subscription approval) and any entity may retrieve items from the node (i.e., without being subscribed); this SHOULD be the default access model for generic pubsub services."
I hope this gives a clear answer to your question.

Related

How to receive cumulocity real time notifications with SmartREST?

We use the cumulocity REST API. Regular real time notifications work, e.g. we subscribe to /alarms/*, start our connection/polling loop and when we create an alarm we receive the expected JSON. We did not install any specific modules or statements, it just works.
But when we try to do the same with SmartREST we receive this error, as soon as the alarm is created:
40,,/alarms/177649296,Could not find any templates subscribed for the channel
Following the reference guide (http://cumulocity.com/guides/reference/smartrest/) we tried it like this, where all requests have the same X-Id-header and all requests result in the expected http status 200 and no error messages, except for the last one:
Register a smart response template by doing a POST to /s
Body: 11,102,,,$.channel
Handhake: POST to /cep/realtime
Body: 80
Response is our clientId (e.g. 191het1z38bp7iq1m96jqqt8jnef)
Subscribe: POST to /cep/realtime
Body: 81,191het1z38bp7iq1m96jqqt8jnef,/alarms/*
Connect: POST to /cep/realtime
Body: 83,191het1z38bp7iq1m96jqqt8jnef
In the normal REST case the notification consists of a JSON array with 2 elements, both of which have a property "channel". So that is what we would expect from our response template. Instead, we get the aforementioned error 40.
Is our response template wrong? Is it not properly matched by the X-Id? What does it mean, that there are no "templates subscribed for the channel"? The subscriptions are done for a clientId, and not for a specific response template, and the templates are supposed to be matched automatically anyway. So probably "template" means "X-Id" here? The documentation seems ambiguous as to the meaning of that word. But anyway, we did use the same X-Id header in all of the requests.
Any pointer about what we're doing wrong would be appreciated, since we tried pretty much anything by now.
The SmartREST protocol was developed for a IoT-device <-> platform communication. So there was never any design around using it to subscribing to realtime data (except of course for the operations a device needs) as usually devices to not need subscribe to the data that they created themselves.
That said it is possible to use it but with a couple of limitations. Your approach is basically correct but there is one problem with the subscription. The wildcard subscriptions will not work with SmartREST because on subscription it links your X-Id with the channel you subscribed to but there is never a message published on the channel /alarms/*. Thus this kind of weird error message that said that there was no template subscribed for the channel the alarm appeared on. Inside CometD you still receive the alarm because of the wildcard subscription but the SmartREST part does not work.
The messages are published on the channel with the deviceId (e.g. /alarms/12345).
If you subscribe to /alarms/12345 it will work. You can of course subscribe to as many channels as you want but wildcard subscription won't work.
Regarding the templates you need to know the following. The SmartREST parsing is not done on the raw JSON of CometD but on the payload inside it (e.g. the alarm). So a template for an alarm could look like this:
11,500,,$.severity,$.id,$.type,$.severity
This would trigger only if the object has a severity and would return id, type and severity.

How to add profiles via the FHIR REST api (HAPI)

I've looked at the documentation for creating profiles for FHIR, and I've used Forge to create some xml that I believe is valid to describe a profile. I can't find in the documentation where it actually states what request I need to make to the RESTful api to actually add a new profile.
Any ideas?
You can of course just "store" your profiles on a FHIR server by POSTing them to a FHIR endpoint, but you probably mean: can I actively let instances be validated against the StructureDefinition?
There are two ways, both of which require a bit of experimentation to see which public servers support them:
Any FHIR instance may declare it adheres to a StructureDefinition, by adding the canononical url (StructureDefinition.url) to the instances meta.profile as shown below. Servers may pick this up on a POST and validate the instance against the stated profile:
<Patient>
<id value="44Q3"/>
<meta>
<profile value="http://example.org/StructureDefinition/PatientNL"/>
</meta>
</Patient>
Actively ask a server to validate your instance using the $validate FHIR operation (see http://hl7.org/fhir/resource-operations.html#validate)

Smack MultiUserChatManager creates not joinable room

I am using Smack 4.1.1 as Gradle dependency in mine Android project.
I have successfully established connection with mine local OpenFire server.
But I have an issue while creating temporary room from Android client.
final MultiUserChat multiUserChat = userChatManager.getMultiUserChat(roomId);  
try {  
multiUserChat.create(connection.getUser());  
LOG.debug("room created");  
} catch (XMPPException.XMPPErrorException | SmackException e) {  
LOG.error("create room error:{}", e);  
}  
try{  
multiUserChat.sendConfigurationForm(new Form(DataForm.Type.submit));   
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException e) {  
LOG.error("sending room configurations error:{}", e);  
}   
The most great thing is that I can see that room was created in OpenFire admin panel and get room information from another client.
try {  
MultiUserChatManager userChatManager = MultiUserChatManager.getInstanceFor(connection);  
RoomInfo info = userChatManager.getRoomInfo(roomId);  
LOG.debug("room has {} occupants", info.getOccupantsCount());  
joinToExistingRoom(roomId);  
} catch (XMPPException.XMPPErrorException e) {  
LOG.error("join room error:{}", e);  
final XMPPError.Condition condition = e.getXMPPError().getCondition();  
if (condition == XMPPError.Condition.item_not_found) {  
LOG.error("room does not exist error:{}", e);  
createRoom(roomId);  
}  
}  
But while trying to join room from second client I receive XMPPError: recipient-unavailable - wait.
Snippet of mine joinRoom method:
final MultiUserChat multiUserChat = userChatManager.getMultiUserChat(roomId);  
try {  
multiUserChat.join(connection.getUser());  
LOG.debug("joined to room:{}", roomId);  
} catch (SmackException.NoResponseException  
| XMPPException.XMPPErrorException  
| SmackException.NotConnectedException e) {  
LOG.error("error joining room {}", e);  
}  
So I am catching error joining room org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError:recipient-unavailable - wait
So the question is what can be wrong?
I also tried creating submitForm from createAnswerForm() method. But the result is the same.
One solution I have found to make it work is to send persistantroom as true in Answer of configuration form. But this method creates persistent room, though I need this room to be destroyed after all attendees leave room.
Maybe it is a simple problem, but now I do not know how to solve this issue.
Help will be appreciated a lot.
Thanks in advance.
The create() method documentation states that:
Creates the room according to some default configuration, assign the requesting user as the room owner, and add the owner to the room but not allow anyone else to enter the room (effectively "locking" the room). The requesting user will join the room under the specified nickname as soon as the room has been created.
To create an "Instant Room", that means a room with some default configuration that is available for immediate access, the room's owner should send an empty form after creating the room.
Try to send configuration form this way:
multiUserChat.create(connection.getUser())
Form form = new Form(DataForm.Type.submit);
multiUserChat.sendConfigurationForm(form);
See also muc extension documentation

How to implement "last seen at" functionality (like whatsapp) in XMPP?

I am working on a chat application and want to add "last seen at" functionality. I am trying to implement it by using presence stanzas but getting one issue, please check at below link
Not getting unavailable presence of User A when User B is also unavailable
Is there any other way to implement last seen at functionality
please suggest
The first Google result for "xmpp last seen" is XEP-0012: Last Activity, which is a protocol extension that can be used to find out when a user was online last time.
You send a request like this:
<iq from='romeo#montague.net/orchard'
id='last1'
to='juliet#capulet.com'
type='get'>
<query xmlns='jabber:iq:last'/>
</iq>
And get a response like this:
<iq from='juliet#capulet.com'
id='last1'
to='romeo#montague.net/orchard'
type='result'>
<query xmlns='jabber:iq:last' seconds='903'/>
</iq>
Which means that the contact was last online 903 seconds ago. Subtract this from the current time to get the "last seen" timestamp.
Last seen and Last Activity are two different scenarios.
Last Activity is when user gone offline last time, but last seen is when user goes in background from the application in that case user will be available if application is not killed.You have to create new plugin on server side for last seen.
The #legoscia solution will return the last activity time, which is your last logout time(not the last time when user was online), plz check this https://github.com/processone/ejabberd/issues/2265
If the user has at least one connected or available resource when the server receives the request, the response MUST (subject to local security policies) contain an empty element whose 'seconds' attribute is set to a value of '0'.
One solution is to kill the session every time the app goes in background and reconnect when the app is in foreground

Whoisxmlapi API is not running

This API http://www.whoisxmlapi.com/whoisserver/WhoisService?domainName=xxxxxx is returning an error message as xml format.
<ErrorMessage>
<msg>
IP Address 203.100.79.84 has 0/50 queries available, please refill
</msg>
</ErrorMessage>
Can any one help me to sort this out. I need proper xml for a registered domain.
You're only allowed 50 queries for a free account. Check this page for options if you want to upgrade.