com.google.code.facebookapi
Class FacebookSignatureUtil

java.lang.Object
  extended by com.google.code.facebookapi.FacebookSignatureUtil

public final class FacebookSignatureUtil
extends java.lang.Object

Utility for managing Facebook-specific parameters, specifically those related to session/login aspects.


Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
FacebookSignatureUtil()
           
 
Method Summary
static java.lang.StringBuilder generateBaseString(java.util.SortedMap<java.lang.String,java.lang.String> params)
           
static java.lang.String generateEmailHash(java.lang.String email)
           Normalize the email address.
static java.lang.String generateMD5(java.lang.String value)
           
static java.lang.String generateSignature(java.util.SortedMap<java.lang.String,java.lang.String> params, java.lang.String secret)
           
static java.util.SortedMap<java.lang.String,java.lang.String> getVerifiedParams(java.lang.String prefix, java.util.SortedMap<java.lang.String,java.lang.String> map, java.lang.String secret)
           
static java.util.SortedMap<java.lang.String,java.lang.String> pulloutFbSigParams(java.util.Map<java.lang.String,java.lang.String[]> reqParams)
           
static boolean verifySignature(java.util.SortedMap<java.lang.String,java.lang.String> params, java.lang.String secret)
          Verifies that a signature received matches the expected value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Constructor Detail

FacebookSignatureUtil

public FacebookSignatureUtil()
Method Detail

pulloutFbSigParams

public static java.util.SortedMap<java.lang.String,java.lang.String> pulloutFbSigParams(java.util.Map<java.lang.String,java.lang.String[]> reqParams)

verifySignature

public static boolean verifySignature(java.util.SortedMap<java.lang.String,java.lang.String> params,
                                      java.lang.String secret)
Verifies that a signature received matches the expected value. Removes FacebookParam.SIGNATURE from params if present.

Parameters:
params - a map of parameters and their values, such as one obtained from extractFacebookNamespaceParams; expected to contain the signature as the FacebookParam.SIGNATURE parameter
secret - the developers 'secret' API key
Returns:
a boolean indicating whether the calculated signature matched the expected signature

getVerifiedParams

public static java.util.SortedMap<java.lang.String,java.lang.String> getVerifiedParams(java.lang.String prefix,
                                                                                       java.util.SortedMap<java.lang.String,java.lang.String> map,
                                                                                       java.lang.String secret)

generateSignature

public static java.lang.String generateSignature(java.util.SortedMap<java.lang.String,java.lang.String> params,
                                                 java.lang.String secret)

generateBaseString

public static java.lang.StringBuilder generateBaseString(java.util.SortedMap<java.lang.String,java.lang.String> params)

generateMD5

public static java.lang.String generateMD5(java.lang.String value)

generateEmailHash

public static java.lang.String generateEmailHash(java.lang.String email)
  1. Normalize the email address. Trim leading and trailing whitespace, and convert all characters to lowercase.
  2. Compute the CRC32 value for the normalized email address and use the unsigned integer representation of this value. (Note that some implementations return signed integers, in which case you will need to convert that result to an unsigned integer.)
  3. Compute the MD5 value for the normalized email address and use the hex representation of this value (using lowercase for A through F).
  4. Combine these two value with an underscore.
For example, the address mary@example.com converts to 4228600737_c96da02bba97aedfd26136e980ae3761.

Parameters:
email -
Returns:
email_hash
See Also:
IFacebookRestClient.connect_registerUsers(Collection)


Copyright © 2010. All Rights Reserved.