ericdai / pwm

Automatically exported from code.google.com/p/pwm
0 stars 0 forks source link

SMS sending fails if detected browser locale is not known / empty #120

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,
First of all thanks for providing this great tool :) 

What steps will reproduce the problem?
1. setup SMS sending for forgotten password token
2. set browser language/locale to English[en] or something else not defined in 
/pwm/WEB-INF/classes/password/pwm/PwmConstants.properties - locale.knownLocales 
- section
3. try to forgotten password functionality

What is the expected output? What do you see instead?
- sendind token to SMS fails, if browser locale is en

What version of PWM are you using?
- v1.5.6 b1078 (devbuild) 

What ldap directory and version are you using?
- edirectory 8.8 SP6

Please paste any error log messages below:

## This line comes when browser locale is en

011-09-28 12:02:17, TRACE, pwm.SessionFilter, {1} user locale set to '' 
[xx.xx.xx.xx]

## after trying to sent SMS you get this error

2011-09-28 12:02:36, DEBUG, servlet.ForgottenPasswordServlet, {1} token SMS 
added to send queue for +xxxxxxxx [xx.xx.xx.xx]
2011-09-28 12:02:37, ERROR, util.SmsQueueManager, unexpected exception while 
processing sms queue: The JsonDeserializer LocaleTypeAdapter failed to 
deserialize json object "" given the type class java.util.Locale
com.google.gson.JsonParseException: The JsonDeserializer LocaleTypeAdapter 
failed to deserialize json object "" given the type class java.util.Locale
        at com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExceptionWrapper.java:64)
        at com.google.gson.JsonDeserializationVisitor.invokeCustomDeserializer(JsonDeserializationVisitor.java:92)
        at com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(JsonObjectDeserializationVisitor.java:117)
        at com.google.gson.ReflectingFieldNavigator.visitFieldsReflectively(ReflectingFieldNavigator.java:63)
        at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:120)
        at com.google.gson.JsonDeserializationVisitor.visitChild(JsonDeserializationVisitor.java:110)
        at com.google.gson.JsonDeserializationVisitor.visitChildAsObject(JsonDeserializationVisitor.java:99)
        at com.google.gson.JsonObjectDeserializationVisitor.visitObjectField(JsonObjectDeserializationVisitor.java:63)
        at com.google.gson.ReflectingFieldNavigator.visitFieldsReflectively(ReflectingFieldNavigator.java:69)
        at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:120)
        at com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializationContextDefault.java:76)
        at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:54)
        at com.google.gson.Gson.fromJson(Gson.java:551)
        at com.google.gson.Gson.fromJson(Gson.java:498)
        at com.google.gson.Gson.fromJson(Gson.java:467)
        at com.google.gson.Gson.fromJson(Gson.java:417)
        at com.google.gson.Gson.fromJson(Gson.java:389)
        at password.pwm.util.SmsQueueManager.processQueue(SmsQueueManager.java:245)
        at password.pwm.util.SmsQueueManager.access$500(SmsQueueManager.java:58)
        at password.pwm.util.SmsQueueManager$SmsSendThread.run(SmsQueueManager.java:468)
Caused by: java.lang.NullPointerException
        at java.util.Locale.toLowerCase(Unknown Source)
        at java.util.Locale.convertOldISOCodes(Unknown Source)
        at java.util.Locale.<init>(Unknown Source)
        at java.util.Locale.<init>(Unknown Source)
        at com.google.gson.DefaultTypeAdapters$LocaleTypeAdapter.deserialize(DefaultTypeAdapters.java:610)
        at com.google.gson.DefaultTypeAdapters$LocaleTypeAdapter.deserialize(DefaultTypeAdapters.java:587)
        at com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExceptionWrapper.java:51)
        ... 19 more
2011-09-28 12:02:37, ERROR, util.SmsQueueManager, unable to process sms queue 
successfully; sleeping for 1m

## You need to add to this file also en to knowlocales, 
# or any other locale your user is using in their browsers.
##/pwm/WEB-INF/classes/password/pwm/PwmConstants.properties
#locale.knownLocales=cs;;;de;;;en;;;es;;;fr;;;iw;;;it.....

# Then when you access to system en is detected
# and SMS sending works 
2011-09-28 12:23:30, TRACE, pwm.SessionFilter, {4} user locale set to 'en' 
[xx.xx.xx.xx]

# I think locale detection in SMS module should failover
# to english (en) or something like that if no detected locale is found.

Original issue reported on code.google.com by tami.rau...@gmail.com on 28 Sep 2011 at 9:52

GoogleCodeExporter commented 8 years ago
The work-around workd, but only after removing the pwmDB so the SMSqueue was 
empty. The SmsQueuManager got stuck on the first queued message and never 
recovered.

Is there a more elegant way to clear the sms queue?

Original comment by mrva...@gmail.com on 17 Oct 2011 at 4:03

GoogleCodeExporter commented 8 years ago
I hereby confirm the problem and have tried to figure it out. The Email queue 
does not have the problem, but makes the same calls to gson. The only relevant 
difference that I could find is that the SMS module uses Locales to get a 
configuration option, while the Email module does not.

Adding "en;;;" to the properties file indeed solves the problem, but I have no 
idea what side effects may occur, except that "en" is shown as an extra locale 
in the configuration screens. Apart from that, all seems to work fine.

Original comment by menno.pi...@gmail.com on 17 Oct 2011 at 9:03

GoogleCodeExporter commented 8 years ago
should be resolved in svn revision 280.  please check.

Original comment by jrivard on 30 Oct 2011 at 4:19

GoogleCodeExporter commented 8 years ago
Closing as resolved, please re-open if this is still an issue.

Original comment by jrivard on 24 Nov 2011 at 3:14