Decode encoded string while transforming in openidm - forgerock

I want to decode the string while transforming the data from Active Directory to OpenIDM. Sync between the system is alright but one of the attribute have base64 encoded string.
I want to transform the property before persisting it into managed user object.
Anyone have any idea how can I achieve it. I tried few javascript ways but no success.

Finally I was able to achieve the decoding of the string using below transformation
if (source != null)
{
var base64 = Packages.org.forgerock.util.encode.Base64url
b64tO = new Packages.java.lang.String(base64.decode(source));
logger.info("Decoded: {}", b64tO);
target = b64tO;
}
Hope it help someone !!!

Related

unable to convert raw data to json format after replacing the \(slash)

I am passing the raw data and removing unwanted slash and trying to convert to json format, unable to proceed.
json spot = {"LoginDetails":"{\"firstName\":\"abcd\",\"lastName\":\"\",\"middleName\":\"\",\"phoneNumber\":\"6944000000\",\"phoneCountryCode\":\"+91\",\"dob\":\"1945-02-22\"}"}
string a = spot
def ab = a.replace("\\", "")
json st = ab
And request st
When method POST
Then status 200
Getting error
net.minidev.json.parser.ParseException: Unexpected token f
How to resolve this issue and convert the above payload into json format?
NOTE: After conversion to json firstname, phonenumber should be passed dynamically from the preceding API calls.
If u want escape slash with json, you could try
a.replaceAll("\\", "\\\\")
or change it to unicode.
a.replaceAll("\\", "\u005C")
Both of them is workable for browser but not sure for karate, maybe you need change a bit by yourself.

Is there a way to load externaldata from a variable URL in Kusto?

With Kusto's externaldata operator, I am able to load a text file from my website:
let appUsers = externaldata(userId:string)['https://www.mybusiness.com/files/salesforce-guid.txt'];
However I need to manipulate the URL string based on differing factors. When I try moving the URL into a variable, Kusto gives me syntax errors ( expected ']' )
let url = 'https://www.mybusiness.com/files/salesforce-guid.txt';
let appUsers = externaldata(userId:string)[url]; // syntax err
Is there a way for Kusto to load externaldata from a variable URL?
Such functionality doesn't exist.
You can suggest it on https://aka.ms/adx.uservoice

Pentaho JsonInput GET fields

I'm trying to use PDI to read data from an API (json) and now I'm simply trying to use json input to get a few specific fields but the get fields button on the input step gives me.
ERROR (version 8.3.0.0-371, build 8.3.0.0-371 from 2019-06-11 11.09.08 by buildguy) : Index 1 out of bounds for length 1
all the steps execute fine, and produce data - just not the json input step doesn't wnat to give me the fields option! - I've tired the text file and json oput and both write valid json so IDK whats going on....
PS. this is my first time using PDI
ISSUE 2:
It looks like PDI uses jayway for its json path parsing so I've been using this site https://jsonpath.herokuapp.com/ jayway selection which gives me my expected path. When I put that into the 'fields' of the json input dialog I only get the FIRST instance of that path value vs it actually parsing the json and giving me every instance, and can't figure out why though I assume it has something to do with PDI's row based view on things but I also don't know how to get it to understand that its json and it should be giving me back all values that match that path.
UPDATE 1:
I've been looking at this https://forums.pentaho.com/threads/135882-Parsing-JSON-data-without-knowing-field-names/ it seems like this Modified Java Script Value step might be the way to go. Will continue testing.
UPDATE 2
OK - Used the MJSV as posted above along with a select fields step and finally able to get the key's
var obj = JSON.parse(mydata);
var keys = Object.keys(obj);
for (var i = 0; i < Object.keys(obj).length; i++) {
var row = createRowCopy(getOutputRowMeta().size());
var idx = getInputRowMeta().size();
row[idx++] = keys[i];
putRow(row);
}
trans_Status = SKIP_TRANSFORMATION;

how to pass multiple type of data to API from server side as formdata?

I want to create circuit (messenger like skype) conversation from my server side code (C#) by calling circuit api.
Function : https://circuitsandbox.net/rest/v2/conversations/
I have to pass two type of parameters :
1) Participants - string array
2) topic - string
According to function definition (in swagger), I have to pass them as formdata. But, when I am trying to encode the parameters
var content = new FormUrlEncodedContent(values);
It is not accepting the array string for participants list. It is expecting "key/value" pair as "string/string".
I have even tried to create the JSON serialization also
JsonConvert.SerializeObject(values)
But the API definition is not accepting this converted values as it is expecting formdata in string/string as key/value.
I had even tried to concatenate the participants list with ";" as delimiter. But in that case, I am getting 400 error.
I tried to convert my parameters like this also
var formData = new List>();
formData.Add(new KeyValuePair("participants", JsonConvert.SerializeObject( participants)));
formData.Add(new KeyValuePair("topic", "Testing1"));
But again, I a getting 400 error.
Here is my API call
var response = client.PostAsync("https://circuitsandbox.net/rest/v2/conversations/group", content);
Can someone provide me some code snippet to pass that this data to API?
Let me emphasis, I am trying from server side code (C#) and not jquery code.
as we checked together earlier today, make the participants value a comma separated string of emails and it should work

Talend - Dynamic Column Name (Enterprise version)

Can anyone help me solve this case?
I have much file to process, two of them is like on below screenshot with my expected output.
I use this transformation on Talend: tFileList---tInputExcel---tUnpivotRow---tMap---tPostgresqlOutput
The output is different to my expected output. This is the screenshot of the output
Can anyone help me to reach my expected output which is like on my first picture above?
This will be pretty hard. You'd have to handle that as a text file. And whenever you found "store" value in the first column you'd update your type with the value.
Here's how I'd start:
Basically tJavaFlex begin piece would contain:
String col1Type
String colNType
main part:
if input_row.col0.equalsIgnoreCase("store") {
col1Type = input_row.col1;
col2Type = input_row.col2;
colNType = input_row.colN;
continue; /*(so this record will be Ignored for the rest of the components!)*/
}
output_row.col1Type = col1Type;
output_row.col1Value = Integer.valueOf(input_row.col1);
/*coz we have text and need numbers :( */
I think using propagate results will save you from writing down all the other fields.
And from here it would be very simple as you have key-type-value-type-value-type-value results.