Monday, March 19, 2012

Base64 Encoding, Decoding


Base64 Encoding, Decoding

SCC_COMMON_UTILITIES.UTIL.Base64Wrapper.OnExecute
 (This Appl package has all the methods needed for base64 encode and decode)

class Base64Wrapper
   method Base64Wrapper();
   method encode(&filename As string) Returns string;
   method decode(&filename As string, &base64data As string) Returns boolean;
   rem method getErrorDetails() Returns string;
private
   instance JavaObject &joB64;
end-class;
method base64Encode
   Local number &nbr_retcode;
   Local File &file;
      &nbr_retcode = GetAttachment(&fileURL, &sysfilename, &tempFilename);
   %This.delay();
   If &nbr_retcode > 0 Then
      throw CreateException(18179, 207, "", &displayFilename);
   End-If;
   &Base64String = &b64w.encode(&tempFilename);
   %This.cleanupTempFile();
   end-method;;
method Base64Wrapper
   rem &joB64 = CreateJavaObject("com.peoplesoft.hrms.hrs.base64Utils");
   &joB64 = CreateJavaObject("com.peoplesoft.hr.sa.base64Utils");
end-method;
method encode
   /+ &filename as String +/
   /+ Returns String +/ 
   Local string &filedata;
   &filedata = &joB64.base64Encode(&filename);
   Return &filedata;
end-method;
method decode
   /+ &filename as String, +/
   /+ &base64data as String +/
   /+ Returns Boolean +/
   Return &joB64.base64Decode(&filename, &base64data);
   end-method;
/*method getErrorDetails
   /+ Returns String +/
   Return &joB64.getErrorDetails();
end-method;*/
HRS_HROI_RESUMEEXTRACT:Util(Application Package)
HRS_HROI:UTIL:Base64Wrapper;
class Base64Wrapper
   method Base64Wrapper();
   method encode(&filename As string) Returns string;
   method decode(&filename As string, &base64data As string) Returns boolean;
private
   instance JavaObject &joB64;
end-class;
method Base64Wrapper
   &joB64 = CreateJavaObject("com.peoplesoft.hrms.hrs.base64Utils");
end-method;
method encode
   /+ &filename as String +/
   /+ Returns String +/
      Local string &filedata; 
      &filedata = &joB64.base64Encode(&filename);
   Return &filedata;
end-method;
method decode
   /+ &filename as String, +/
   /+ &base64data as String +/
   /+ Returns Boolean +/
   Return &joB64.base64Decode(&filename, &base64data);
   end-method;;

1 comment: