String Encoding for Talend/JaspersoftETL for Basic Authentication/md5/sha-256

What is a convenient way to encode usernames/passwords for use in my ETL jobs?

First copy the java code on this Github Gist into your clipboard:
package routines;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import sun.misc.BASE64Encoder;
public class hashingUtils {
/**
* @return
* @throws NoSuchAlgorithmException
*/
public static String md5encode(String message) throws NoSuchAlgorithmException{
MessageDigest m=MessageDigest.getInstance("MD5");
m.update(message.getBytes(),0,message.length());
System.out.println("MD5: "+new BigInteger(1,m.digest()).toString(16));
return new BigInteger(1,m.digest()).toString(16);
}
public static String sha256encode(String message) throws NoSuchAlgorithmException{
MessageDigest m=MessageDigest.getInstance("SHA-256");
m.update(message.getBytes(),0,message.length());
System.out.println("SHA-256: "+new BigInteger(1,m.digest()).toString(16));
return new BigInteger(1,m.digest()).toString(16);
}
public static String basicAuth(String username, String password) {
System.out.println("Basic " + new BASE64Encoder().encodeBuffer((username+ ":"+password).getBytes()).replace("\n", "").replace("\r", ""));
return "Basic " + new BASE64Encoder().encodeBuffer((username+ ":"+password).getBytes()).replace("\n", "").replace("\r", "");
}
}



Second Create a routine called hashingUtils (name is important!). Paste the Java code from above and save the routine









Third you can now use the following methods in any component:

hashingUtils.basicAuth("username","password")
hashingUtils.md5encode("string")
hashingUtils.sha256encode("string")

For example, in a tHttpRequest Component:


Comments

campfire ark said…
Hi Sir,

First of all thankyou for sharing this video. Secondly my question is how its going to be secured ? because the other person can decode it very easily using the same as we do. Then how its providing security mechanism here i am unable to understand ?
I would like to know how to handle the login button rendering, when the page is reloaded it's visible for a brief period. What's the right way of storing this auth state? Should i store? Or default should be hidden and show when didn't auth?

Popular posts from this blog

Dealing with Nested Documents in MongoDB and Talend (aka Baking a Cake)

Add sbin to user PATH in Debian

Linux Software RAID Nagios Monitoring & Failure Simulation