The removal of "fb_sig" parameter from params map will throw an
UnsupportedOperationException when the map comes from
request.getParameterMap(), because it is an immutable map.
I fixed this with an ugly one, by creating a new map wrapper like
this :
Map<String,String[]> reqParams = request.getParameterMap();
Map<String,String[]> x = new HashMap<String, String[]>(reqParams);
Map<String, CharSequence> z = new HashMap<String, CharSequence>();
for(Entry<String, String[]> e : x.entrySet()){
z.put(e.getKey(), e.getValue()[0].subSequence(0, e.getValue()
[0].length()));
} // z is now mutable, fb_sig can be removed
Also, I don't really understand the whole CharSequence or
CharSequence[] constructors/utilities around FacebookSignatureUtil
verifications, given that request.getParameterMap is a
Map<String,String[]> as defined in
http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.ht...()
, not a CharSequence one.
Off the top of my head (not looking at code), you have to use two methods in FacebookSignatureUtils, one to convert map and one to verify signature. I can't remember the method names, but they are there. There should really be a single method to do it, but it's not there.
On Jan 3, 2008 3:48 AM, Laurent Perez <hak...@gmail.com> wrote:
> The removal of "fb_sig" parameter from params map will throw an > UnsupportedOperationException when the map comes from > request.getParameterMap(), because it is an immutable map.
> I fixed this with an ugly one, by creating a new map wrapper like > this :
> Map<String,String[]> reqParams = request.getParameterMap(); > Map<String,String[]> x = new HashMap<String, String[]>(reqParams); > Map<String, CharSequence> z = new HashMap<String, CharSequence>(); > for(Entry<String, String[]> e : x.entrySet()){ > z.put(e.getKey(), e.getValue()[0].subSequence(0, e.getValue() > [0].length())); > } // z is now mutable, fb_sig can be removed
> Also, I don't really understand the whole CharSequence or > CharSequence[] constructors/utilities around FacebookSignatureUtil > verifications, given that request.getParameterMap is a > Map<String,String[]> as defined in
I've added an FacebookSignatureUtil.autoVerifySignature() API call
that will automatically convert the map before trying to modify it. I
would have modified the existing verifySignature() implementation to
perform the same task, but I noticed that that API call is not meant
to be passed the results of request.getParameterMap() (which as you
noted returns a Map<String,String[]>, while that method was expecting
a Map<String, CharSequence>...the only reason you weren't getting a
ClassCastException when you passed request.getParameterMap() to it was
that the method tries to modify the Map before it reads anythong from
it). According to the javadoc on it, you are supposed to manually
call extractFacebookNamespaceParams on the map before invoking that
API call.
Anyways, the new FacebookSignatureUtil.autoVerifySignature() call
should now do it all for you.
On Jan 4, 7:47 am, "Travis Reeder" <tree...@gmail.com> wrote:
> Off the top of my head (not looking at code), you have to use two methods in
> FacebookSignatureUtils, one to convert map and one to verify signature. I
> can't remember the method names, but they are there. There should really be
> a single method to do it, but it's not there.
> On Jan 3, 2008 3:48 AM, Laurent Perez <hak...@gmail.com> wrote:
> > Hi
> > The removal of "fb_sig" parameter from params map will throw an
> > UnsupportedOperationException when the map comes from
> > request.getParameterMap(), because it is an immutable map.
> > I fixed this with an ugly one, by creating a new map wrapper like
> > this :
> > Map<String,String[]> reqParams = request.getParameterMap();
> > Map<String,String[]> x = new HashMap<String, String[]>(reqParams);
> > Map<String, CharSequence> z = new HashMap<String, CharSequence>();
> > for(Entry<String, String[]> e : x.entrySet()){
> > z.put(e.getKey(), e.getValue()[0].subSequence(0, e.getValue()
> > [0].length()));
> > } // z is now mutable, fb_sig can be removed
> > Also, I don't really understand the whole CharSequence or
> > CharSequence[] constructors/utilities around FacebookSignatureUtil
> > verifications, given that request.getParameterMap is a
> > Map<String,String[]> as defined in
ar...@bigtribe.com wrote: > I've added an FacebookSignatureUtil.autoVerifySignature() API call > that will automatically convert the map before trying to modify it. I > would have modified the existing verifySignature() implementation to > perform the same task, but I noticed that that API call is not meant > to be passed the results of request.getParameterMap() (which as you > noted returns a Map<String,String[]>, while that method was expecting > a Map<String, CharSequence>...the only reason you weren't getting a > ClassCastException when you passed request.getParameterMap() to it was > that the method tries to modify the Map before it reads anythong from > it). According to the javadoc on it, you are supposed to manually > call extractFacebookNamespaceParams on the map before invoking that > API call.
> Anyways, the new FacebookSignatureUtil.autoVerifySignature() call > should now do it all for you.
> On Jan 4, 7:47 am, "Travis Reeder" <tree...@gmail.com> wrote:
>> Off the top of my head (not looking at code), you have to use two methods in >> FacebookSignatureUtils, one to convert map and one to verify signature. I >> can't remember the method names, but they are there. There should really be >> a single method to do it, but it's not there.
>> On Jan 3, 2008 3:48 AM, Laurent Perez <hak...@gmail.com> wrote:
>>> Hi
>>> The removal of "fb_sig" parameter from params map will throw an >>> UnsupportedOperationException when the map comes from >>> request.getParameterMap(), because it is an immutable map.
>>> I fixed this with an ugly one, by creating a new map wrapper like >>> this :
>>> Map<String,String[]> reqParams = request.getParameterMap(); >>> Map<String,String[]> x = new HashMap<String, String[]>(reqParams); >>> Map<String, CharSequence> z = new HashMap<String, CharSequence>(); >>> for(Entry<String, String[]> e : x.entrySet()){ >>> z.put(e.getKey(), e.getValue()[0].subSequence(0, e.getValue() >>> [0].length())); >>> } // z is now mutable, fb_sig can be removed
>>> Also, I don't really understand the whole CharSequence or >>> CharSequence[] constructors/utilities around FacebookSignatureUtil >>> verifications, given that request.getParameterMap is a >>> Map<String,String[]> as defined in
> ar...@bigtribe.com wrote:
> > I've added an FacebookSignatureUtil.autoVerifySignature() API call
> > that will automatically convert the map before trying to modify it. I
> > would have modified the existing verifySignature() implementation to
> > perform the same task, but I noticed that that API call is not meant
> > to be passed the results of request.getParameterMap() (which as you
> > noted returns a Map<String,String[]>, while that method was expecting
> > a Map<String, CharSequence>...the only reason you weren't getting a
> > ClassCastException when you passed request.getParameterMap() to it was
> > that the method tries to modify the Map before it reads anythong from
> > it). According to the javadoc on it, you are supposed to manually
> > call extractFacebookNamespaceParams on the map before invoking that
> > API call.
> > Anyways, the new FacebookSignatureUtil.autoVerifySignature() call
> > should now do it all for you.
> > On Jan 4, 7:47 am, "Travis Reeder" <tree...@gmail.com> wrote:
> >> Off the top of my head (not looking at code), you have to use two methods in
> >> FacebookSignatureUtils, one to convert map and one to verify signature. I
> >> can't remember the method names, but they are there. There should really be
> >> a single method to do it, but it's not there.
> >> On Jan 3, 2008 3:48 AM, Laurent Perez <hak...@gmail.com> wrote:
> >>> Hi
> >>> The removal of "fb_sig" parameter from params map will throw an
> >>> UnsupportedOperationException when the map comes from
> >>> request.getParameterMap(), because it is an immutable map.
> >>> I fixed this with an ugly one, by creating a new map wrapper like
> >>> this :
> >>> Map<String,String[]> reqParams = request.getParameterMap();
> >>> Map<String,String[]> x = new HashMap<String, String[]>(reqParams);
> >>> Map<String, CharSequence> z = new HashMap<String, CharSequence>();
> >>> for(Entry<String, String[]> e : x.entrySet()){
> >>> z.put(e.getKey(), e.getValue()[0].subSequence(0, e.getValue()
> >>> [0].length()));
> >>> } // z is now mutable, fb_sig can be removed
> >>> Also, I don't really understand the whole CharSequence or
> >>> CharSequence[] constructors/utilities around FacebookSignatureUtil
> >>> verifications, given that request.getParameterMap is a
> >>> Map<String,String[]> as defined in
> ar...@bigtribe.com wrote:
> > I've added an FacebookSignatureUtil.autoVerifySignature() API call
> > that will automatically convert the map before trying to modify it. I
> > would have modified the existing verifySignature() implementation to
> > perform the same task, but I noticed that that API call is not meant
> > to be passed the results of request.getParameterMap() (which as you
> > noted returns a Map<String,String[]>, while that method was expecting
> > a Map<String, CharSequence>...the only reason you weren't getting a
> > ClassCastException when you passed request.getParameterMap() to it was
> > that the method tries to modify the Map before it reads anythong from
> > it). According to the javadoc on it, you are supposed to manually
> > call extractFacebookNamespaceParams on the map before invoking that
> > API call.
> > Anyways, the new FacebookSignatureUtil.autoVerifySignature() call
> > should now do it all for you.
> > On Jan 4, 7:47 am, "Travis Reeder" <tree...@gmail.com> wrote:
> >> Off the top of my head (not looking at code), you have to use two methods in
> >> FacebookSignatureUtils, one to convert map and one to verify signature. I
> >> can't remember the method names, but they are there. There should really be
> >> a single method to do it, but it's not there.
> >> On Jan 3, 2008 3:48 AM, Laurent Perez <hak...@gmail.com> wrote:
> >>> Hi
> >>> The removal of "fb_sig" parameter from params map will throw an
> >>> UnsupportedOperationException when the map comes from
> >>> request.getParameterMap(), because it is an immutable map.
> >>> I fixed this with an ugly one, by creating a new map wrapper like
> >>> this :
> >>> Map<String,String[]> reqParams = request.getParameterMap();
> >>> Map<String,String[]> x = new HashMap<String, String[]>(reqParams);
> >>> Map<String, CharSequence> z = new HashMap<String, CharSequence>();
> >>> for(Entry<String, String[]> e : x.entrySet()){
> >>> z.put(e.getKey(), e.getValue()[0].subSequence(0, e.getValue()
> >>> [0].length()));
> >>> } // z is now mutable, fb_sig can be removed
> >>> Also, I don't really understand the whole CharSequence or
> >>> CharSequence[] constructors/utilities around FacebookSignatureUtil
> >>> verifications, given that request.getParameterMap is a
> >>> Map<String,String[]> as defined in
> On Jan 7, 12:49am, Cesar Arevalo <carev...@cakefinancial.com> wrote: > > Hi Aroth,
> > I don't see the changes you mention.
> > -Cesar
> > ar...@bigtribe.com wrote: > > > I've added an FacebookSignatureUtil.autoVerifySignature() API call > > > that will automatically convert the map before trying to modify it. I > > > would have modified the existing verifySignature() implementation to > > > perform the same task, but I noticed that that API call is not meant > > > to be passed the results of request.getParameterMap() (which as you > > > noted returns a Map<String,String[]>, while that method was expecting > > > a Map<String, CharSequence>...the only reason you weren't getting a > > > ClassCastException when you passed request.getParameterMap() to it was > > > that the method tries to modify the Map before it reads anythong from > > > it). According to the javadoc on it, you are supposed to manually > > > call extractFacebookNamespaceParams on the map before invoking that > > > API call.
> > > Anyways, the new FacebookSignatureUtil.autoVerifySignature() call > > > should now do it all for you.
> > > On Jan 4, 7:47 am, "Travis Reeder" <tree...@gmail.com> wrote:
> > >> Off the top of my head (not looking at code), you have to use two methods in > > >> FacebookSignatureUtils, one to convert map and one to verify signature. I > > >> can't remember the method names, but they are there. There should really be > > >> a single method to do it, but it's not there.
> > >> On Jan 3, 2008 3:48 AM, Laurent Perez <hak...@gmail.com> wrote:
> > >>> Hi
> > >>> The removal of "fb_sig" parameter from params map will throw an > > >>> UnsupportedOperationException when the map comes from > > >>> request.getParameterMap(), because it is an immutable map.
> > >>> I fixed this with an ugly one, by creating a new map wrapper like > > >>> this :
> > >>> Map<String,String[]> reqParams = request.getParameterMap(); > > >>> Map<String,String[]> x = new HashMap<String, String[]>(reqParams); > > >>> Map<String, CharSequence> z = new HashMap<String, CharSequence>(); > > >>> for(Entry<String, String[]> e : x.entrySet()){ > > >>> z.put(e.getKey(), e.getValue()[0].subSequence(0, e.getValue() > > >>> [0].length())); > > >>> } // z is now mutable, fb_sig can be removed
> > >>> Also, I don't really understand the whole CharSequence or > > >>> CharSequence[] constructors/utilities around FacebookSignatureUtil > > >>> verifications, given that request.getParameterMap is a > > >>> Map<String,String[]> as defined in