diff options
author | hmartin | 2012-01-29 15:28:47 +0000 |
---|---|---|
committer | hmartin | 2012-01-29 15:28:47 +0000 |
commit | 71d0a363c9f3aa00f87f9481e6da5482984df1ab (patch) | |
tree | 774b4d9ace94afcff64be84b3c8a74d030c4f39c /protocols | |
parent | d9aca990075799b78f6bda6fccb0b6e44422212b (diff) | |
download | org.eclipse.ecf-71d0a363c9f3aa00f87f9481e6da5482984df1ab.tar.gz org.eclipse.ecf-71d0a363c9f3aa00f87f9481e6da5482984df1ab.tar.xz org.eclipse.ecf-71d0a363c9f3aa00f87f9481e6da5482984df1ab.zip |
Fixing the MSN provider issue
https://bugs.eclipse.org/bugs/show_bug.cgi?id=306270. As the initial
step adding MD5 Hash Implementation. In the next step will use the
reference doc to make 128 bit hash to 64 bit hash.
Diffstat (limited to 'protocols')
2 files changed, 30 insertions, 1 deletions
diff --git a/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/NotificationSession.java b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/NotificationSession.java index 49c4b5a8e..8ef37c8e5 100644 --- a/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/NotificationSession.java +++ b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/NotificationSession.java @@ -274,7 +274,9 @@ final class NotificationSession extends DispatchSession { } } else if (input.indexOf("CHL") != -1) { //$NON-NLS-1$ // the read input is a challenge string - String query = Challenge.createQuery(StringUtils.splitSubstring(input, " ", 2)); //$NON-NLS-1$ + // String query = Challenge.createQuery(StringUtils.splitSubstring(input, " ", 2)); //$NON-NLS-1$ + String query = MD5HashImpl.getMD5(StringUtils.splitSubstring(input, " ", 2)); + // Even this is wrong. we need to create a 64bit hash out of 128bit hash according to http://bit.ly/wdzdkd write("QRY", Challenge.PRODUCT_ID + ' ' + query.length() + "\r\n" //$NON-NLS-1$ //$NON-NLS-2$ + query, false); } else if (input.indexOf("RNG") != -1) { //$NON-NLS-1$ diff --git a/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/internal/encode/MD5HashImpl.java b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/internal/encode/MD5HashImpl.java new file mode 100644 index 000000000..78393ed68 --- /dev/null +++ b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/internal/encode/MD5HashImpl.java @@ -0,0 +1,27 @@ +package org.eclipse.ecf.protocol.msn.internal.encode; + +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class MD5HashImpl { + public static String getMD5(String input) { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] messageDigest = md.digest(input.getBytes()); + BigInteger number = new BigInteger(1, messageDigest); + String hashtext = number.toString(16); + // Now we need to zero pad it if you actually want the full 32 chars. + while (hashtext.length() < 32) { + hashtext = "0" + hashtext; + } + return hashtext; + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + } + + public static void main(String[] args) throws NoSuchAlgorithmException { + System.out.println(getMD5("22210219642164014968YMM8C_H7KCQ2S_KL")); + } +} |