How to create a JID from the Username - xmpp

I've been running the echo.html example that comes with Strophe.js. When I start it up I sign in using a user I made called user1. When I click the connect button I get the following output:
Strophe is connecting.
Strophe is connected.
ECHOBOT: Send a message to 5ee09j8v8y#ubuntu/5ee09j8v8y to talk to me.
I am able to successfully test this example using the Gajim client. In Gajim I simply start a new chat using the above JID (5ee09j8v8y#ubuntu/5ee09j8v8y). When I send a message using Gajim it shows up on the echobot example and everything is hunky dory.
So here's my question, I see from this official site that the JID is in this format:
<JID> ::= [<node>"#"]<domain>["/"<resource>]
And I get that the resource is optional, and that the domain in my case above is simply my computer's name (my computer's name is ubuntu). BUT what I don't get is how the heck you get 5ee09j8v8y from the username user1.
The code inside echobot.js which prints the JID line above uses this command to get the information:
connection.jid
Which is just a Strophe.Connection Object retrieving it's JID.
So to sum all of this up, I cannot communicate from Gajim using user1#ubuntu/5ee09j8v8y the only way it works is when I use the JID 5ee09j8v8y#ubuntu/5ee09j8v8y. So what exactly is the node (5ee09j8v8y), how does it get mapped to the username (user1), how can I get Gajim to work with user1#ubuntu/5ee09j8v8y instead of using 5ee09j8v8y#ubuntu/5ee09j8v8y and at the very least can someone point me in the right direction to some documentation on this JID problem?
Note: This tutorial will explain my setup (and help others who are curious in how I set all of this up).

Related

What is the workflow for a basic Auth OIDC with Keycloak

I have keycloak on docker (v20.0.2) and as you know some versions change some or good part of the UI, so is hard to follow tutorials around the web...
I am trying to follow this particular tuto
https://developers.redhat.com/blog/2020/11/24/authentication-and-authorization-using-the-keycloak-rest-api#keycloak_sso_demo
that seems the more updated. My keycloak is actually behind traeffic and thomseddon/traeffic-fordward-auth with a docker-compose file (but the connection through traeffic is good and I have acces to admin UI)
So on step 10 of the tutorial things change for me, I have to look for that particular view inside:
Click on lateral menu Client Scope
Click on button Create client scope
Give a name to the scope, and click on Tab Mapper
All mappers are predefined... so there is no "New mapper" don't understand this bit
then just follow the tuto
With that series of steps I get an error when retriving the token...
https://keycloak:8443/realms/education/protocol/openid-connect/token
enter image description here
(this are fake local data from the realm I created for testing)
that responds with a or something similar I have also tried to change the grant_type to password, and the same happens can not query the token....
{
"error": "invalid_client",
"error_description": "Invalid client or Invalid client credentials"
}
But if I do not link a user with an scope/role as in the tuto suggest then I get the token, but of course I want to use the role or scope to limit who can see which endpoint and who can not
Any step that I'm missing from this update, do you have the same error?
Thank you in advance
I have tried to run it with different combinations of options to see if there is a toggle that actually allows me to fetch the token
Also with different types of grant_type
I will build an API in Python (I don't know Java and prefer Json instead of XML) that connect to this keycloak to allow users or not based on their scope/role/permission or something
I need to be able to block user so if user Student try to access an url from another Student he get blocked that url. So is based on the role or scope or I don't know which is prefered or easer to accomplish, the mission is to block users or not based on a factor that could be used for this in keycloak.

error: Failed to run the post merge process

I'm trying to generate documents using conga composer 8 from apex code but its failing with error Failed to run the post-merge process. I have looked into url and its same as the one I used initially in another salesforce org. I couldn't find any help online or on conga-composer form.
Here is my conga endpoint URL:
https://composer.congamerge.com/Composer8/Index.Html? sessionId=00D41000000dorw!ARQAQKbinH5TXMR_70s3XCShQh5GuSVdrFcq0Fg9OidZLo9MLxzWSby8QY1B4xM8e72DPawVziclnXBjTzpG41RiCAPKQqOt
&serverUrl=https://na35.salesforce.com/services/Soap/u/29.0/00D41000000dorwEAA
&id=a1J410000012BwS
&TemplateId=a0C41000000kg5GEAQ
&APIMODE=13
&ESAgreementName=Contract+for+Test
&queryid=a0441000001PwI7AAK,a0441000001PwICAA0
&ESSignatureType=2
&ESSignatureOrder=2
&ESVisible=1
&ESCustomField=cldocgen__App__c
&ESCustomFieldValue=a1J410000012BwSEAU
&ESRecipient1=00541000000Ke9pAAC
&ESRecipient2=003410000078zVbAAI
&ESRecipient3=003410000078zVhAAI, Method=GET]
Any insight what might be causing this issue.
I had the same problem and was able to solve it using permissions. In this case make sure the user id whose sessionID is passing to Conga has the correct CRUD access to the primary object in your conga call (id=a1J410000012BwS). My guess is that this is something to do with Conga not being able to write the attachment back to salesforce.
Apart from what Greg has mentioned, there are 2 more observations for this error:
Under Email Administration -> Deliverability -> Access to Send Email (All Email Services) should be set to All email.
In case you are using the EmailTemplateId parameter then the classic email template must be available for use.
Also mostly this error is also because of some discrepancy in the URL.

Stop Hubot (with Flowdock) from responding to itself?

I'm using Hubot with the Hubot-Flowdock adapter.
I'm using robot.hear to respond to messages with a certain string in them (e.g. "chocolate").
I then call msg.send with a message, which also happens to contain the trigger string ("chocolate") in it.
This causes Hubot to hear itself, and then just loop endlessly, triggering over and over again.
I'm trying to find a way to get Hubot to not respond to itself.
From what I gather, the Hubot Campfire adapter seems to include a specific check to prevent Hubot from listening to itself:
https://github.com/github/hubot/blob/b96ea30654ef2dbf93f710c6e310c909fa1bdd65/src/adapters/campfire.coffee#L71
However, other adapters don't seem to have this.
Is there another way to write a Hubot script with robot.hear and msg.send such that it will not respond to itself?
I found the answer to this - Hubot is not meant to respond/hear itself.
It's the responsibility of each adapter to handle filtering these messages out.
Some adapter (e.g. hubot-hipchat) will actually set the hubot bot name to the name of the user you authenticate in Hubot as.
In the case of hubot-flowdock, it will check the hubot bot name against the Flowdock "Display name" of the user you authenticate as - so you just need to make sure those match up (either by changing the "Display name" on the Flowdock account page, or using the -n flag or HUBOT_NAME environment variable to set the bot name).

How can I connect with strophejs using an email address as a user name.

I am able to connect successfully to Open fire using strophe, unfortunately, when a users username is in the format of an email, the connection incorrectly uses everything that is after the first # symbol as the domain. Then the connection does not work.
Is this a bug or is this something that can be done differently (e.g by using some format to specify the domain some other way).
Thanks
Call Strophe.escapeNode(string to escape) before sending the username/jid to the server.
var jid = Strophe.escapeNode(foo#domain.com) + '#jabberserver.com';

IMAP "Invalid Credentials" via GMail XOAUTH

I'm trying to get into the IMAP server with OAuth, using the PHP Sample Code provided by Google which uses the Zend Imap class but I am failing to authenticate. Zend is giving me the error:
Zend_Mail_Storage_Exception [ Error ]: cannot select INBOX, is this a valid transport?
Annoyingly this is a rather confusing error message, for what is essentially "Invalid Credentials". How did I know that? By debugging the actual commands being send to the IMAP socket I see this:
string(44) "NO Invalid credentials ey9if1544983wid.142
"
I have tried with telnet and a Ruby gmail_xoauth gem which suggests it is not a code issue, but something else.
Looking at the most basic level of all this, I am getting commands like this:
TAG1 AUTHENTICATE XOAUTH R0VUIGh0dHBzOi8vbWFpbC5nb29nbGUuY29tL21h......etc
This is where I get NO Invalid credentials then:
TAG2 SELECT "INBOX"
This returns BAD Unknown command and kicks me out.
I have tried searching around for people having the same problem but I find only questions and no answers. There are a few similar StackOverflow questions:
One post shows somebody having the exact same problem in Python.
This post shows somebody trying to be awkward and do it with OAuth 2, with no report of success.
There is a thread on the GMail Google Group that suggests an "Invalid Credentials" error can be resolved by going to https://accounts.google.com/DisplayUnlockCaptcha for GMail accounts and https://www.google.com/a/[YOURDOMAIN.COM]/UnlockCaptcha if you are using Google Apps, but the latter just said that my username and password were wrong when they clearly were not. Using this https://accounts.google.com/DisplayUnlockCaptcha worked fine - even though my account is a hosted App, not plain old GMail - however I still get the same errors when trying to log back in with the PHP sample code provided by Google.
I've tried with various hosted Google App accounts and a plain GMail account. I've tried switching the IMAP server from imap.gmail.com to imap.googlemail.com, nothing makes any difference.
/**
* Make the IMAP connection and send the auth request
*/
$imap = new Zend_Mail_Protocol_Imap('imap.googlemail.com', '993', true);
$authenticateParams = array('XOAUTH', $initClientRequestEncoded);
$imap->requestAndResponse('AUTHENTICATE', $authenticateParams);
/**
* Print the INBOX message count and the subject of all messages
* in the INBOX
*/
$storage = new Zend_Mail_Storage_Imap($imap);
echo '<h1>Total messages: ' . $storage->countMessages() . "</h1>\n";
For those with an interest, this is the specific PHP code that sets up the connection, all XOauth is handled by Google's PHP in the same file but I skipped it.
I had this exact same error, and eventually realised I was using the wrong scope when requesting the OAuth permissions.
You need to have...
scope=https://mail.google.com/
access_type=offline
And also IMAP enabled in your Gmail account obviously. All seems good now.
One problem you may have is that the third parameter of Zend_Mail_Protocol_Imap('imap.googlemail.com', '993', true); should not be true. It should be a string, as either "SSL" or "TLS". I believe you want "SSL" if going over port 993. It's only a boolean when it is FALSE.
Try replacing that first line with this:
$imap = new Zend_Mail_Protocol_Imap('imap.googlemail.com', '993', 'SSL');
When i had this same error message, it was because
$options['consumerSecret'] = $THREE_LEGGED_CONSUMER_SECRET_HMAC;
I was doing that in a function and variable $THREE_LEGGED... wasn't in the scope. Pretty stupid and i'm sure that you'd have spotted that but just in case somebody new is reading that.