Project

General

Profile

Actions

Feature #948

closed

Script sms sender

Added by Ondřej Kopr about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Ondřej Kopr
Target version:
Start date:
02/05/2018
Due date:
% Done:

100%

Estimated time:
Owner:

Description

Implement new sender (extends from AbstractSmsNotificationSender)

The sender will send sms via script. To script will be add all necessary attributes for sending.
Example script will be created.


Files

sonar_sms_module.png (149 KB) sonar_sms_module.png Peter Štrunc, 03/29/2018 01:12 PM
Actions #2

Updated by Ondřej Kopr about 6 years ago

  • Tracker changed from Task to Feature
  • Project changed from IdStory Identity Manager to sms
  • Category deleted (Notification)
  • Status changed from New to In Progress
  • Target version changed from Hematite (8.0.0) to 1.0.0

This feature will be implement as new standalone module.

Actions #3

Updated by Ondřej Kopr about 6 years ago

  • % Done changed from 0 to 60

I implement first version of new SMS module with one implementation sms 'driver' with GET method.

Commit: https://git.bcvsolutions.eu/modules/sms/commit/4411482fb900cd3f0221b42d926874bc659ecb53
Documentation:
https://wiki.czechidm.com/devel/documentation/modules_sms
https://wiki.czechidm.com/tutorial/adm/modules_sms

Default configurations:

# Enable property for SMS GET script driver
idm.sec.sms.script.get.enabled
#
# Login that will be used for composes URL with gateway
idm.sec.sms.script.get.login
#
# Password that will be used for composes URL with gatewat
idm.sec.sms.script.get.password
#
# Script that be used for composes URL
idm.sec.sms.script.get.scriptCode
#
# Timeout for comunication with gatewat
idm.sec.sms.script.get.timeout
#
# Number that will be used for overriding all recipient number (for testing or?)
idm.sec.sms.script.get.overrideNumber

Actions #4

Updated by Ondřej Kopr about 6 years ago

I founded some minor issues:
  • when I use method createLog from AbstractSmsNotificationSender isn't filled topic.
  • Method merge in AbstractSmsNotificationSender, merge log with probably some errors, for example result: "null | ",

With fix these methods I wait to Peter S.

Actions #5

Updated by Ondřej Kopr about 6 years ago

  • % Done changed from 60 to 80
Actions #6

Updated by Ondřej Kopr about 6 years ago

  • Status changed from In Progress to Needs feedback
  • Assignee changed from Ondřej Kopr to Petr Michal
  • % Done changed from 80 to 90

I made two new implementation for sms gateway:

  • DefaultSmsBranaSmsSender
  • DefaultHtmlSmsSender

tests are included + documentation was updated

You must choose which sender will be used: https://wiki.czechidm.com/devel/documentation/application_configuration/backend#notification_senders

Please Petr could you test this snapshot version? Thank you very much :)

Actions #7

Updated by Petr Michal about 6 years ago

  • Assignee changed from Petr Michal to Ondřej Kopr

I tested this wonderful feature.
Good news is that I was able to send sms throw your defaultHtmlSmsSender!

But here are some problems I have encountered:
  • Topic for generated password does not contains module prefix.
  • Topic sends messages to the administrator instead of person who needs the new passwords. (of course, I like this feature, but its probably dangerous security bug).
  • Message sending does not work if the user has a national prefix in phone number. But if I send messages from the terminal, then prefix works.
  • I was a bit confused with the sender property settings (correct property name), please modify this section of the documentation.
Actions #8

Updated by Petr Michal about 6 years ago

I fixed documentation from the last point. No need to deal with it anymore.

Actions #9

Updated by Ondřej Kopr about 6 years ago

  • Assignee changed from Ondřej Kopr to Petr Michal

Thank you for feedback,

  • Topic for generated password does not contains module prefix.
  • This is probably bug for password reset module, this isn't related to sms gateway module, what topic name do you mean? You probably can report this into password reset module.
  • Topic sends messages to the administrator instead of person who needs the new passwords. (of course, I like this feature, but its probably dangerous security bug),
  • what topic do you mean? Sms script sender doesn't contains topics, with what topic is the problem?
  • Message sending does not work if the user has a national prefix in phone number. But if I send messages from the terminal, then prefix works.
  • please could you send me your script for composed url with smsm gateway? You need probably encoded character '+',
  • I was a bit confused with the sender property settings (correct property name), please modify this section of the documentation.
  • with what configuration property did you have a problem? Configuration property
# sender implementation
idm.sec.<module>.notification-sender.<notificationType>.impl=<beanName>

must works, I used it in a tests and it is part of core module.

Could you please test send notification with encoded character '+' if it works?

Actions #10

Updated by Ondřej Kopr about 6 years ago

Petr Michal wrote:

Topic sends messages to the administrator instead of person who needs the new passwords. (of course, I like this feature, but its probably dangerous security bug).

This bug will be solved in https://redmine.czechidm.com/issues/1022 as new version 1.2.1

Actions #11

Updated by Ondřej Kopr about 6 years ago

  • Assignee changed from Petr Michal to Radek Tomiška
Actions #13

Updated by Marcel Poul about 6 years ago

  • Assignee changed from Radek Tomiška to Peter Štrunc

Pls Peter do us a favor and make a review, thx.

Actions #14

Updated by Peter Štrunc about 6 years ago

I did review. New sender is really cool, I found only a few minor things

  • Fix doc grammar
  • AbstractScriptSmsNotificationSender#getSmsNumber TODO - create ticket for it, do not let it be forgotten
  • AbstractScriptSmsNotificationSender#isEnabledSendSms is unused. Maybe you wanted to use it in sendSms on line 152?
  • AbstractScriptSmsNotificationSender#sendSms is a little long to my taste, i would break it down a little bit
  • TODO in createFailedLog. Is it really TODO? what should be changed?
  • Why is AbstractScriptSmsNotificationSender abstract and then DefaultScriptSmsSender is just empty class with overridden constructor and component annotation? Why does not DefaultScriptSmsSender contain the base implementation from AbstractScriptSmsNotificationSender and other senders (eg. DefaultSmsBranaSender) just extend DefaultScriptSmsSender. I am not saying it is wrong, i just need explanation on why did you decide to do it like this, because it now looks strange to me.
  • Invalid link to SmsGetResponseExtractor in javadoc in SmsGetConfiguration#isResponseDebug. You must use whole className including package (if class is not imported)

I also added screenshot from sonar analysis. Some of the issues are nosense but some are quite helpful, so take a look at it and decide if anything is worth fixing.

Actions #15

Updated by Ondřej Kopr about 6 years ago

  • Status changed from In Progress to Needs feedback
  • Assignee changed from Ondřej Kopr to Peter Štrunc

Thanks for feedback,

  • i'm not friend with english, all english documentation that we write is written according to our best conscience, please if you found some grammar mistake feel free to edit, I can spent some days and read all documentation that I write into wiki.czechidm.com, but for this exists so many better persons than me,
  • create new ticket for TODO's is good idea, thank you :) ,
  • I removed method isEnabledSendSms, thanks for hint,
  • I agree, long methods is way to hell, but 60 rows with some spaces and LOG calls, isn't so bad, in this case I iterate over recipient and fill result list and skip some recipient (like missing sms number), so I try add some new private method, please check new behavior, (I removed all spaces and empty lines + create two new private methods)
  • TODO in createFailedLog is right TODO, because when you set only smsLogDto.setState(NotificationState.NOT) without smsLogDto.setSent(null) on FE is this message marked as successful sent. I haven't time for debug this problem. I remove this todo, but for next we must not forget this 'bug?',
  • javadoc in SmsGetConfiguration was fixed, this is propably most dangerous bug in this module :D.
Report from sonar:
  • hardcoded password, this ins't bug for me, this is constant, but If you really want, I can change this constant to something else, but for me isn't this importatnt,
  • refactor method from 16 to 15, i'm little bit confused what exactly is wrong with this method?
  • add format for string into method getSmsGatewayUrl,
  • constats PARAM_LOGIN, PARAM_PASSWORD, PARAM_NUMBER, PARAM_MESSAGE have underscore, but we use this for constant, see application code, are you sure with fix this with only [a-z][a-zA-Z0-9]?
  • slf4j LOG is already final and static,
  • I removed unused import,
  • I removed generic types from constructor in DefaultSmsBranaSmsSender,
  • constans in SmsGetConfiguration is correct,we use constants in interfaces, see core, acc and etc.

Thanks for big feedback I didn't expect so many problems, Vitek already created new project on our sonar. Thank you and please could you made a second code review? Thank you.

Actions #16

Updated by Ondřej Kopr about 6 years ago

Thanks for check with sonar I also fixed issues from our sonar, thank you :) (the plugin for eclipse with sonar is great idea!).

Actions #17

Updated by Peter Štrunc about 6 years ago

  • Status changed from Needs feedback to In Progress
  • Assignee changed from Peter Štrunc to Ondřej Kopr

Fixes are OK. You can close the ticket now.

Actions #18

Updated by Petr Fišer about 6 years ago

Merged into master.

Actions #19

Updated by Ondřej Kopr about 6 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100

Thanks for merge. I close the ticket.

Actions

Also available in: Atom PDF