Byte Array in Peoplesoft

Byte Array in Peoplesoft:
What is Byte Array?
The Byte Array service provides a mechanism to create an array of bytes. This can be useful for sending a raw data packets containing binary information. Basically passing contents of files/Images in a byte (array) format.
If you google Byte Array it is very hard to find the definition and you can find lot of java programs for converting File to Byte Array or Vice Versa.
Byte Array and Peoplesoft:
While integrating peoplesoft with a third party tool i got a situation to pass the file as byte array. I searched in google but in vein i didn’t get even a single clue. Then i thought of using java to overcome this issue.
Latter i find an article from Jims Blog regarding the Base64 encoding, which really gave me a good idea to continue.
From Jims Blog: (Thanks Jim)
We need to create an Algorithm Chain and an Encryption Profile. PeopleBooks does an excellent job of explaining each of these terms as well as telling how to create each of these components. Since PeopleSoft delivers the base64 encryption algorithm with the PSPETSSL encryption library, we can move right into defining the Algorithm Chain. To define the chain, navigate to PeopleTools > Security > Encryption > Algorithm Chain. Add the new value BASE64_ENCODE and add the following Algorithms in order:
PSUnicodeToAscii
base64_encode
PSAsciiToUnicode
Be sure to set the sequence number for each row (1-3). Save and navigate to PeopleTools > Security > Encryption > Encryption Profile. Add the new value BASE64_ENCODE. Specify the algorithm chain BASE64_ENCODE and save. We can now test this pluggable encryption profile with a little PeopleCode:
Local object &crypto =
CreateObject("Crypt");&crypto.Open("BASE64_ENCODE");&crypto.UpdateData("Hello World");MessageBox(0, "", 0, 0, "Encrypted: " &crypto.Result);
And, the result should be: SGVsbG8gV29ybGQ=.


Latter i searched in Peoplesoft technically, how they are attaching the file and how they are viewing it. Really it is true they are using Byte array to do that. Atlast we can use one liner code to achieve this.


Local HRS_HROI:UTIL:Base64Wrapper &b64e;
Local string &b64encoded;
&b64e = create HRS_HROI:UTIL:Base64Wrapper();
&b64encoded = &b64e.encode("C:\temp\test.txt");

Use the App Package HRS_HROI:UTIL to do this Magic J




Comments

  1. @mymithraa, thank you for sharing this information. I wasn't aware of a delivered App class for base64 encoding binary files.

    I opened the app class HRS_HROI:UTIL:Base64Wrapper and looked at it's code. I noticed that it uses Java to read a file from disk and converts its binary data to base64.

    Unfortunately, the app class and corresponding Java class are HRMS specific. If you need to base64 encode a file in a different application, you can write your own Java class to do the same thing.

    By the way, the final solution you presented doesn't actually use pluggable encryption. I'm not sure pluggable encryption has anything to offer here because it doesn't provide a mechanism for reading binary files. At this time, Java is the only method I know of for reading binary files from disk.

    ReplyDelete

Post a Comment

Popular posts from this blog

Peoplesoft SFTP

How to find the Java Version being used by WebLogic

Peoplesoft Error: All Processing Suspended: Restart OPRID=PS, RUNID=RUN01, PI=5000(108,503)