├── setupRepo.sh ├── service ├── app │ ├── controllers │ │ ├── search │ │ │ └── SearchController.java │ │ ├── usermanagement │ │ │ ├── UserTypeController.java │ │ │ ├── UserLoginController.java │ │ │ ├── validator │ │ │ │ ├── UserStatusRequestValidator.java │ │ │ │ ├── UserDataEncryptionRequestValidator.java │ │ │ │ └── ResetPasswordRequestValidator.java │ │ │ ├── ResetPasswordController.java │ │ │ ├── UserMergeController.java │ │ │ ├── UserStatusController.java │ │ │ ├── IdentifierFreeUpController.java │ │ │ └── UserRoleController.java │ │ ├── scheduler │ │ │ └── SchedulerController.java │ │ ├── tac │ │ │ ├── UserTnCController.java │ │ │ └── validator │ │ │ │ └── UserTnCRequestValidator.java │ │ ├── organisationmanagement │ │ │ └── KeyManagementController.java │ │ ├── otp │ │ │ └── OtpController.java │ │ └── tenantmigration │ │ │ └── TenantMigrationController.java │ ├── util │ │ ├── RBACUtil.java │ │ └── Attrs.java │ ├── modules │ │ ├── StartModule.java │ │ └── SignalHandler.java │ ├── filters │ │ └── AccessLogFilter.java │ ├── org │ │ └── sunbird │ │ │ └── validator │ │ │ └── systemsettings │ │ │ └── SystemSettingsRequestValidator.java │ └── mapper │ │ └── RequestMapper.java ├── .gitignore ├── conf │ └── log4j2.properties └── test │ └── controllers │ ├── DummyActor.java │ └── ApplicationTest.java ├── actors └── sunbird-lms-mw │ ├── actors │ ├── sunbird-utils │ │ ├── sunbird-platform-core │ │ │ ├── sunbird-commons │ │ │ │ └── .gitignore │ │ │ ├── actor-core │ │ │ │ ├── .gitignore │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── org │ │ │ │ │ └── sunbird │ │ │ │ │ └── actor │ │ │ │ │ ├── core │ │ │ │ │ ├── RouterMode.java │ │ │ │ │ └── RouterException.java │ │ │ │ │ ├── router │ │ │ │ │ └── ActorConfig.java │ │ │ │ │ └── service │ │ │ │ │ └── SunbirdMWService.java │ │ │ ├── actor-util │ │ │ │ ├── .gitignore │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── org │ │ │ │ │ └── sunbird │ │ │ │ │ ├── actorutil │ │ │ │ │ ├── email │ │ │ │ │ │ ├── EmailServiceClient.java │ │ │ │ │ │ └── EmailServiceFactory.java │ │ │ │ │ └── systemsettings │ │ │ │ │ │ └── SystemSettingClient.java │ │ │ │ │ └── models │ │ │ │ │ ├── systemsetting │ │ │ │ │ └── SystemSetting.java │ │ │ │ │ └── location │ │ │ │ │ └── Location.java │ │ │ ├── common-util │ │ │ │ ├── .gitignore │ │ │ │ └── src │ │ │ │ │ ├── main │ │ │ │ │ ├── resources │ │ │ │ │ │ ├── elasticsearch.config.properties │ │ │ │ │ │ ├── sso.properties │ │ │ │ │ │ ├── dbconfig.properties │ │ │ │ │ │ ├── OTPSMSTemplate.vm │ │ │ │ │ │ ├── welcomeSmsTemplate.vm │ │ │ │ │ │ ├── cassandra.config.properties │ │ │ │ │ │ ├── mailTemplates.properties │ │ │ │ │ │ └── userencryption.properties │ │ │ │ │ └── java │ │ │ │ │ │ └── org │ │ │ │ │ │ └── sunbird │ │ │ │ │ │ ├── services │ │ │ │ │ │ └── sso │ │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ │ ├── impl │ │ │ │ │ │ │ └── package-info.java │ │ │ │ │ │ │ └── SSOServiceFactory.java │ │ │ │ │ │ ├── common │ │ │ │ │ │ ├── exception │ │ │ │ │ │ │ └── package-info.java │ │ │ │ │ │ ├── request │ │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ │ └── orgvalidator │ │ │ │ │ │ │ │ └── BaseOrgRequestValidator.java │ │ │ │ │ │ ├── models │ │ │ │ │ │ │ ├── util │ │ │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ │ │ ├── mail │ │ │ │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ │ │ │ └── GMailAuthenticator.java │ │ │ │ │ │ │ │ ├── azure │ │ │ │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ │ │ │ ├── CloudService.java │ │ │ │ │ │ │ │ │ └── AzureCloudService.java │ │ │ │ │ │ │ │ ├── datasecurity │ │ │ │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ │ │ │ ├── impl │ │ │ │ │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ │ │ │ │ └── LogMaskServiceImpl.java │ │ │ │ │ │ │ │ │ └── OneWayHashing.java │ │ │ │ │ │ │ │ ├── url │ │ │ │ │ │ │ │ │ └── URLShortner.java │ │ │ │ │ │ │ │ ├── BulkUploadJsonKey.java │ │ │ │ │ │ │ │ ├── GeoLocationJsonKey.java │ │ │ │ │ │ │ │ ├── LocationActorOperation.java │ │ │ │ │ │ │ │ ├── TelemetryEnvKey.java │ │ │ │ │ │ │ │ ├── BulkUploadActorOperation.java │ │ │ │ │ │ │ │ ├── EmailValidator.java │ │ │ │ │ │ │ │ ├── FileUtil.java │ │ │ │ │ │ │ │ ├── EntryExitLogEvent.java │ │ │ │ │ │ │ │ └── PhoneValidator.java │ │ │ │ │ │ │ └── response │ │ │ │ │ │ │ │ ├── package-info.java │ │ │ │ │ │ │ │ ├── ClientErrorResponse.java │ │ │ │ │ │ │ │ └── Params.java │ │ │ │ │ │ ├── responsecode │ │ │ │ │ │ │ └── package-info.java │ │ │ │ │ │ └── util │ │ │ │ │ │ │ └── Matcher.java │ │ │ │ │ │ └── telemetry │ │ │ │ │ │ ├── util │ │ │ │ │ │ ├── TelemetryParams.java │ │ │ │ │ │ ├── TelemetryConstant.java │ │ │ │ │ │ └── TelemetryEvents.java │ │ │ │ │ │ ├── validator │ │ │ │ │ │ └── TelemetryObjectValidator.java │ │ │ │ │ │ ├── collector │ │ │ │ │ │ ├── TelemetryDataAssembler.java │ │ │ │ │ │ ├── TelemetryAssemblerFactory.java │ │ │ │ │ │ └── TelemetryDataAssemblerImpl.java │ │ │ │ │ │ └── dto │ │ │ │ │ │ ├── Actor.java │ │ │ │ │ │ ├── Producer.java │ │ │ │ │ │ ├── Target.java │ │ │ │ │ │ └── TelemetryBJREvent.java │ │ │ │ │ └── test │ │ │ │ │ └── java │ │ │ │ │ └── org │ │ │ │ │ └── sunbird │ │ │ │ │ └── common │ │ │ │ │ ├── models │ │ │ │ │ ├── util │ │ │ │ │ │ ├── SlugTest.java │ │ │ │ │ │ ├── datasecurity │ │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ │ └── OnWayhashingTest.java │ │ │ │ │ │ ├── URLShortnerImplTest.java │ │ │ │ │ │ ├── AuditLogTest.java │ │ │ │ │ │ └── EmailTest.java │ │ │ │ │ ├── ResponseParamsTest.java │ │ │ │ │ └── RequestParamsTest.java │ │ │ │ │ └── request │ │ │ │ │ └── RequestTest.java │ │ │ └── pom.xml │ │ ├── sunbird-cassandra-utils │ │ │ ├── src │ │ │ │ ├── test │ │ │ │ │ ├── java │ │ │ │ │ │ └── org │ │ │ │ │ │ │ └── sunbird │ │ │ │ │ │ │ └── cassandra │ │ │ │ │ │ │ ├── CassandraStandaloneTest.java │ │ │ │ │ │ │ └── CassandraTest.java │ │ │ │ │ └── resources │ │ │ │ │ │ ├── cassandra.config.properties │ │ │ │ │ │ └── cassandra.cql │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── org │ │ │ │ │ └── sunbird │ │ │ │ │ ├── cassandraannotation │ │ │ │ │ ├── ClusteringKey.java │ │ │ │ │ └── PartitioningKey.java │ │ │ │ │ └── helper │ │ │ │ │ ├── CassandraConnectionMngrFactory.java │ │ │ │ │ ├── ServiceFactory.java │ │ │ │ │ └── CassandraConnectionManager.java │ │ │ └── .gitignore │ │ ├── sunbird-es-utils │ │ │ ├── .gitignore │ │ │ └── src │ │ │ │ ├── test │ │ │ │ ├── resources │ │ │ │ │ └── elasticsearch.config.properties │ │ │ │ └── java │ │ │ │ │ └── org │ │ │ │ │ └── sunbird │ │ │ │ │ ├── helper │ │ │ │ │ ├── ElasticSearchMappingTest.java │ │ │ │ │ ├── ElasticSearchSettingsTest.java │ │ │ │ │ └── ConnectionManagerTest.java │ │ │ │ │ └── common │ │ │ │ │ └── factory │ │ │ │ │ └── EsClientFactoryTest.java │ │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── org │ │ │ │ │ └── sunbird │ │ │ │ │ ├── helper │ │ │ │ │ ├── ElasticSearchSettings.java │ │ │ │ │ └── ElasticSearchMapping.java │ │ │ │ │ └── common │ │ │ │ │ └── factory │ │ │ │ │ └── EsClientFactory.java │ │ │ │ └── resources │ │ │ │ └── indices │ │ │ │ └── org.json │ │ ├── sunbird-notification │ │ │ ├── .gitignore │ │ │ └── src │ │ │ │ ├── main │ │ │ │ ├── java │ │ │ │ │ └── org │ │ │ │ │ │ └── sunbird │ │ │ │ │ │ └── notification │ │ │ │ │ │ ├── sms │ │ │ │ │ │ ├── provider │ │ │ │ │ │ │ └── ISmsProviderFactory.java │ │ │ │ │ │ ├── providerimpl │ │ │ │ │ │ │ ├── Msg91SmsProviderFactory.java │ │ │ │ │ │ │ ├── NICGatewaySmsProviderFactory.java │ │ │ │ │ │ │ └── ProviderDetails.java │ │ │ │ │ │ └── Sms.java │ │ │ │ │ │ └── utils │ │ │ │ │ │ ├── JsonUtil.java │ │ │ │ │ │ └── SMSFactory.java │ │ │ │ └── resources │ │ │ │ │ └── configuration.properties │ │ │ │ └── test │ │ │ │ ├── resources │ │ │ │ └── configuration.properties │ │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── sunbird │ │ │ │ └── notification │ │ │ │ ├── utils │ │ │ │ └── PropertiesCacheTest.java │ │ │ │ └── sms │ │ │ │ └── Message91GetSMSTest.java │ │ ├── .gitignore │ │ ├── auth-verifier │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── org │ │ │ │ │ └── sunbird │ │ │ │ │ └── auth │ │ │ │ │ └── verifier │ │ │ │ │ ├── KeyData.java │ │ │ │ │ └── CryptoUtil.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── sunbird │ │ │ │ └── auth │ │ │ │ └── verifier │ │ │ │ └── KeyManagerTest.java │ │ └── pom.xml │ ├── common │ │ ├── .gitignore │ │ └── src │ │ │ ├── test │ │ │ ├── resources │ │ │ │ ├── BulkOrgUploadEmptyFile.csv │ │ │ │ ├── BulkSelfDeclaredUserUploadEmpty.csv │ │ │ │ ├── BulkUploadUserWithInvalidHeaders.csv │ │ │ │ ├── BulkOrgUploadSample.csv │ │ │ │ ├── BulkSelfDeclaredUserUploadImproperSample.csv │ │ │ │ ├── BulkUploadUserSample.csv │ │ │ │ └── BulkSelfDeclaredUserUploadSample.csv │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── sunbird │ │ │ │ └── learner │ │ │ │ └── util │ │ │ │ ├── OTPUtilTest.java │ │ │ │ ├── UserFlagEnumTest.java │ │ │ │ ├── UserFlagUtilTest.java │ │ │ │ └── FormApiUtilTest.java │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── sunbird │ │ │ ├── actor │ │ │ └── background │ │ │ │ └── BackgroundOperations.java │ │ │ ├── ratelimit │ │ │ ├── limiter │ │ │ │ ├── RateLimiter.java │ │ │ │ └── OtpRateLimiter.java │ │ │ ├── service │ │ │ │ └── RateLimitService.java │ │ │ └── dao │ │ │ │ └── RateLimitDao.java │ │ │ ├── learner │ │ │ ├── actors │ │ │ │ ├── bulkupload │ │ │ │ │ ├── model │ │ │ │ │ │ ├── SelfDeclaredStatusEnum.java │ │ │ │ │ │ ├── SelfDeclaredErrorTypeEnum.java │ │ │ │ │ │ └── StorageDetails.java │ │ │ │ │ └── dao │ │ │ │ │ │ └── BulkUploadProcessDao.java │ │ │ │ ├── role │ │ │ │ │ ├── dao │ │ │ │ │ │ ├── RoleDao.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── RoleDaoImpl.java │ │ │ │ │ └── group │ │ │ │ │ │ ├── dao │ │ │ │ │ │ └── RoleGroupDao.java │ │ │ │ │ │ └── service │ │ │ │ │ │ └── RoleGroupService.java │ │ │ │ ├── url │ │ │ │ │ └── action │ │ │ │ │ │ ├── dao │ │ │ │ │ │ └── UrlActionDao.java │ │ │ │ │ │ └── service │ │ │ │ │ │ └── UrlActionService.java │ │ │ │ ├── notificationservice │ │ │ │ │ └── dao │ │ │ │ │ │ └── EmailTemplateDao.java │ │ │ │ └── otp │ │ │ │ │ └── dao │ │ │ │ │ └── OTPDao.java │ │ │ ├── organisation │ │ │ │ ├── dao │ │ │ │ │ └── OrgDao.java │ │ │ │ └── service │ │ │ │ │ ├── OrgService.java │ │ │ │ │ └── impl │ │ │ │ │ └── OrgServiceImpl.java │ │ │ └── util │ │ │ │ ├── ExecutorManager.java │ │ │ │ ├── UserFlagEnum.java │ │ │ │ ├── SchedulerManager.java │ │ │ │ └── UserFlagUtil.java │ │ │ ├── error │ │ │ ├── RowComparator.java │ │ │ ├── IErrorDispatcher.java │ │ │ ├── ErrorEnum.java │ │ │ ├── CsvError.java │ │ │ ├── CsvErrorDispatcher.java │ │ │ ├── CsvRowErrorDetails.java │ │ │ └── ListErrorDispatcher.java │ │ │ ├── models │ │ │ ├── user │ │ │ │ ├── FeedStatus.java │ │ │ │ └── FeedAction.java │ │ │ ├── url │ │ │ │ └── action │ │ │ │ │ └── UrlAction.java │ │ │ ├── role │ │ │ │ ├── group │ │ │ │ │ └── RoleGroup.java │ │ │ │ └── Role.java │ │ │ ├── systemsetting │ │ │ │ └── SystemSetting.java │ │ │ ├── adminutil │ │ │ │ ├── AdminUtilRequest.java │ │ │ │ └── AdminUtilRequestData.java │ │ │ └── FormUtil │ │ │ │ └── FormUtilRequest.java │ │ │ ├── feed │ │ │ ├── impl │ │ │ │ └── FeedFactory.java │ │ │ └── IFeedService.java │ │ │ ├── bean │ │ │ ├── ClaimStatus.java │ │ │ └── SelfDeclaredUser.java │ │ │ └── validator │ │ │ └── user │ │ │ └── UserTenantMigrationRequestValidator.java │ ├── user │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── sunbird │ │ │ │ └── user │ │ │ │ ├── util │ │ │ │ ├── UserConstants.java │ │ │ │ ├── KafkaConfigConstants.java │ │ │ │ ├── DateUtil.java │ │ │ │ └── UserActorOperations.java │ │ │ │ ├── service │ │ │ │ ├── UserMergeService.java │ │ │ │ ├── UserRoleService.java │ │ │ │ ├── UserConsentService.java │ │ │ │ ├── UserSelfDeclarationService.java │ │ │ │ ├── UserExternalIdentityService.java │ │ │ │ ├── AssociationMechanism.java │ │ │ │ ├── UserLookupService.java │ │ │ │ └── impl │ │ │ │ │ └── UserConsentServiceImpl.java │ │ │ │ ├── dao │ │ │ │ ├── UserExternalIdentityDao.java │ │ │ │ ├── UserOrgDao.java │ │ │ │ ├── UserRoleDao.java │ │ │ │ ├── UserSelfDeclarationDao.java │ │ │ │ ├── UserConsentDao.java │ │ │ │ └── UserLookupDao.java │ │ │ │ └── actors │ │ │ │ ├── UserLoginActor.java │ │ │ │ └── UserLookupActor.java │ │ │ └── test │ │ │ └── java │ │ │ └── org │ │ │ └── sunbird │ │ │ └── user │ │ │ ├── service │ │ │ └── UserMergeServiceImplTest.java │ │ │ └── UserLoginActorTest.java │ ├── location │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── sunbird │ │ │ └── location │ │ │ ├── service │ │ │ └── LocationService.java │ │ │ └── dao │ │ │ ├── impl │ │ │ └── LocationDaoFactory.java │ │ │ └── LocationDao.java │ ├── organization │ │ └── pom.xml │ ├── pom.xml │ └── systemsettings │ │ └── src │ │ └── main │ │ └── java │ │ └── org │ │ └── sunbird │ │ └── systemsettings │ │ └── dao │ │ └── SystemSettingDao.java │ ├── service │ └── src │ │ ├── test │ │ ├── resources │ │ │ ├── dbconfig.properties │ │ │ ├── BulkUploadUserSample.csv │ │ │ └── BulkOrgUploadSampleWithRootOrgTrue.csv │ │ └── java │ │ │ └── org │ │ │ └── sunbird │ │ │ └── learner │ │ │ └── actors │ │ │ └── OrgExternalServiceTest.java │ │ └── main │ │ └── java │ │ └── org │ │ └── sunbird │ │ └── middleware │ │ └── Application.java │ ├── .gitignore │ └── pom.xml ├── installDeps.sh ├── metadata.sh ├── tools └── java-format │ └── google-java-format-1.5-all-deps.jar ├── scripts ├── setup.sh └── check-java-file-format ├── .gitignore ├── git-hooks └── pre-commit ├── dockerPushToRepo.sh ├── Dockerfile.Build ├── README.md ├── deploy.sh ├── Dockerfile ├── .circleci └── config.yml └── LICENSE /setupRepo.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /service/app/controllers/search/SearchController.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /service/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /bin/ 3 | /.classpath 4 | /.project 5 | /.settings 6 | /logs 7 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/sunbird-commons/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/src/test/java/org/sunbird/cassandra/CassandraStandaloneTest.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /installDeps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Build script 3 | # set -o errexit 4 | 5 | #apk -v --update --no-cache add jq 6 | sudo apt-get install -y jq -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.classpath 3 | /.project 4 | /.settings 5 | /logs 6 | /bin/ 7 | velocity.log 8 | -------------------------------------------------------------------------------- /metadata.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # return version 3 | echo '{"name":"learner_service","version":"1.15.0","org":"sunbird","hubuser":"purplesunbird"}' 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | .settings 5 | /bin/ 6 | 7 | *.iml 8 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.project 3 | /.settings 4 | /.classpath 5 | 6 | /bin/ 7 | 8 | *.iml 9 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | .settings 5 | /bin/ 6 | 7 | *.iml 8 | *.log 9 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-core/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.classpath 3 | /.project 4 | /.settings 5 | /logs 6 | /bin/ 7 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-util/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | .settings 5 | /bin/ 6 | 7 | *.iml 8 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | .settings 5 | /bin/ 6 | 7 | *.iml 8 | -------------------------------------------------------------------------------- /tools/java-format/google-java-format-1.5-all-deps.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sphere/sunbird-lms-service/master/tools/java-format/google-java-format-1.5-all-deps.jar -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/resources/BulkOrgUploadEmptyFile.csv: -------------------------------------------------------------------------------- 1 | orgName,isTenant,channel,externalId,provider,description,homeUrl,organisationType,contactDetail -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/.gitignore: -------------------------------------------------------------------------------- 1 | **/target/** 2 | **/.project 3 | **/.settings 4 | /.idea 5 | /*.iml 6 | *.iml 7 | *.log 8 | **/velocity.log* 9 | **/.DS_Store -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/src/test/resources/elasticsearch.config.properties: -------------------------------------------------------------------------------- 1 | es.cluster.name=test 2 | es.host.name=localhost 3 | es.host.port=9300 -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/service/src/test/resources/dbconfig.properties: -------------------------------------------------------------------------------- 1 | db.ip=127.0.0.1 2 | db.port=9042 3 | db.username=cassandra 4 | db.password=password 5 | db.keyspace=sunbird 6 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/resources/elasticsearch.config.properties: -------------------------------------------------------------------------------- 1 | es.cluster.name= 2 | es.host.name=localhost 3 | es.host.port=9300 -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/resources/sso.properties: -------------------------------------------------------------------------------- 1 | sso.url= 2 | sso.realm=sunbird 3 | sso.connection.pool.size=20 4 | sso.enabled=true 5 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/resources/BulkSelfDeclaredUserUploadEmpty.csv: -------------------------------------------------------------------------------- 1 | Diksha UUID,Status,State provided ext. ID,Channel,School Name,School UDISE ID,Phone number,Email ID,Persona,Error Type -------------------------------------------------------------------------------- /scripts/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" 4 | 5 | cp "${REPO_ROOT_DIR}/git-hooks/pre-commit" "${REPO_ROOT_DIR}/.git/hooks/" 6 | echo "format hooks registered" 7 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.services.sso; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.common.exception; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.common.request; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/resources/dbconfig.properties: -------------------------------------------------------------------------------- 1 | db.ip=127.0.0.1 2 | db.port=9042 3 | db.username= 4 | db.password= 5 | db.keyspace=sunbird 6 | 7 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.common.models.util; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.services.sso.impl; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/responsecode/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.common.responsecode; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/resources/BulkUploadUserWithInvalidHeaders.csv: -------------------------------------------------------------------------------- 1 | firstName,lastName,phone,email,userName,countryCode,password,roles,position,location,dob,gender,language,profileSummary,subject,webPages 2 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.common.models.response; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.common.models.util.mail; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.common.models.util.azure; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/resources/OTPSMSTemplate.vm: -------------------------------------------------------------------------------- 1 | One time password to verify your phone number on $installationName is $otp. This is valid for $otpExpiryInMinutes minutes only. -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.common.models.util.datasecurity; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | /** @author Manzarul */ 3 | package org.sunbird.common.models.util.datasecurity.impl; 4 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryParams.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.util; 2 | 3 | public enum TelemetryParams { 4 | CHANNEL, 5 | ENV, 6 | ACTOR; 7 | } 8 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/actor/background/BackgroundOperations.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.actor.background; 2 | 3 | /** @author Mahesh Kumar Gangula */ 4 | public enum BackgroundOperations { 5 | registerChannel, 6 | emailService; 7 | } 8 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/ratelimit/limiter/RateLimiter.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.ratelimit.limiter; 2 | 3 | public interface RateLimiter { 4 | 5 | Integer getRateLimit(); 6 | 7 | int getTTL(); 8 | 9 | String name(); 10 | } 11 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/main/java/org/sunbird/notification/sms/provider/ISmsProviderFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.notification.sms.provider; 2 | 3 | public interface ISmsProviderFactory { 4 | 5 | ISmsProvider create(); 6 | } 7 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/RouterMode.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.actor.core; 2 | 3 | /** @author Mahesh Kumar Gangula */ 4 | public enum RouterMode { 5 | OFF, 6 | LOCAL, 7 | REMOTE; 8 | } 9 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/url/URLShortner.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util.url; 2 | 3 | public interface URLShortner { 4 | 5 | public String shortUrl(String url); 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | project/project 3 | project/target 4 | target 5 | tmp 6 | .history 7 | dist 8 | /.idea 9 | /*.iml 10 | *.iml 11 | *.log 12 | RUNNING_PID 13 | /out 14 | /.idea_modules 15 | /.classpath 16 | /.project 17 | /.settings 18 | /.target/ 19 | /bin/ 20 | /logs 21 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/bulkupload/model/SelfDeclaredStatusEnum.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.bulkupload.model; 2 | 3 | public enum SelfDeclaredStatusEnum { 4 | SUBMITTED, 5 | VALIDATED, 6 | REJECTED, 7 | ERROR 8 | } 9 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/resources/BulkOrgUploadSample.csv: -------------------------------------------------------------------------------- 1 | orgName,isTenant,channel,externalId,provider,description,homeUrl,organisationType,contactDetail,locationCode 2 | hello001,false,,1119,ugc,technical,googlehome,school,"[{'name':'abcd','age':110},{'fax':123456}]",40 -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/resources/welcomeSmsTemplate.vm: -------------------------------------------------------------------------------- 1 | Welcome to $instanceName. Your user account has now been created. Click on the link below to #if ($setPasswordLink) set a password #else verify your email ID #end and start using your account:$newline$link -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/resources/BulkSelfDeclaredUserUploadImproperSample.csv: -------------------------------------------------------------------------------- 1 | Status,State provided ext. ID,Channel,School Name,School UDISE ID,Phone number,Email ID,Personal,Error Types,Diksha UUID, 2 | REJECTED,sdkjdsf,ROOT_ORG,test,22222222222,8888888888,,Teacher,ERROR-EMAIL,8eaa1621-ac15-42a4-9e26-9c846963f331 -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/service/src/main/java/org/sunbird/middleware/Application.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.middleware; 2 | 3 | 4 | /** @author Mahesh Kumar Gangula */ 5 | public class Application { 6 | 7 | public static void main(String[] args) { 8 | init(); 9 | } 10 | 11 | public static void init() {} 12 | } 13 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/resources/BulkUploadUserSample.csv: -------------------------------------------------------------------------------- 1 | firstName,lastName,phone,email,userName,countryCode,roles,position,location,dob,gender,language,profileSummary,subject,webPages 2 | xyz1234516,Kumar15,9453500000,bk3@yahoo.com,bk3hoo,91,,pos,loc,1992-10-12,MALE,"ENGLISH,KANADA",summary,"HINDI,MATH,PHYSICS", 3 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/util/UserConstants.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.util; 2 | 3 | public final class UserConstants { 4 | 5 | public static final String SIGNUP_TYPE = "signupType"; 6 | public static final String USER_TYPE = "userType"; 7 | 8 | private UserConstants() {} 9 | } 10 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/service/src/test/resources/BulkUploadUserSample.csv: -------------------------------------------------------------------------------- 1 | firstName,lastName,phone,email,userName,countryCode,roles,position,location,dob,gender,language,profileSummary,subject,webPages 2 | xyz1234516,Kumar15,9453500000,bk3@yahoo.com,bk3hoo,countryCode,,pos,loc,1992-10-12,MALE,"ENGLISH,KANADA",summary,"HINDI,MATH,PHYSICS", 3 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/service/UserMergeService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.service; 2 | 3 | import java.util.Map; 4 | import org.sunbird.models.user.User; 5 | 6 | public interface UserMergeService { 7 | void triggerUserMergeTelemetry(Map telemetryMap, User merger, Map context); 8 | } 9 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/service/src/test/resources/BulkOrgUploadSampleWithRootOrgTrue.csv: -------------------------------------------------------------------------------- 1 | orgName,isRootOrg,channel,externalId,provider,description,homeUrl,orgCode,orgType,preferredLanguage,theme,contactDetail,hashTagId 2 | hello002,true,himanchalboardk9899543c,1119gxf47,hbx3r8ugc,technical,googlehome,122,,hindi,sunbied,"[{'name':'abcd','age':110},{'fax':123456}]",ggy6dnuyy7c54 3 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/error/RowComparator.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.error; 2 | 3 | import java.util.Comparator; 4 | 5 | public class RowComparator implements Comparator { 6 | @Override 7 | public int compare(CsvRowErrorDetails o1, CsvRowErrorDetails o2) { 8 | return o1.rowId - o2.rowId; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/main/resources/configuration.properties: -------------------------------------------------------------------------------- 1 | sunbird.msg.91.country=91 2 | sunbird.msg.91.sender=TesSun 3 | sunbird.msg.91.auth= 4 | sunbird.msg.91.method=POST 5 | sunbird.msg.91.route=4 6 | sunbird.msg.91.baseurl=http://api.msg91.com/ 7 | sunbird.msg.91.get.url=api/sendhttp.php? 8 | sunbird.msg.91.post.url=api/v2/sendsms 9 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/service/UserRoleService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.request.RequestContext; 6 | 7 | public interface UserRoleService { 8 | List> updateUserRole(Map userRequest, RequestContext context); 9 | } 10 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryConstant.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.util; 2 | 3 | /** 4 | * Class contains Constants for telemetry. 5 | * 6 | * @author arvind. 7 | */ 8 | public class TelemetryConstant { 9 | 10 | public static final String LOG_LEVEL_ERROR = "error"; 11 | } 12 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/resources/cassandra.config.properties: -------------------------------------------------------------------------------- 1 | coreConnectionsPerHostForLocal=4 2 | coreConnectionsPerHostForRemote=2 3 | maxConnectionsPerHostForLocal=10 4 | maxConnectionsPerHostForRemote=4 5 | maxRequestsPerConnection=32768 6 | heartbeatIntervalSeconds=60 7 | poolTimeoutMillis=0 8 | queryLoggerConstantThreshold=300 -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/role/dao/RoleDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.role.dao; 2 | 3 | import java.util.List; 4 | import org.sunbird.models.role.Role; 5 | 6 | public interface RoleDao { 7 | 8 | /** 9 | * Get list of roles. 10 | * 11 | * @return List of all roles. 12 | */ 13 | List getRoles(); 14 | } 15 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/error/IErrorDispatcher.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.error; 2 | 3 | /** 4 | * this is an interface class for the error dispatcher 5 | * 6 | * @author anmolgupta 7 | */ 8 | public interface IErrorDispatcher { 9 | 10 | /** this method will prepare the error and will throw ProjectCommonException. */ 11 | void dispatchError(); 12 | } 13 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/error/ErrorEnum.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.error; 2 | 3 | public enum ErrorEnum { 4 | invalid("invalid"), 5 | duplicate("duplicate"), 6 | missing("missing"); 7 | private String value; 8 | 9 | ErrorEnum(String value) { 10 | this.value = value; 11 | } 12 | 13 | public String getValue() { 14 | return value; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/models/user/FeedStatus.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.user; 2 | 3 | public enum FeedStatus { 4 | READ("read"), 5 | UNREAD("unread"); 6 | 7 | private String status; 8 | 9 | private FeedStatus(String status) { 10 | this.status = status; 11 | } 12 | 13 | public String getfeedStatus() { 14 | return status; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | project/project 3 | project/target 4 | target 5 | tmp 6 | .history 7 | dist 8 | /.idea 9 | /*.iml 10 | /out 11 | /.idea_modules 12 | /.classpath 13 | /.project 14 | /.settings 15 | /.target/ 16 | /bin/ 17 | /logs 18 | .settings 19 | .classpath 20 | .project 21 | **/*.iml 22 | **/.DS_Store 23 | actors/badge/logs 24 | dependency-reduced-pom.xml 25 | **/velocity.log 26 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/models/user/FeedAction.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.user; 2 | 3 | public enum FeedAction { 4 | ORG_MIGRATION_ACTION("OrgMigrationAction"); 5 | 6 | private String action; 7 | 8 | private FeedAction(String action) { 9 | this.action = action; 10 | } 11 | 12 | public String getfeedAction() { 13 | return action; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/location/src/main/java/org/sunbird/location/service/LocationService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.location.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.request.RequestContext; 6 | 7 | public interface LocationService { 8 | List> getValidatedRelatedLocationIdAndType( 9 | List codeList, RequestContext context); 10 | } 11 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/src/test/java/org/sunbird/helper/ElasticSearchMappingTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.helper; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class ElasticSearchMappingTest { 7 | 8 | @Test 9 | public void testcreateMapping() { 10 | String mapping = ElasticSearchMapping.createMapping(); 11 | Assert.assertNotNull(mapping); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/role/group/dao/RoleGroupDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.role.group.dao; 2 | 3 | import java.util.List; 4 | import org.sunbird.models.role.group.RoleGroup; 5 | 6 | public interface RoleGroupDao { 7 | 8 | /** 9 | * Get list of role groups. 10 | * 11 | * @return List of role groups. 12 | */ 13 | List getRoleGroups(); 14 | } 15 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/url/action/dao/UrlActionDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.url.action.dao; 2 | 3 | import java.util.List; 4 | import org.sunbird.models.url.action.UrlAction; 5 | 6 | public interface UrlActionDao { 7 | 8 | /** 9 | * Get list of URL actions. 10 | * 11 | * @return List of URL actions. 12 | */ 13 | List getUrlActions(); 14 | } 15 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/java/org/sunbird/learner/util/OTPUtilTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.util; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class OTPUtilTest { 7 | 8 | @Test 9 | public void generateOtpTest() { 10 | for (int i = 0; i < 10000; i++) { 11 | String code = OTPUtil.generateOtp(null); 12 | Assert.assertTrue(code.length() >= 4); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /git-hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" 4 | 5 | FORMAT_JAR_LOCATION="${REPO_ROOT_DIR}/tools/java-format/google-java-format-1.5-all-deps.jar" 6 | 7 | for staged_file in $(git diff --cached --name-only); do 8 | [ -f "${staged_file}" ] || continue 9 | 10 | "${REPO_ROOT_DIR}/scripts/check-java-file-format" "${FORMAT_JAR_LOCATION}" "${staged_file}" 11 | git add "${staged_file}" 12 | done 13 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/core/RouterException.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.actor.core; 2 | 3 | /** @author Mahesh Kumar Gangula */ 4 | public class RouterException extends RuntimeException { 5 | 6 | /** */ 7 | private static final long serialVersionUID = 7669891026222754334L; 8 | 9 | public RouterException(String message) { 10 | super(message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/src/test/java/org/sunbird/helper/ElasticSearchSettingsTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.helper; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class ElasticSearchSettingsTest { 7 | 8 | @Test 9 | public void testcreateSettingsForIndex() { 10 | 11 | String settings = ElasticSearchSettings.createSettingsForIndex(); 12 | Assert.assertNotNull(settings); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /scripts/check-java-file-format: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | FILES_TO_SKIP="^(src-gen|third-party|(test/.*\/testdata\/)).*\.java$" 4 | 5 | JAR_PATH=$1 6 | FILE_PATH=$2 7 | 8 | # Test if the file is Java file 9 | echo "${FILE_PATH}" | grep -Eqi "\.java$" || exit 1 10 | 11 | # Test if the file should be skipped 12 | echo "${FILE_PATH}" | grep -Eqi "${FILES_TO_SKIP}" && exit 0 13 | 14 | # Try to format the file 15 | java -jar "${JAR_PATH}" -i "${FILE_PATH}" 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /service/conf/log4j2.properties: -------------------------------------------------------------------------------- 1 | status = info 2 | name = PropertiesConfig 3 | appenders = console 4 | 5 | appender.console.type = Console 6 | appender.console.name = STDOUT 7 | appender.console.layout.type = PatternLayout 8 | appender.console.layout.pattern = %m%n 9 | 10 | logger.default.name = defaultLogger 11 | logger.default.level = info 12 | 13 | 14 | rootLogger.level = debug 15 | rootLogger.appenderRefs = STDOUT 16 | rootLogger.appenderRef.stdout.ref = STDOUT -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/organisation/dao/OrgDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.organisation.dao; 2 | 3 | import java.util.Map; 4 | import org.sunbird.common.request.RequestContext; 5 | 6 | public interface OrgDao { 7 | 8 | Map getOrgById(String orgId, RequestContext context); 9 | 10 | Map getOrgByExternalId( 11 | String externalId, String provider, RequestContext context); 12 | } 13 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/src/test/resources/cassandra.config.properties: -------------------------------------------------------------------------------- 1 | coreConnectionsPerHostForLocal=4 2 | coreConnectionsPerHostForRemote=2 3 | maxConnectionsPerHostForLocal=10 4 | maxConnectionsPerHostForRemote=4 5 | maxRequestsPerConnection=32768 6 | heartbeatIntervalSeconds=60 7 | poolTimeoutMillis=0 8 | contactPoint=127.0.0.1 9 | port=9042 10 | userName=cassandra 11 | password=password 12 | queryLoggerConstantThreshold=300 13 | keyspace=sunbird -------------------------------------------------------------------------------- /dockerPushToRepo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Build script 3 | # set -o errexit 4 | e () { 5 | echo $( echo ${1} | jq ".${2}" | sed 's/\"//g') 6 | } 7 | m=$(./metadata.sh) 8 | 9 | org=$(e "${m}" "org") 10 | hubuser=$(e "${m}" "hubuser") 11 | name=$(e "${m}" "name") 12 | version=$(e "${m}" "version") 13 | 14 | artifactLabel=${ARTIFACT_LABEL:-bronze} 15 | 16 | docker login -u "${hubuser}" -p`cat /home/ops/vault_pass` 17 | docker push ${org}/${name}:${version}-${artifactLabel} 18 | docker logout 19 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/organisation/service/OrgService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.organisation.service; 2 | 3 | import java.util.Map; 4 | import org.sunbird.common.request.RequestContext; 5 | 6 | public interface OrgService { 7 | 8 | Map getOrgById(String orgId, RequestContext context); 9 | 10 | Map getOrgByExternalIdAndProvider( 11 | String externalId, String provider, RequestContext context); 12 | } 13 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/util/KafkaConfigConstants.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.util; 2 | 3 | public class KafkaConfigConstants { 4 | 5 | public static final String SUNBIRD_USER_CERT_KAFKA_SERVICE_CONFIG = 6 | "sunbird_user_cert_kafka_servers_config"; 7 | public static final String SUNBIRD_USER_CERT_KAFKA_TOPIC = "sunbird_user_cert_kafka_topic"; 8 | public static final String KAFKA_CLIENT_USER_CERT_PRODUCER = "KafkaClientUserCertProducer"; 9 | } 10 | -------------------------------------------------------------------------------- /service/test/controllers/DummyActor.java: -------------------------------------------------------------------------------- 1 | package controllers; 2 | 3 | import akka.actor.ActorRef; 4 | import akka.actor.UntypedAbstractActor; 5 | import org.sunbird.common.models.response.Response; 6 | 7 | /** Created by arvind on 30/11/17. */ 8 | public class DummyActor extends UntypedAbstractActor { 9 | 10 | @Override 11 | public void onReceive(Object message) throws Throwable { 12 | Response response = new Response(); 13 | sender().tell(response, ActorRef.noSender()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/validator/TelemetryObjectValidator.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.validator; 2 | 3 | /** @author arvind */ 4 | public interface TelemetryObjectValidator { 5 | 6 | public boolean validateAudit(String jsonString); 7 | 8 | public boolean validateSearch(String jsonString); 9 | 10 | public boolean validateLog(String jsonString); 11 | 12 | public boolean validateError(String jsonString); 13 | } 14 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/resources/mailTemplates.properties: -------------------------------------------------------------------------------- 1 | orgName=Diksha 2 | onboarding_mail_subject=Welcome to {0} 3 | onboarding_welcome_message=Welcome to {0} 4 | onboarding_welcome_mail_body=Please ensure that you change your password according to instructions when you log in for the first time. 5 | mail_note=Note: This is an automatic alert email. Replies to this mail box will not be monitored. If you are not the intended recipient of this message, or need to communicate with the team, write to 6 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/service/UserConsentService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.service; 2 | 3 | import org.sunbird.common.models.response.Response; 4 | import org.sunbird.common.request.RequestContext; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public interface UserConsentService { 10 | 11 | Response updateConsent(Map consent, RequestContext context); 12 | 13 | List> getConsent(Map consentReq, RequestContext context); 14 | } 15 | -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/UserTypeController.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement; 2 | 3 | import controllers.BaseController; 4 | import org.sunbird.common.models.util.ActorOperations; 5 | import play.mvc.Http; 6 | import play.mvc.Result; 7 | 8 | import java.util.concurrent.CompletionStage; 9 | 10 | public class UserTypeController extends BaseController { 11 | 12 | public CompletionStage getUserTypes(Http.Request httpRequest) { 13 | return handleRequest(ActorOperations.GET_USER_TYPES.getValue(), httpRequest); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/util/TelemetryEvents.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.util; 2 | 3 | /** 4 | * enum for telemetry events 5 | * 6 | * @author arvind. 7 | */ 8 | public enum TelemetryEvents { 9 | AUDIT("AUDIT"), 10 | SEARCH("SEARCH"), 11 | LOG("LOG"), 12 | ERROR("ERROR"); 13 | private String name; 14 | 15 | TelemetryEvents(String name) { 16 | this.name = name; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/resources/userencryption.properties: -------------------------------------------------------------------------------- 1 | userkey.encryption=email,phone,userName,loginId,prevUsedEmail,prevUsedPhone,recoveryEmail,recoveryPhone 2 | userkey.decryption=encEmail,encPhone,userName,loginId,email,phone,prevUsedEmail,prevUsedPhone,recoveryEmail,recoveryPhone 3 | userkey.masked=email,phone,recoveryEmail,recoveryPhone,prevUsedPhone,recoveryEmail,prevUsedEmail 4 | userkey.phonetypeattributes=phone,recoveryPhone,prevUsedPhone 5 | userkey.emailtypeattributes=email,recoveryEmail,prevUsedEmail -------------------------------------------------------------------------------- /service/app/util/RBACUtil.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package util; 3 | 4 | /** 5 | * This is role based access control class. This class will handle user role based access control. 6 | * 7 | * @author Manzarul 8 | */ 9 | public class RBACUtil { 10 | 11 | /** 12 | * Based on incoming user id and API, this method will decide user has access to this API or not. 13 | * 14 | * @param uid String 15 | * @param api String 16 | * @return boolean 17 | */ 18 | public boolean hasAccess(String uid, String api) { 19 | 20 | return true; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/feed/impl/FeedFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.feed.impl; 2 | 3 | import org.sunbird.feed.IFeedService; 4 | 5 | /** This class will create instance of FeedService */ 6 | public class FeedFactory { 7 | private static IFeedService instance; 8 | 9 | public static IFeedService getInstance() { 10 | if (instance == null) { 11 | synchronized (FeedFactory.class) { 12 | if (instance == null) instance = new FeedServiceImpl(); 13 | } 14 | } 15 | return instance; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/notificationservice/dao/EmailTemplateDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.notificationservice.dao; 2 | 3 | import org.sunbird.common.request.RequestContext; 4 | 5 | public interface EmailTemplateDao { 6 | 7 | /** 8 | * Get email template information for given name. 9 | * 10 | * @param templateName Email template name 11 | * @param context 12 | * @return String containing email template information 13 | */ 14 | String getTemplate(String templateName, RequestContext context); 15 | } 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/test/java/org/sunbird/user/service/UserMergeServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.service; 2 | 3 | import java.util.HashMap; 4 | import org.junit.Test; 5 | import org.sunbird.models.user.User; 6 | import org.sunbird.user.service.impl.UserMergeServiceImpl; 7 | 8 | public class UserMergeServiceImplTest { 9 | @Test 10 | public void triggerUserMergeTelemetryTest() { 11 | UserMergeService mergeService = new UserMergeServiceImpl(); 12 | mergeService.triggerUserMergeTelemetry(new HashMap(), new User(), new HashMap<>()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/service/UserSelfDeclarationService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.service; 2 | 3 | import java.util.Map; 4 | import org.sunbird.common.models.response.Response; 5 | import org.sunbird.common.request.RequestContext; 6 | import org.sunbird.models.user.UserDeclareEntity; 7 | 8 | public interface UserSelfDeclarationService { 9 | Response saveUserSelfDeclareAttributes(Map requestMap, RequestContext context); 10 | 11 | void updateSelfDeclaration(UserDeclareEntity userDeclareEntity, RequestContext context); 12 | } 13 | -------------------------------------------------------------------------------- /Dockerfile.Build: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine 2 | MAINTAINER "Manojv" "manojv@ilimi.in" 3 | WORKDIR /opt 4 | RUN apk update \ 5 | && mkdir -p /opt/learner \ 6 | && apk add wget \ 7 | && wget http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \ 8 | && tar -xvzf apache-maven-3.3.9-bin.tar.gz 9 | ENV M2_HOME /opt/apache-maven-3.3.9 10 | ENV PATH ${M2_HOME}/bin:${PATH} 11 | COPY learner /opt/learner/ 12 | WORKDIR /opt/learner/services 13 | RUN mvn clean install -DskipTests 14 | WORKDIR /opt/learner/services/learning-service 15 | CMD ["mvn", "play2:dist"] -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/bean/ClaimStatus.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.bean; 2 | 3 | /** 4 | * this class will have user action performed on the shadow user record. 5 | * 6 | * @author anmolgupta 7 | */ 8 | public enum ClaimStatus { 9 | CLAIMED(1), 10 | UNCLAIMED(0), 11 | REJECTED(2), 12 | FAILED(3), 13 | MULTIMATCH(4), 14 | ORGEXTERNALIDMISMATCH(5), 15 | ELIGIBLE(6); 16 | 17 | private int value; 18 | 19 | ClaimStatus(int value) { 20 | this.value = value; 21 | } 22 | 23 | public int getValue() { 24 | return value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/src/main/java/org/sunbird/cassandraannotation/ClusteringKey.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.cassandraannotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Indicate the field as part of the cassandra clustering key. 10 | * 11 | * @author arvind. 12 | */ 13 | @Target({ElementType.FIELD, ElementType.PARAMETER}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface ClusteringKey {} 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/src/main/java/org/sunbird/cassandraannotation/PartitioningKey.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.cassandraannotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Indicate the field as part of the cassandra partitioning key. 10 | * 11 | * @author arvind. 12 | */ 13 | @Target({ElementType.FIELD, ElementType.PARAMETER}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface PartitioningKey {} 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionMngrFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.helper; 2 | 3 | public class CassandraConnectionMngrFactory { 4 | 5 | private static CassandraConnectionManager instance; 6 | 7 | public static CassandraConnectionManager getInstance() { 8 | if (instance == null) { 9 | synchronized (CassandraConnectionMngrFactory.class) { 10 | if (instance == null) { 11 | instance = new CassandraConnectionManagerImpl(); 12 | } 13 | } 14 | } 15 | return instance; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/ratelimit/service/RateLimitService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.ratelimit.service; 2 | 3 | import org.sunbird.common.request.RequestContext; 4 | import org.sunbird.ratelimit.limiter.RateLimiter; 5 | 6 | public interface RateLimitService { 7 | 8 | /** 9 | * Throttle requests by key as per given rate limiters. 10 | * 11 | * @param key Key (e.g. phone number, email address) 12 | * @param rateLimiters List of rate limiters 13 | * @param context 14 | */ 15 | void throttleByKey(String key, RateLimiter[] rateLimiters, RequestContext context); 16 | } 17 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/dao/UserExternalIdentityDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.dao; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.request.RequestContext; 6 | 7 | public interface UserExternalIdentityDao { 8 | 9 | public String getUserIdByExternalId(String extId, String provider, RequestContext context); 10 | 11 | public List> getUserExternalIds(String userId, RequestContext context); 12 | 13 | public List> getUserSelfDeclaredDetails( 14 | String userId, RequestContext context); 15 | } 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/test/resources/configuration.properties: -------------------------------------------------------------------------------- 1 | sunbird.msg.91.country=91 2 | sunbird.msg.91.sender=TesSun 3 | sunbird.msg.91.auth=randomstring 4 | sunbird.msg.91.method=POST 5 | sunbird.msg.91.route=4 6 | sunbird.msg.91.baseurl=http://api.msg91.com/ 7 | sunbird.msg.91.get.url=api/sendhttp.php? 8 | sunbird.msg.91.post.url=api/v2/sendsms 9 | nic_sms_gateway_provider_base_url=https://smsgw.sms.gov.in/failsafe/HttpLink 10 | nic_sms_gateway_provider_senderid=senderid 11 | nic_sms_gateway_provider_username=user 12 | nic_sms_gateway_provider_password=pass 13 | diksha_dlt_entity_id=465466 14 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/dao/UserOrgDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.dao; 2 | 3 | import org.sunbird.common.models.response.Response; 4 | import org.sunbird.common.request.RequestContext; 5 | import org.sunbird.models.user.org.UserOrg; 6 | 7 | public interface UserOrgDao { 8 | Response updateUserOrg(UserOrg userOrg, RequestContext context); 9 | 10 | Response createUserOrg(UserOrg userOrg, RequestContext context); 11 | 12 | Response getUserOrgListByUserId(String userId, RequestContext context); 13 | 14 | Response getUserOrgDetails(String userId, String organisationId, RequestContext context); 15 | } 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/error/CsvError.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.error; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class CsvError { 7 | 8 | private List errorsList = new ArrayList<>(); 9 | 10 | public CsvError() {} 11 | 12 | public List getErrorsList() { 13 | return errorsList; 14 | } 15 | 16 | public void setErrorsList(List errorsList) { 17 | this.errorsList = errorsList; 18 | } 19 | 20 | public void setError(CsvRowErrorDetails errorDetails) { 21 | errorsList.add(errorDetails); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/EmailServiceClient.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.actorutil.email; 2 | 3 | import akka.actor.ActorRef; 4 | import java.util.Map; 5 | import org.sunbird.common.models.response.Response; 6 | 7 | public interface EmailServiceClient { 8 | /** 9 | * Send mail user from course. 10 | * 11 | * @param actorRef Actor reference 12 | * @param request Request containing email realted information 13 | * @return Response containing email send status 14 | */ 15 | Response sendMail(ActorRef actorRef, Map request); 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sunbird-lms-service 2 | 3 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b963e5ed122f47b5a27b19a87d9fa6de)](https://app.codacy.com/app/sunbird-bot/sunbird-lms-service?utm_source=github.com&utm_medium=referral&utm_content=project-sunbird/sunbird-lms-service&utm_campaign=Badge_Grade_Settings) 4 | 5 | This is the repository for Sunbird learning management system (lms) micro-service. It provides the APIs for lms functionality of Sunbird. 6 | 7 | The code in this repository is licensed under MIT License unless otherwise noted. Please see the [LICENSE](https://github.com/project-sunbird/sunbird-lms-service/blob/master/LICENSE) file for details. 8 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/router/ActorConfig.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.actor.router; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** @author Mahesh Kumar Gangula */ 10 | @Target(ElementType.TYPE) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Inherited 13 | public @interface ActorConfig { 14 | String[] tasks(); 15 | 16 | String[] asyncTasks(); 17 | 18 | String dispatcher() default ""; 19 | } 20 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/email/EmailServiceFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.actorutil.email; 2 | 3 | import org.sunbird.actorutil.email.impl.EmailServiceClientImpl; 4 | 5 | public class EmailServiceFactory { 6 | 7 | private static EmailServiceClient instance; 8 | 9 | private EmailServiceFactory() {} 10 | 11 | static { 12 | instance = new EmailServiceClientImpl(); 13 | } 14 | 15 | public static EmailServiceClient getInstance() { 16 | if (null == instance) { 17 | instance = new EmailServiceClientImpl(); 18 | } 19 | return instance; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryDataAssembler.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.collector; 2 | 3 | import java.util.Map; 4 | 5 | /** Created by arvind on 16/1/18. */ 6 | public interface TelemetryDataAssembler { 7 | 8 | public String audit(Map context, Map params); 9 | 10 | public String search(Map context, Map params); 11 | 12 | public String log(Map context, Map params); 13 | 14 | public String error(Map context, Map params); 15 | } 16 | -------------------------------------------------------------------------------- /service/app/modules/StartModule.java: -------------------------------------------------------------------------------- 1 | package modules; 2 | 3 | import com.google.inject.AbstractModule; 4 | import org.sunbird.common.models.util.LoggerUtil; 5 | 6 | public class StartModule extends AbstractModule { 7 | private LoggerUtil logger = new LoggerUtil(StartModule.class); 8 | 9 | @Override 10 | protected void configure() { 11 | logger.info("StartModule:configure: Start"); 12 | try { 13 | bind(SignalHandler.class).asEagerSingleton(); 14 | bind(ApplicationStart.class).asEagerSingleton(); 15 | } catch (Exception | Error e) { 16 | e.printStackTrace(); 17 | } 18 | logger.info("StartModule:configure: End"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/main/java/org/sunbird/notification/sms/providerimpl/Msg91SmsProviderFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.notification.sms.providerimpl; 2 | 3 | import org.sunbird.notification.sms.provider.ISmsProvider; 4 | import org.sunbird.notification.sms.provider.ISmsProviderFactory; 5 | 6 | public class Msg91SmsProviderFactory implements ISmsProviderFactory { 7 | 8 | private static Msg91SmsProvider msg91SmsProvider = null; 9 | 10 | @Override 11 | public ISmsProvider create() { 12 | if (msg91SmsProvider == null) { 13 | msg91SmsProvider = new Msg91SmsProvider(); 14 | } 15 | return msg91SmsProvider; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/main/java/org/sunbird/notification/sms/providerimpl/NICGatewaySmsProviderFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.notification.sms.providerimpl; 2 | 3 | import org.sunbird.notification.sms.provider.ISmsProvider; 4 | import org.sunbird.notification.sms.provider.ISmsProviderFactory; 5 | 6 | public class NICGatewaySmsProviderFactory implements ISmsProviderFactory { 7 | 8 | private static NICGatewaySmsProvider nicSmsProvider = null; 9 | 10 | @Override 11 | public ISmsProvider create() { 12 | if (nicSmsProvider == null) { 13 | nicSmsProvider = new NICGatewaySmsProvider(); 14 | } 15 | return nicSmsProvider; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/util/Matcher.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** this class is used to match the identifiers. */ 6 | public class Matcher { 7 | 8 | /** 9 | * this method will match the two arguments , equal or not if two string is null or empty this 10 | * method will return true 11 | * 12 | * @param firstVal 13 | * @param secondVal 14 | * @return boolean 15 | */ 16 | public static boolean matchIdentifiers(String firstVal, String secondVal) { 17 | return StringUtils.equalsIgnoreCase(firstVal, secondVal); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/location/src/main/java/org/sunbird/location/dao/impl/LocationDaoFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.location.dao.impl; 2 | 3 | import org.sunbird.location.dao.LocationDao; 4 | 5 | /** @author Amit Kumar */ 6 | public class LocationDaoFactory { 7 | 8 | /** private default constructor. */ 9 | private LocationDaoFactory() {} 10 | 11 | private static LocationDao locationDao; 12 | 13 | static { 14 | locationDao = new LocationDaoImpl(); 15 | } 16 | 17 | /** 18 | * This method will provide singleton instance for LocationDaoImpl. 19 | * 20 | * @return LocationDao 21 | */ 22 | public static LocationDao getInstance() { 23 | return locationDao; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /service/app/controllers/scheduler/SchedulerController.java: -------------------------------------------------------------------------------- 1 | package controllers.scheduler; 2 | 3 | import controllers.BaseController; 4 | import org.sunbird.common.models.util.ActorOperations; 5 | import play.mvc.Http; 6 | import play.mvc.Result; 7 | 8 | import java.util.concurrent.CompletionStage; 9 | 10 | public class SchedulerController extends BaseController { 11 | public CompletionStage startScheduler(Http.Request httpRequest) { 12 | return handleRequest( 13 | ActorOperations.ONDEMAND_START_SCHEDULER.getValue(), 14 | httpRequest.body().asJson(), 15 | null, 16 | null, 17 | null, 18 | true, 19 | httpRequest); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/dao/UserRoleDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.dao; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.models.response.Response; 6 | import org.sunbird.common.request.RequestContext; 7 | 8 | public interface UserRoleDao { 9 | 10 | Response assignUserRole(List> userRoleMap, RequestContext context); 11 | 12 | Response updateRoleScope(List> userRoleMap, RequestContext context); 13 | 14 | void deleteUserRole(List> userRoleMap, RequestContext context); 15 | 16 | List> getUserRoles(String userId, String role, RequestContext context); 17 | } 18 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryAssemblerFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.collector; 2 | 3 | /** Created by arvind on 16/1/18. */ 4 | public class TelemetryAssemblerFactory { 5 | 6 | private static TelemetryDataAssembler telemetryDataAssembler = null; 7 | 8 | public static TelemetryDataAssembler get() { 9 | if (telemetryDataAssembler == null) { 10 | synchronized (TelemetryAssemblerFactory.class) { 11 | if (telemetryDataAssembler == null) { 12 | telemetryDataAssembler = new TelemetryDataAssemblerImpl(); 13 | } 14 | } 15 | } 16 | return telemetryDataAssembler; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BulkUploadJsonKey.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | /** 4 | * Constants for Bulk Upload service. 5 | * 6 | * @author Arvind 7 | */ 8 | public class BulkUploadJsonKey { 9 | 10 | private BulkUploadJsonKey() {} 11 | 12 | public static final String TASK_COUNT = "taskCount"; 13 | public static final String SEQUENCE_ID = "sequenceId"; 14 | public static final String OPERATION_STATUS_MSG = "Operation is {0}."; 15 | public static final String NOT_STARTED = "NOT STARTED"; 16 | public static final String IN_PROGRESS = "IN PROGRESS"; 17 | public static final String COMPLETED = "COMPLETED"; 18 | } 19 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/services/sso/SSOServiceFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.services.sso; 2 | 3 | import org.sunbird.services.sso.impl.KeyCloakServiceImpl; 4 | 5 | /** @author Amit Kumar */ 6 | public class SSOServiceFactory { 7 | private static SSOManager ssoManager = null; 8 | 9 | private SSOServiceFactory() {} 10 | 11 | /** 12 | * On call of this method , it will provide a new KeyCloakServiceImpl instance on each call. 13 | * 14 | * @return SSOManager 15 | */ 16 | public static SSOManager getInstance() { 17 | if (null == ssoManager) { 18 | ssoManager = new KeyCloakServiceImpl(); 19 | } 20 | return ssoManager; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/test/java/org/sunbird/notification/utils/PropertiesCacheTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.notification.utils; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class PropertiesCacheTest { 7 | 8 | @Test 9 | public void testGetProperty() { 10 | PropertiesCache cache = PropertiesCache.getInstance(); 11 | String code = cache.getProperty("sunbird.msg.91.country"); 12 | Assert.assertEquals("91", code); 13 | } 14 | 15 | @Test 16 | public void testReadProperty() { 17 | PropertiesCache cache = PropertiesCache.getInstance(); 18 | String code = cache.readProperty("sunbird.msg.91.country"); 19 | Assert.assertEquals("91", code); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/ClientErrorResponse.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.response; 2 | 3 | import org.sunbird.common.exception.ProjectCommonException; 4 | import org.sunbird.common.responsecode.ResponseCode; 5 | 6 | public class ClientErrorResponse extends Response { 7 | 8 | private ProjectCommonException exception = null; 9 | 10 | public ClientErrorResponse() { 11 | responseCode = ResponseCode.CLIENT_ERROR; 12 | } 13 | 14 | public ProjectCommonException getException() { 15 | return exception; 16 | } 17 | 18 | public void setException(ProjectCommonException exception) { 19 | this.exception = exception; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/organization/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.sunbird 8 | mw-actors 9 | 1.0-SNAPSHOT 10 | ../pom.xml 11 | 12 | organization 13 | Organization 14 | 15 | UTF-8 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/bulkupload/model/SelfDeclaredErrorTypeEnum.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.bulkupload.model; 2 | 3 | public enum SelfDeclaredErrorTypeEnum { 4 | ERROR_DISTRICT("ERROR-DISTRICT"), 5 | ERROR_PHONE("ERROR-PHONE"), 6 | ERROR_EMAIL("ERROR-EMAIL"), 7 | ERROR_SCHOOL_ORG_NAME("ERROR-SCHOOL ORG NAME"), 8 | ERROR_SCHOOL_ORG_ID("ERROR-SCHOOL ORG ID"), 9 | ERROR_ID("ERROR-ID"), 10 | ERROR_NAME("ERROR-NAME"), 11 | ERROR_STATE("ERROR-STATE"); 12 | 13 | public final String errorType; 14 | 15 | SelfDeclaredErrorTypeEnum(String errorType) { 16 | this.errorType = errorType; 17 | } 18 | 19 | public String getErrorType() { 20 | return this.errorType; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Build script 3 | # set -o errexit 4 | e () { 5 | echo $( echo ${1} | jq ".${2}" | sed 's/\"//g') 6 | } 7 | m=$(./metadata.sh) 8 | 9 | org=$(e "${m}" "org") 10 | name=$(e "${m}" "name") 11 | version=$(e "${m}" "version") 12 | 13 | artifactLabel=${ARTIFACT_LABEL:-bronze} 14 | env=${ENV:-null} 15 | 16 | echo "artifactLabel: ${artifactLabel}" 17 | echo "env: ${env}" 18 | echo "org: ${org}" 19 | echo "name: ${name}" 20 | echo "version: ${version}" 21 | 22 | ansible-playbook --version 23 | ansible-playbook -i ansible/inventory/dev ansible/deploy.yml --tags "stack-sunbird" --extra-vars "hub_org=${org} image_name=${name} image_tag=${version}-${artifactLabel}" --vault-password-file /run/secrets/vault-pass 24 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/java/org/sunbird/learner/util/UserFlagEnumTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.util; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 6 | 7 | @PowerMockIgnore({ 8 | "javax.management.*", 9 | "javax.net.ssl.*", 10 | "javax.security.*", 11 | "jdk.internal.reflect.*" 12 | }) 13 | public class UserFlagEnumTest { 14 | 15 | @Test 16 | public void testUserFlagEnumPhoneValue() { 17 | Assert.assertEquals(4, UserFlagEnum.STATE_VALIDATED.getUserFlagValue()); 18 | } 19 | 20 | @Test 21 | public void testUserFlagEnumPhoneType() { 22 | Assert.assertEquals("stateValidated", UserFlagEnum.STATE_VALIDATED.getUserFlagType()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/src/test/java/org/sunbird/common/factory/EsClientFactoryTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.factory; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | import org.sunbird.common.ElasticSearchRestHighImpl; 6 | import org.sunbird.common.inf.ElasticSearchService; 7 | 8 | public class EsClientFactoryTest { 9 | 10 | @Test 11 | public void testGetRestClient() { 12 | ElasticSearchService service = EsClientFactory.getInstance("rest"); 13 | Assert.assertTrue(service instanceof ElasticSearchRestHighImpl); 14 | } 15 | 16 | @Test 17 | public void testInstanceNull() { 18 | ElasticSearchService service = EsClientFactory.getInstance("test"); 19 | Assert.assertNull(service); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/actors/UserLoginActor.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.actors; 2 | 3 | import org.sunbird.actor.router.ActorConfig; 4 | import org.sunbird.common.models.response.Response; 5 | import org.sunbird.common.models.util.JsonKey; 6 | import org.sunbird.common.request.Request; 7 | 8 | @ActorConfig( 9 | tasks = {"userCurrentLogin"}, 10 | asyncTasks = {} 11 | ) 12 | public class UserLoginActor extends UserBaseActor { 13 | 14 | @Override 15 | public void onReceive(Request request) { 16 | // Always return 200 and in future release will depricate these apis 17 | Response response = new Response(); 18 | response.put(JsonKey.RESPONSE, JsonKey.SUCCESS); 19 | sender().tell(response, self()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/util/DateUtil.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.util; 2 | 3 | import java.sql.Timestamp; 4 | import java.text.DateFormat; 5 | import java.text.SimpleDateFormat; 6 | import java.util.Calendar; 7 | import java.util.Date; 8 | 9 | public class DateUtil { 10 | public static Date addDaysToDate(Date dateObj, int days){ 11 | Calendar c = Calendar.getInstance(); 12 | c.setTime(dateObj); 13 | // manipulate date 14 | c.add(Calendar.DATE, days); 15 | // convert calendar to date 16 | return c.getTime(); 17 | } 18 | 19 | public static Timestamp getCurrentDateTimestamp(){ 20 | return new Timestamp(Calendar.getInstance().getTime().getTime()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/GeoLocationJsonKey.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | /** Created by arvind on 19/4/18. */ 4 | public class GeoLocationJsonKey { 5 | 6 | private GeoLocationJsonKey() {} 7 | 8 | public static final String PARENT_CODE = "parentCode"; 9 | public static final String CODE = "code"; 10 | public static final String LOCATION_TYPE = "type"; 11 | public static final String PARENT_ID = "parentId"; 12 | public static final String SUNBIRD_VALID_LOCATION_TYPES = "sunbird_valid_location_types"; 13 | public static final String PROPERTY_NAME = "name"; 14 | public static final String PROPERTY_VALUE = "value"; 15 | public static final String ID = "id"; 16 | } 17 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/SlugTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class SlugTest { 7 | 8 | @Test 9 | public void createSlugWithNullValue() { 10 | String slug = Slug.makeSlug(null, true); 11 | Assert.assertEquals(null, slug); 12 | } 13 | 14 | @Test 15 | public void createSlug() { 16 | String val = "NTP@#Test"; 17 | String slug = Slug.makeSlug(val, true); 18 | Assert.assertEquals("ntptest", slug); 19 | } 20 | 21 | @Test 22 | public void removeDuplicateChar() { 23 | String val = Slug.removeDuplicateChars("ntpntest"); 24 | Assert.assertEquals("ntpes", val); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/auth-verifier/src/main/java/org/sunbird/auth/verifier/KeyData.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.auth.verifier; 2 | 3 | import java.security.PublicKey; 4 | 5 | public class KeyData { 6 | private String keyId; 7 | private PublicKey publicKey; 8 | 9 | public KeyData(String keyId, PublicKey publicKey) { 10 | this.keyId = keyId; 11 | this.publicKey = publicKey; 12 | } 13 | 14 | public String getKeyId() { 15 | return keyId; 16 | } 17 | 18 | public void setKeyId(String keyId) { 19 | this.keyId = keyId; 20 | } 21 | 22 | public PublicKey getPublicKey() { 23 | return publicKey; 24 | } 25 | 26 | public void setPublicKey(PublicKey publicKey) { 27 | this.publicKey = publicKey; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/LocationActorOperation.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | public enum LocationActorOperation { 4 | CREATE_LOCATION("createLocation"), 5 | UPDATE_LOCATION("updateLocation"), 6 | SEARCH_LOCATION("searchLocation"), 7 | DELETE_LOCATION("deleteLocation"), 8 | GET_RELATED_LOCATION_IDS("getRelatedLocationIds"), 9 | READ_LOCATION_TYPE("readLocationType"), 10 | UPSERT_LOCATION_TO_ES("upsertLocationDataToES"), 11 | DELETE_LOCATION_FROM_ES("deleteLocationDataFromES"); 12 | 13 | private String value; 14 | 15 | LocationActorOperation(String value) { 16 | this.value = value; 17 | } 18 | 19 | public String getValue() { 20 | return this.value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/UserLoginController.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement; 2 | 3 | import controllers.BaseController; 4 | import java.util.concurrent.CompletionStage; 5 | import org.sunbird.common.models.util.ActorOperations; 6 | import play.mvc.Http; 7 | import play.mvc.Result; 8 | 9 | public class UserLoginController extends BaseController { 10 | /** 11 | * Updates current login time for given user in Keycloak. 12 | * 13 | * @return Return a promise for update login time API result. 14 | */ 15 | public CompletionStage updateLoginTime(Http.Request httpRequest) { 16 | 17 | return handleRequest( 18 | ActorOperations.USER_CURRENT_LOGIN.getValue(), 19 | httpRequest.body().asJson(), 20 | request -> null, 21 | httpRequest); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/TelemetryEnvKey.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | /** Created by arvind on 9/4/18. */ 4 | public class TelemetryEnvKey { 5 | 6 | public static final String USER = "User"; 7 | public static final String ORGANISATION = "Organisation"; 8 | public static final String GEO_LOCATION = "GeoLocation"; 9 | public static final String MASTER_KEY = "MasterKey"; 10 | public static final String OBJECT_STORE = "ObjectStore"; 11 | public static final String LOCATION = "Location"; 12 | public static final String REQUEST_UPPER_CAMEL = "Request"; 13 | public static final String USER_CONSENT = "UserConsent"; 14 | public static final String EDATA_TYPE_USER_CONSENT = "user-consent"; 15 | } 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Actor.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.dto; 2 | 3 | public class Actor { 4 | 5 | private String id; 6 | private String type; 7 | 8 | public Actor() {} 9 | 10 | public Actor(String id, String type) { 11 | super(); 12 | this.id = id; 13 | this.type = type; 14 | } 15 | 16 | /** @return the id */ 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | /** @param id the id to set */ 22 | public void setId(String id) { 23 | this.id = id; 24 | } 25 | 26 | /** @return the type */ 27 | public String getType() { 28 | return type; 29 | } 30 | 31 | /** @param type the type to set */ 32 | public void setType(String type) { 33 | this.type = type; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/service/UserExternalIdentityService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.request.RequestContext; 6 | 7 | public interface UserExternalIdentityService { 8 | 9 | List> getSelfDeclaredDetails( 10 | String userId, String orgId, String role, RequestContext context); 11 | 12 | List> getSelfDeclaredDetails(String userId, RequestContext context); 13 | 14 | List> getUserExternalIds(String userId, RequestContext context); 15 | 16 | String getUserV1(String extId, String provider, String idType, RequestContext context); 17 | 18 | String getUserV2(String extId, String orgId, String idType, RequestContext context); 19 | } 20 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/auth-verifier/src/main/java/org/sunbird/auth/verifier/CryptoUtil.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.auth.verifier; 2 | 3 | import java.nio.charset.Charset; 4 | import java.security.*; 5 | 6 | public class CryptoUtil { 7 | private static final Charset US_ASCII = Charset.forName("US-ASCII"); 8 | 9 | public static boolean verifyRSASign(String payLoad, byte[] signature, PublicKey key, String algorithm) { 10 | Signature sign; 11 | try { 12 | sign = Signature.getInstance(algorithm); 13 | sign.initVerify(key); 14 | sign.update(payLoad.getBytes(US_ASCII)); 15 | return sign.verify(signature); 16 | } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { 17 | return false; 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | lms-service 6 | org.sunbird 7 | 1.0-SNAPSHOT 8 | ../../pom.xml 9 | 10 | 4.0.0 11 | org.sunbird 12 | sunbird-lms-mw 13 | 1.0-SNAPSHOT 14 | pom 15 | Sunbird LMS MW 16 | 17 | actors/sunbird-utils 18 | actors 19 | service 20 | 21 | 22 | -------------------------------------------------------------------------------- /service/app/controllers/tac/UserTnCController.java: -------------------------------------------------------------------------------- 1 | package controllers.tac; 2 | 3 | import controllers.BaseController; 4 | import controllers.tac.validator.UserTnCRequestValidator; 5 | import org.sunbird.common.models.util.ActorOperations; 6 | import org.sunbird.common.request.Request; 7 | import play.mvc.Http; 8 | import play.mvc.Result; 9 | 10 | import java.util.concurrent.CompletionStage; 11 | 12 | public class UserTnCController extends BaseController { 13 | 14 | public CompletionStage acceptTnC(Http.Request httpRequest) { 15 | return handleRequest( 16 | ActorOperations.USER_TNC_ACCEPT.getValue(), 17 | httpRequest.body().asJson(), 18 | (request) -> { 19 | new UserTnCRequestValidator().validateTnCRequest((Request) request); 20 | return null; 21 | }, 22 | httpRequest); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk/openjdk11:alpine-slim 2 | MAINTAINER "Manojv" "manojv@ilimi.in" 3 | RUN apk update \ 4 | && apk add unzip \ 5 | && apk add curl \ 6 | && adduser -u 1001 -h /home/sunbird/ -D sunbird \ 7 | && mkdir -p /home/sunbird/learner 8 | #ENV sunbird_learnerstate_actor_host 52.172.24.203 9 | #ENV sunbird_learnerstate_actor_port 8088 10 | RUN chown -R sunbird:sunbird /home/sunbird 11 | USER sunbird 12 | COPY ./service/target/learning-service-1.0-SNAPSHOT-dist.zip /home/sunbird/learner/ 13 | RUN unzip /home/sunbird/learner/learning-service-1.0-SNAPSHOT-dist.zip -d /home/sunbird/learner/ 14 | WORKDIR /home/sunbird/learner/ 15 | CMD java -XX:+PrintFlagsFinal $JAVA_OPTIONS -Dplay.server.http.idleTimeout=180s -cp '/home/sunbird/learner/learning-service-1.0-SNAPSHOT/lib/*' play.core.server.ProdServerStart /home/sunbird/learner/learning-service-1.0-SNAPSHOT 16 | 17 | -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/validator/UserStatusRequestValidator.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement.validator; 2 | 3 | import org.sunbird.common.models.util.JsonKey; 4 | import org.sunbird.common.request.BaseRequestValidator; 5 | import org.sunbird.common.request.Request; 6 | import org.sunbird.common.responsecode.ResponseCode; 7 | 8 | public class UserStatusRequestValidator extends BaseRequestValidator { 9 | 10 | public void validateBlockUserRequest(Request request) { 11 | validateUserId((String) request.getRequest().get(JsonKey.USER_ID)); 12 | } 13 | 14 | public void validateUnblockUserRequest(Request request) { 15 | validateUserId((String) request.getRequest().get(JsonKey.USER_ID)); 16 | } 17 | 18 | public void validateUserId(String userId) { 19 | validateParam(userId, ResponseCode.mandatoryParamsMissing, JsonKey.USER_ID); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/resources/BulkSelfDeclaredUserUploadSample.csv: -------------------------------------------------------------------------------- 1 | Name,Diksha UUID,State,District,School Name,School UDISE ID,State provided ext. ID,Phone number,Email ID,Persona,Status,Error Type,Channel 2 | localstateuser15,c13f855b-6aec-47c2-aabd-063c0a2c21e6,Andaman & Nicobar Islands,MIDDLE AND NORTH ANDAMANS,school15,localsuborgxternalid,externalid15,8917401167,localstateuser15@yopmail.com,teacher,ERROR,ERROR-ID,localstatechannel 3 | localstateuser16,c13f855b-6aec-47c2-aabd-063c0a2c21e6,Andaman & Nicobar Islands,MIDDLE AND NORTH ANDAMANS,school16,localsuborgxternalid,externalid16,8917401167,localstateuser16@yopmail.com,teacher,REJECTED,,localstatechannel 4 | localstateuser17,c13f855b-6aec-47c2-aabd-063c0a2c21e6,Andaman & Nicobar Islands,MIDDLE AND NORTH ANDAMANS,school17,localsuborgxternalid,externalid17,8917401167,localstateuser17@yopmail.com,teacher,VALIDATED,,localstatechannel 5 | -------------------------------------------------------------------------------- /service/app/util/Attrs.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import org.sunbird.common.models.util.JsonKey; 4 | import play.libs.typedmap.TypedKey; 5 | 6 | public class Attrs { 7 | public static final TypedKey USER_ID = TypedKey.create(JsonKey.USER_ID); 8 | public static final TypedKey CONTEXT = TypedKey.create(JsonKey.CONTEXT); 9 | public static final TypedKey MANAGED_FOR = TypedKey.create(JsonKey.MANAGED_FOR); 10 | public static final TypedKey START_TIME = TypedKey.create(JsonKey.START_TIME); 11 | public static final TypedKey AUTH_WITH_MASTER_KEY = 12 | TypedKey.create(JsonKey.AUTH_WITH_MASTER_KEY); 13 | public static final TypedKey IS_AUTH_REQ = TypedKey.create(JsonKey.IS_AUTH_REQ); 14 | public static final TypedKey X_REQUEST_ID = TypedKey.create(JsonKey.X_REQUEST_ID); 15 | } 16 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/ratelimit/dao/RateLimitDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.ratelimit.dao; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.request.RequestContext; 6 | import org.sunbird.ratelimit.limiter.RateLimit; 7 | 8 | public interface RateLimitDao { 9 | 10 | /** 11 | * Inserts one or more rate limits for throttling 12 | * 13 | * @param rateLimits List of rate limits 14 | * @param context 15 | */ 16 | void insertRateLimits(List rateLimits, RequestContext context); 17 | 18 | /** 19 | * Fetches list of rate limits for given (partition) key 20 | * 21 | * @param key Partition key (e.g. phone number, email address) 22 | * @param context 23 | * @return List of rate limits for given key 24 | */ 25 | List> getRateLimits(String key, RequestContext context); 26 | } 27 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/main/java/org/sunbird/notification/sms/Sms.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.notification.sms; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** @author Manzarul */ 7 | public class Sms implements Serializable { 8 | 9 | /** */ 10 | private static final long serialVersionUID = -5055157442558614964L; 11 | 12 | private String message; 13 | private List to; 14 | 15 | public Sms(String message, List to) { 16 | this.message = message; 17 | this.to = to; 18 | } 19 | 20 | /** @return the serialversionuid */ 21 | public static long getSerialversionuid() { 22 | return serialVersionUID; 23 | } 24 | 25 | /** @return the message */ 26 | public String getMessage() { 27 | return message; 28 | } 29 | 30 | /** @return the to */ 31 | public List getTo() { 32 | return to; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/dao/UserSelfDeclarationDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.dao; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.request.RequestContext; 6 | import org.sunbird.models.user.UserDeclareEntity; 7 | 8 | public interface UserSelfDeclarationDao { 9 | void insertSelfDeclaredFields(Map extIdMap, RequestContext context); 10 | 11 | UserDeclareEntity upsertUserSelfDeclaredFields( 12 | UserDeclareEntity userDeclareEntity, RequestContext context); 13 | 14 | List> getUserSelfDeclaredFields( 15 | UserDeclareEntity userDeclareEntity, RequestContext context); 16 | 17 | List> getUserSelfDeclaredFields(String userId, RequestContext context); 18 | 19 | void deleteUserSelfDeclaredDetails( 20 | String userId, String orgId, String persona, RequestContext context); 21 | } 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/mail/GMailAuthenticator.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.common.models.util.mail; 3 | 4 | import javax.mail.Authenticator; 5 | import javax.mail.PasswordAuthentication; 6 | 7 | /** @author Manzarul.Haque */ 8 | public class GMailAuthenticator extends Authenticator { 9 | private String user; 10 | private String pw; 11 | 12 | /** 13 | * this method is used to authenticate gmail user name and password. 14 | * 15 | * @param username 16 | * @param password 17 | */ 18 | public GMailAuthenticator(String username, String password) { 19 | super(); 20 | this.user = username; 21 | this.pw = password; 22 | } 23 | 24 | /** */ 25 | @Override 26 | public PasswordAuthentication getPasswordAuthentication() { 27 | return new PasswordAuthentication(this.user, this.pw); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/util/ExecutorManager.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.util; 2 | 3 | import java.util.concurrent.Executors; 4 | import java.util.concurrent.ScheduledExecutorService; 5 | 6 | /** 7 | * This class will manage execute service thread. 8 | * 9 | * @author Manzarul.Haque 10 | */ 11 | public final class ExecutorManager { 12 | 13 | private static final int MAX_EXECUTOR_THREAD = 2; 14 | /* 15 | * service ScheduledExecutorService object 16 | */ 17 | private static ScheduledExecutorService service = null; 18 | 19 | private ExecutorManager() {} 20 | 21 | static { 22 | service = Executors.newScheduledThreadPool(MAX_EXECUTOR_THREAD); 23 | } 24 | 25 | /** 26 | * This method will send executor service object. 27 | * 28 | * @return 29 | */ 30 | public static ScheduledExecutorService getExecutorService() { 31 | return service; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/util/UserFlagEnum.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.util; 2 | 3 | import org.sunbird.common.models.util.JsonKey; 4 | 5 | /** 6 | * UserFlagEnum provides all the flags of user type It contains flagtype and corresponding value in 7 | * decimal format value should be bit enabled and equivalent to decimal format. If any flag is 8 | * added, please add value as 2 pow (position-1) 9 | */ 10 | public enum UserFlagEnum { 11 | STATE_VALIDATED(JsonKey.STATE_VALIDATED, 4); 12 | 13 | private String userFlagType; 14 | private int userFlagValue; 15 | 16 | UserFlagEnum(String userFlagType, int userFlagValue) { 17 | this.userFlagType = userFlagType; 18 | this.userFlagValue = userFlagValue; 19 | } 20 | 21 | public int getUserFlagValue() { 22 | return userFlagValue; 23 | } 24 | 25 | public String getUserFlagType() { 26 | return userFlagType; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/error/CsvErrorDispatcher.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.error; 2 | 3 | import org.sunbird.common.exception.ProjectCommonException; 4 | import org.sunbird.common.responsecode.ResponseCode; 5 | 6 | /** 7 | * this class will dispatch the errors in the csv format 8 | * 9 | * @author anmolgupta 10 | */ 11 | public class CsvErrorDispatcher implements IErrorDispatcher { 12 | 13 | private CsvError error; 14 | 15 | private CsvErrorDispatcher(CsvError error) { 16 | this.error = error; 17 | } 18 | 19 | public static CsvErrorDispatcher getInstance(CsvError error) { 20 | return new CsvErrorDispatcher(error); 21 | } 22 | 23 | @Override 24 | public void dispatchError() { 25 | throw new ProjectCommonException( 26 | ResponseCode.invalidRequestData.getErrorCode(), 27 | error.getErrorsList().toString(), 28 | ResponseCode.CLIENT_ERROR.getResponseCode()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/validator/UserDataEncryptionRequestValidator.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement.validator; 2 | 3 | import org.sunbird.common.models.util.JsonKey; 4 | import org.sunbird.common.request.BaseRequestValidator; 5 | import org.sunbird.common.request.Request; 6 | import org.sunbird.common.responsecode.ResponseCode; 7 | 8 | public class UserDataEncryptionRequestValidator extends BaseRequestValidator { 9 | 10 | public void validateEncryptRequest(Request request) { 11 | commonValidation(request); 12 | } 13 | 14 | public void validateDecryptRequest(Request request) { 15 | commonValidation(request); 16 | } 17 | 18 | private void commonValidation(Request request) { 19 | if (request.getRequest().get(JsonKey.USER_IDs) == null) { 20 | validateParam(null, ResponseCode.mandatoryParamsMissing, JsonKey.USER_IDs); 21 | } 22 | validateListParam(request.getRequest(), JsonKey.USER_IDs); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /service/app/filters/AccessLogFilter.java: -------------------------------------------------------------------------------- 1 | package filters; 2 | 3 | import akka.util.ByteString; 4 | import java.util.concurrent.Executor; 5 | import javax.inject.Inject; 6 | import play.libs.streams.Accumulator; 7 | import play.mvc.EssentialAction; 8 | import play.mvc.EssentialFilter; 9 | import play.mvc.Result; 10 | 11 | public class AccessLogFilter extends EssentialFilter { 12 | 13 | private final Executor executor; 14 | 15 | @Inject 16 | public AccessLogFilter(Executor executor) { 17 | super(); 18 | this.executor = executor; 19 | } 20 | 21 | @Override 22 | public EssentialAction apply(EssentialAction next) { 23 | return EssentialAction.of( 24 | request -> { 25 | Accumulator accumulator = next.apply(request); 26 | return accumulator.map( 27 | result -> { 28 | return result; 29 | }, 30 | executor); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/src/main/java/org/sunbird/helper/ServiceFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.helper; 2 | 3 | import org.sunbird.cassandra.CassandraOperation; 4 | import org.sunbird.cassandraimpl.CassandraDACImpl; 5 | 6 | /** 7 | * This class will provide cassandraOperationImpl instance. 8 | * 9 | * @author Manzarul 10 | */ 11 | public class ServiceFactory { 12 | private static CassandraOperation operation = null; 13 | 14 | private ServiceFactory() {} 15 | 16 | /** 17 | * On call of this method , it will provide a new CassandraOperationImpl instance on each call. 18 | * 19 | * @return 20 | */ 21 | public static CassandraOperation getInstance() { 22 | if (null == operation) { 23 | synchronized (ServiceFactory.class) { 24 | if (null == operation) { 25 | operation = new CassandraDACImpl(); 26 | } 27 | } 28 | } 29 | return operation; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.sunbird 5 | sunbird-util 6 | 1.0-SNAPSHOT 7 | ../pom.xml 8 | 9 | 4.0.0 10 | org.sunbird 11 | sunbird-platform-core 12 | 1.0-SNAPSHOT 13 | pom 14 | sunbird-platform-core 15 | 16 | 17 | common-util 18 | actor-util 19 | actor-core 20 | sunbird-commons 21 | 22 | 23 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/src/test/resources/cassandra.cql: -------------------------------------------------------------------------------- 1 | CREATE KEYSPACE IF NOT EXISTS sunbird1 WITH replication = {'class':'SimpleStrategy','replication_factor':1}; 2 | 3 | //to change cluster name 4 | //UPDATE system.local SET cluster_name = 'sunbird' where key='local'; 5 | //ALTER USER cassandra WITH PASSWORD 'password'; 6 | USE sunbird1; 7 | 8 | //Address Type values(permanent, current, office, home) 9 | CREATE TABLE IF NOT EXISTS sunbird1.address1(id text, userId text, country text,state text,city text,zipCode text,addType text,createdDate text,createdBy text,updatedDate text,updatedBy text, PRIMARY KEY (id)); 10 | //CREATE INDEX inx_add_userid ON sunbird1.address1 (userId); 11 | //CREATE INDEX inx_add_addType ON sunbird1.address1 (addType); 12 | 13 | //ALTER TABLE sunbird1.address1 ADD addressLine1 text; 14 | //ALTER TABLE sunbird1.address1 ADD addressLine2 text; 15 | 16 | //ALTER TABLE sunbird1.address1 ADD isDeleted boolean; -------------------------------------------------------------------------------- /service/app/org/sunbird/validator/systemsettings/SystemSettingsRequestValidator.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.validator.systemsettings; 2 | 3 | import org.sunbird.common.models.util.JsonKey; 4 | import org.sunbird.common.request.BaseRequestValidator; 5 | import org.sunbird.common.request.Request; 6 | import org.sunbird.common.responsecode.ResponseCode; 7 | 8 | public class SystemSettingsRequestValidator extends BaseRequestValidator { 9 | public void validateSetSystemSetting(Request request) { 10 | validateParam( 11 | (String) request.getRequest().get(JsonKey.ID), 12 | ResponseCode.mandatoryParamsMissing, 13 | JsonKey.ID); 14 | validateParam( 15 | (String) request.getRequest().get(JsonKey.FIELD), 16 | ResponseCode.mandatoryParamsMissing, 17 | JsonKey.FIELD); 18 | validateParam( 19 | (String) request.getRequest().get(JsonKey.VALUE), 20 | ResponseCode.mandatoryParamsMissing, 21 | JsonKey.VALUE); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.sunbird 5 | mw-actors 6 | 1.0-SNAPSHOT 7 | ../pom.xml 8 | 9 | 4.0.0 10 | org.sunbird 11 | sunbird-util 12 | 1.0-SNAPSHOT 13 | pom 14 | Sunbird Utils 15 | 16 | sunbird-cassandra-utils 17 | sunbird-es-utils 18 | sunbird-platform-core 19 | sunbird-notification 20 | auth-verifier 21 | 22 | 23 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/CloudService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util.azure; 2 | 3 | import java.io.File; 4 | import java.util.List; 5 | import org.sunbird.common.request.RequestContext; 6 | 7 | /** Created by arvind on 24/8/17. */ 8 | public interface CloudService { 9 | 10 | String uploadFile( 11 | String containerName, String filName, String fileLocation, RequestContext context); 12 | 13 | boolean downLoadFile( 14 | String containerName, String fileName, String downloadFolder, RequestContext context); 15 | 16 | String uploadFile(String containerName, File file, RequestContext context); 17 | 18 | boolean deleteFile(String containerName, String fileName, RequestContext context); 19 | 20 | List listAllFiles(String containerName, RequestContext context); 21 | 22 | boolean deleteContainer(String containerName, RequestContext context); 23 | } 24 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/BulkUploadActorOperation.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | /** Enum to represent bulk upload operations */ 4 | public enum BulkUploadActorOperation { 5 | LOCATION_BULK_UPLOAD("locationBulkUpload"), 6 | LOCATION_BULK_UPLOAD_BACKGROUND_JOB("locationBulkUploadBackground"), 7 | 8 | ORG_BULK_UPLOAD("orgBulkUpload"), 9 | ORG_BULK_UPLOAD_BACKGROUND_JOB("orgBulkUploadBackground"), 10 | 11 | USER_BULK_UPLOAD("userBulkUpload"), 12 | USER_BULK_UPLOAD_BACKGROUND_JOB("userBulkUploadBackground"), 13 | USER_BULK_MIGRATION("userBulkMigration"), 14 | USER_BULK_SELF_DECLARED("userBulkSelfDeclared"), 15 | PROCESS_USER_BULK_SELF_DECLARED("processUserBulkSelfDeclared"); 16 | 17 | private String value; 18 | 19 | BulkUploadActorOperation(String value) { 20 | this.value = value; 21 | } 22 | 23 | public String getValue() { 24 | return this.value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/service/AssociationMechanism.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.service; 2 | 3 | public class AssociationMechanism { 4 | 5 | public static int SSO = 1; 6 | public static int SELF_DECLARATION = 2; 7 | public static int SYSTEM_UPLOAD = 4; 8 | 9 | private int associationType = 0; 10 | 11 | public int getAssociationType() { 12 | return associationType; 13 | } 14 | 15 | public void setAssociationType(int associationType) { 16 | this.associationType = associationType; 17 | } 18 | 19 | public void appendAssociationType(int inAssociationType) { 20 | this.associationType = this.associationType | inAssociationType; 21 | } 22 | 23 | public void removeAssociationType(int inAssociationType) { 24 | this.associationType = this.associationType ^ inAssociationType; 25 | } 26 | 27 | public boolean isAssociationType(int associationType) { 28 | return (this.associationType & associationType) == associationType; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/util/UserActorOperations.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.util; 2 | 3 | public enum UserActorOperations { 4 | INSERT_USER_ORG_DETAILS("insertUserOrgDetails"), 5 | UPDATE_USER_ORG_DETAILS("updateUserOrgDetails"), 6 | UPSERT_USER_EXTERNAL_IDENTITY_DETAILS("upsertUserExternalIdentityDetails"), 7 | PROCESS_ONBOARDING_MAIL_AND_SMS("processOnBoardingMailAndSms"), 8 | PROCESS_PASSWORD_RESET_MAIL_AND_SMS("processPasswordResetMailAndSms"), 9 | SAVE_USER_ATTRIBUTES("saveUserAttributes"), 10 | UPSERT_USER_DETAILS_TO_ES("upsertUserDetailsToES"), 11 | UPSERT_USER_ORG_DETAILS_TO_ES("upsertUserOrgDetailsToES"), 12 | UPSERT_USER_SELF_DECLARATIONS("upsertUserSelfDeclarations"), 13 | UPDATE_USER_SELF_DECLARATIONS_ERROR_TYPE("updateUserSelfDeclarationsErrorType"); 14 | 15 | private String value; 16 | 17 | UserActorOperations(String value) { 18 | this.value = value; 19 | } 20 | 21 | public String getValue() { 22 | return this.value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/bulkupload/dao/BulkUploadProcessDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.bulkupload.dao; 2 | 3 | import org.sunbird.common.models.response.Response; 4 | import org.sunbird.common.request.RequestContext; 5 | import org.sunbird.learner.actors.bulkupload.model.BulkUploadProcess; 6 | 7 | /** Created by arvind on 24/4/18. */ 8 | public interface BulkUploadProcessDao { 9 | 10 | /** 11 | * @param bulkUploadProcess 12 | * @param context 13 | * @return response Response 14 | */ 15 | Response create(BulkUploadProcess bulkUploadProcess, RequestContext context); 16 | 17 | /** 18 | * @param bulkUploadProcess 19 | * @param context 20 | * @return response Response 21 | */ 22 | Response update(BulkUploadProcess bulkUploadProcess, RequestContext context); 23 | 24 | /** 25 | * @param id 26 | * @param context 27 | * @return response Response 28 | */ 29 | BulkUploadProcess read(String id, RequestContext context); 30 | } 31 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/ResponseParamsTest.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.common.models; 3 | 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.sunbird.common.models.response.ResponseParams; 7 | 8 | /** @author Manzarul */ 9 | public class ResponseParamsTest { 10 | 11 | @Test 12 | public void testResponseParamBean() { 13 | ResponseParams params = new ResponseParams(); 14 | params.setMsgid("test"); 15 | params.setResmsgid("test-1"); 16 | params.setStatus("OK"); 17 | Assert.assertEquals(params.getMsgid(), "test"); 18 | Assert.assertEquals(params.getResmsgid(), "test-1"); 19 | Assert.assertEquals(params.getStatus(), "OK"); 20 | Assert.assertEquals(ResponseParams.StatusType.FAILED.name(), "FAILED"); 21 | Assert.assertEquals(ResponseParams.StatusType.SUCCESSFUL.name(), "SUCCESSFUL"); 22 | Assert.assertEquals(ResponseParams.StatusType.WARNING.name(), "WARNING"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/dao/UserConsentDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.dao; 2 | 3 | import org.sunbird.common.models.response.Response; 4 | import org.sunbird.common.request.RequestContext; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public interface UserConsentDao { 10 | 11 | /** 12 | * This method will update existing user info or throw ProjectCommonException. 13 | * 14 | * @param consent UserConsent Details. 15 | * @param context 16 | */ 17 | Response updateConsent(Map consent, RequestContext context); 18 | 19 | /** 20 | * This method will get UserConsent based on userId and return UserConsent if found else throw 21 | * ProjectCommonException. 22 | * 23 | * @param consentReq consent id. 24 | * @param context 25 | * @return UserConsent UserConsent Details. 26 | */ 27 | List> getConsent(Map consentReq, RequestContext context); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/models/url/action/UrlAction.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.url.action; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | @JsonInclude(JsonInclude.Include.NON_NULL) 10 | public class UrlAction implements Serializable { 11 | private static final long serialVersionUID = 1L; 12 | private String id; 13 | private String name; 14 | private List url; 15 | 16 | public String getId() { 17 | return id; 18 | } 19 | 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public List getUrl() { 33 | return url; 34 | } 35 | 36 | public void setUrl(List url) { 37 | this.url = url; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManager.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.helper; 2 | 3 | import com.datastax.driver.core.Session; 4 | import java.util.List; 5 | 6 | /** 7 | * Interface for cassandra connection manager , implementation would be Standalone and Embedde 8 | * cassandra connection manager . 9 | */ 10 | public interface CassandraConnectionManager { 11 | 12 | /** 13 | * Method to create the cassandra connection . 14 | * 15 | * @param hosts 16 | */ 17 | void createConnection(String[] hosts); 18 | 19 | /** 20 | * Method to get the cassandra session oject on basis of keyspace name provided . 21 | * 22 | * @param keyspaceName 23 | * @return Session 24 | */ 25 | Session getSession(String keyspaceName); 26 | 27 | /** 28 | * Method to get the cassandra cluster oject on basis of keyspace name provided . 29 | * 30 | * @param keyspaceName 31 | * @return List 32 | */ 33 | List getTableList(String keyspaceName); 34 | } 35 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/impl/LogMaskServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util.datasecurity.impl; 2 | 3 | import org.sunbird.common.models.util.datasecurity.DataMaskingService; 4 | 5 | public class LogMaskServiceImpl implements DataMaskingService { 6 | /** 7 | * Mask an email 8 | * 9 | * @param email 10 | * @return the first 4 or 2 characters in plain and masks the rest. The domain is still in plain 11 | */ 12 | public String maskEmail(String email) { 13 | if (email.indexOf("@") > 4) { 14 | return email.replaceAll("(^[^@]{4}|(?!^)\\G)[^@]", "$1*"); 15 | } else { 16 | return email.replaceAll("(^[^@]{2}|(?!^)\\G)[^@]", "$1*"); 17 | } 18 | } 19 | 20 | /** 21 | * Mask a phone number 22 | * 23 | * @param phone 24 | * @return a string with the last digit masked 25 | */ 26 | public String maskPhone(String phone) { 27 | return phone.replaceAll("(^[^*]{9}|(?!^)\\G)[^*]", "$1*"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/java/org/sunbird/learner/util/UserFlagUtilTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.util; 2 | 3 | import java.util.Map; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 8 | import org.powermock.modules.junit4.PowerMockRunner; 9 | import org.sunbird.common.models.util.JsonKey; 10 | 11 | @RunWith(PowerMockRunner.class) 12 | @PowerMockIgnore({ 13 | "javax.management.*", 14 | "javax.net.ssl.*", 15 | "javax.security.*", 16 | "jdk.internal.reflect.*" 17 | }) 18 | public class UserFlagUtilTest { 19 | 20 | @Test 21 | public void testGetFlagValue() { 22 | Assert.assertEquals( 23 | 4, UserFlagUtil.getFlagValue(UserFlagEnum.STATE_VALIDATED.getUserFlagType(), true)); 24 | } 25 | 26 | @Test 27 | public void testAssignUserFlagValues() { 28 | Map userFlagMap = UserFlagUtil.assignUserFlagValues(4); 29 | Assert.assertEquals(true, userFlagMap.get(JsonKey.STATE_VALIDATED)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/src/main/java/org/sunbird/helper/ElasticSearchSettings.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.helper; 3 | 4 | /** 5 | * This class will define Elastic search default settings. 6 | * 7 | * @author Manzarul 8 | */ 9 | public class ElasticSearchSettings { 10 | 11 | /** 12 | * This method will do default settings for Elastic search index 13 | * 14 | * @return String 15 | */ 16 | public static String createSettingsForIndex() { 17 | String settings = 18 | "{\"analysis\": {\"analyzer\": {\"cs_index_analyzer\": {\"type\": \"custom\",\"tokenizer\": \"standard\",\"filter\": [\"lowercase\",\"mynGram\"]},\"cs_search_analyzer\": {\"type\": \"custom\",\"tokenizer\": \"standard\",\"filter\": [\"lowercase\",\"standard\"]},\"keylower\": {\"type\": \"custom\",\"tokenizer\": \"keyword\",\"filter\": \"lowercase\"}},\"filter\": {\"mynGram\": {\"type\": \"ngram\",\"min_gram\": 1,\"max_gram\": 20,\"token_chars\": [\"letter\", \"digit\",\"whitespace\",\"punctuation\",\"symbol\"]} }}}"; 19 | return settings; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/datasecurity/impl/OnWayhashingTest.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.common.models.util.datasecurity.impl; 3 | 4 | import static org.junit.Assert.assertEquals; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.sunbird.common.models.util.datasecurity.OneWayHashing; 9 | 10 | /** @author Manzarul */ 11 | public class OnWayhashingTest { 12 | public static String data = "test1234$5"; 13 | 14 | @Test 15 | public void validateDataHashingSuccess() { 16 | String encryptval = OneWayHashing.encryptVal("test1234$5"); 17 | Assert.assertNotEquals(encryptval.length(), 0); 18 | assertEquals(encryptval, OneWayHashing.encryptVal(data)); 19 | } 20 | 21 | @Test 22 | public void validateDataHashingFailure() { 23 | assertEquals(OneWayHashing.encryptVal(null).length(), 0); 24 | } 25 | 26 | @Test 27 | public void validateDataHashingWithEmptyKey() { 28 | Assert.assertNotEquals((OneWayHashing.encryptVal("")).length(), 0); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/collector/TelemetryDataAssemblerImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.collector; 2 | 3 | import java.util.Map; 4 | import org.sunbird.telemetry.util.TelemetryGenerator; 5 | 6 | /** Created by arvind on 5/1/18. */ 7 | public class TelemetryDataAssemblerImpl implements TelemetryDataAssembler { 8 | 9 | @Override 10 | public String audit(Map context, Map params) { 11 | return TelemetryGenerator.audit(context, params); 12 | } 13 | 14 | @Override 15 | public String search(Map context, Map params) { 16 | return TelemetryGenerator.search(context, params); 17 | } 18 | 19 | @Override 20 | public String log(Map context, Map params) { 21 | return TelemetryGenerator.log(context, params); 22 | } 23 | 24 | @Override 25 | public String error(Map context, Map params) { 26 | return TelemetryGenerator.error(context, params); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | jobs: 3 | build: 4 | machine: 5 | image: ubuntu-2004:202008-01 6 | steps: 7 | - checkout 8 | - restore_cache: 9 | key: lms-dependency-cache-{{ checksum "pom.xml" }} 10 | - run: mvn clean install 11 | - run: cd service && mvn play2:dist 12 | - save_cache: 13 | key: lms-dependency-cache-{{ checksum "pom.xml" }} 14 | paths: ~/.m2 15 | - run: 16 | name: Analyze on SonarCloud 17 | command: mvn verify -DskipTests sonar:sonar -Dsonar.projectKey=project-sunbird_sunbird-lms-service -Dsonar.organization=project-sunbird -Dsonar.host.url=https://sonarcloud.io -Dsonar.coverage.exclusions=**/mw-service/**,**/actor-util/**,**/actor-core/**,**/sunbird-commons/**,**/sunbird-cassandra-utils/**,**/sunbird-es-utils/**,**/sunbird-platform-core/**,**/auth-verifier/**,**/models/**,**/model/**,**/bean/**,**/dto/** -Dsonar.coverage.jacoco.xmlReportPaths=/home/circleci/project/reports/target/jacoco/jacoco.xml 18 | 19 | workflows: 20 | version: 2.1 21 | workflow: 22 | jobs: 23 | - build 24 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/ratelimit/limiter/OtpRateLimiter.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.ratelimit.limiter; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.sunbird.common.models.util.ProjectUtil; 5 | 6 | /** Defines various rate limits for OTP functionality with rate and corresponding TTL. */ 7 | public enum OtpRateLimiter implements RateLimiter { 8 | MINUTE("sunbird_otp_minute_rate_limit", 60), 9 | HOUR("sunbird_otp_hour_rate_limit", 3600), 10 | DAY("sunbird_otp_day_rate_limit", 86400); 11 | 12 | private String limitKey; 13 | private int ttl; 14 | 15 | private OtpRateLimiter(String limitKey, int ttl) { 16 | this.limitKey = limitKey; 17 | this.ttl = ttl; 18 | } 19 | 20 | public String getLimitKey() { 21 | return limitKey; 22 | } 23 | 24 | public Integer getRateLimit() { 25 | String limitVal = ProjectUtil.getConfigValue(limitKey); 26 | if (!StringUtils.isBlank(limitVal)) { 27 | return Integer.valueOf(limitVal); 28 | } 29 | return null; 30 | } 31 | 32 | public int getTTL() { 33 | return ttl; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/models/role/group/RoleGroup.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.role.group; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | @JsonInclude(JsonInclude.Include.NON_NULL) 10 | public class RoleGroup implements Serializable { 11 | private static final long serialVersionUID = 1L; 12 | private String id; 13 | private String name; 14 | private List url_Action_Ids; 15 | 16 | public String getId() { 17 | return id; 18 | } 19 | 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public List getUrlActionIds() { 33 | return url_Action_Ids; 34 | } 35 | 36 | public void setUrlActionIds(List url_Action_Ids) { 37 | this.url_Action_Ids = url_Action_Ids; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/validator/user/UserTenantMigrationRequestValidator.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.validator.user; 2 | 3 | import java.util.Map; 4 | import org.sunbird.common.models.util.JsonKey; 5 | import org.sunbird.common.request.Request; 6 | import org.sunbird.common.responsecode.ResponseCode; 7 | 8 | /** 9 | * Request validator class for user tenant migration request. 10 | * 11 | * @author Amit Kumar 12 | */ 13 | public class UserTenantMigrationRequestValidator extends UserRequestValidator { 14 | 15 | /** 16 | * This method will validate the user migration request. 17 | * 18 | * @param request user migration request body 19 | */ 20 | public void validateUserTenantMigrateRequest(Request request) { 21 | Map req = request.getRequest(); 22 | validateParam( 23 | (String) req.get(JsonKey.CHANNEL), ResponseCode.mandatoryParamsMissing, JsonKey.CHANNEL); 24 | validateParam( 25 | (String) req.get(JsonKey.USER_ID), ResponseCode.mandatoryParamsMissing, JsonKey.USER_ID); 26 | externalIdsValidation(request, JsonKey.CREATE); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/dao/UserLookupDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.dao; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.models.response.Response; 6 | import org.sunbird.common.request.RequestContext; 7 | 8 | public interface UserLookupDao { 9 | 10 | public Response insertRecords(List> reqMap, RequestContext context); 11 | 12 | public void deleteRecords(List> reqMap, RequestContext context); 13 | 14 | public Response insertExternalIdIntoUserLookup( 15 | List> reqMap, String userId, RequestContext context); 16 | 17 | public List> getRecordByType( 18 | String type, String value, boolean encrypt, RequestContext context); 19 | 20 | public List> getEmailByType(String email, RequestContext context); 21 | 22 | public List> getPhoneByType(String phone, RequestContext context); 23 | 24 | public List> getUsersByUserNames( 25 | Map partitionKeyMap, RequestContext context); 26 | } 27 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/RequestParamsTest.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.common.models; 3 | 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.sunbird.common.request.RequestParams; 7 | 8 | /** @author Manzarul */ 9 | public class RequestParamsTest { 10 | 11 | @Test 12 | public void testResponseParamBean() { 13 | RequestParams params = new RequestParams(); 14 | params.setAuthToken("auth_1233"); 15 | params.setCid("cid"); 16 | params.setDid("deviceId"); 17 | params.setKey("account key"); 18 | params.setMsgid("uniqueMsgId"); 19 | params.setSid("sid"); 20 | params.setUid("UUID"); 21 | Assert.assertEquals(params.getAuthToken(), "auth_1233"); 22 | Assert.assertEquals(params.getCid(), "cid"); 23 | Assert.assertEquals(params.getMsgid(), "uniqueMsgId"); 24 | Assert.assertEquals(params.getDid(), "deviceId"); 25 | Assert.assertEquals(params.getKey(), "account key"); 26 | Assert.assertEquals(params.getSid(), "sid"); 27 | Assert.assertEquals(params.getUid(), "UUID"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Project Sunbird 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/src/main/java/org/sunbird/common/factory/EsClientFactory.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.factory; 2 | 3 | import org.sunbird.common.ElasticSearchRestHighImpl; 4 | import org.sunbird.common.inf.ElasticSearchService; 5 | import org.sunbird.common.models.util.JsonKey; 6 | 7 | public class EsClientFactory { 8 | 9 | private static ElasticSearchService restClient = null; 10 | 11 | /** 12 | * This method return REST/TCP client for elastic search 13 | * 14 | * @param type can be "tcp" or "rest" 15 | * @return ElasticSearchService with the respected type impl 16 | */ 17 | public static ElasticSearchService getInstance(String type) { 18 | if (JsonKey.REST.equals(type)) { 19 | return getRestClient(); 20 | } 21 | return null; 22 | } 23 | 24 | private static ElasticSearchService getRestClient() { 25 | if (restClient == null) { 26 | synchronized (EsClientFactory.class) { 27 | if (restClient == null) { 28 | restClient = new ElasticSearchRestHighImpl(); 29 | } 30 | } 31 | } 32 | return restClient; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/URLShortnerImplTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.sunbird.common.models.util.url.URLShortner; 7 | import org.sunbird.common.models.util.url.URLShortnerImpl; 8 | 9 | public class URLShortnerImplTest { 10 | 11 | @Test 12 | public void urlShortTest() { 13 | URLShortner shortner = new URLShortnerImpl(); 14 | String url = shortner.shortUrl("https://staging.open-sunbird.org/"); 15 | Assert.assertNotNull(url); 16 | } 17 | 18 | @Test 19 | public void getShortUrlTest() { 20 | 21 | String SUNBIRD_WEB_URL = "sunbird_web_url"; 22 | 23 | String webUrl = System.getenv(SUNBIRD_WEB_URL); 24 | if (StringUtils.isBlank(webUrl)) { 25 | webUrl = PropertiesCache.getInstance().getProperty(SUNBIRD_WEB_URL); 26 | } 27 | 28 | URLShortnerImpl shortnerImpl = new URLShortnerImpl(); 29 | String url = shortnerImpl.getUrl(); 30 | Assert.assertEquals(url, webUrl); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | sunbird-lms-mw 7 | org.sunbird 8 | 1.0-SNAPSHOT 9 | 10 | org.sunbird 11 | 1.0-SNAPSHOT 12 | 4.0.0 13 | mw-actors 14 | pom 15 | Middleware Actors 16 | 17 | 2.5.19 18 | 19 | 20 | common 21 | user 22 | organization 23 | location 24 | systemsettings 25 | 26 | 27 | 28 | junit 29 | junit 30 | 4.12 31 | test 32 | 33 | 34 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/EmailValidator.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | import org.apache.commons.lang.StringUtils; 6 | 7 | /** 8 | * Helper class for validating email. 9 | * 10 | * @author Amit Kumar 11 | */ 12 | public class EmailValidator { 13 | 14 | private static Pattern pattern; 15 | private static final String EMAIL_PATTERN = 16 | "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" 17 | + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; 18 | 19 | private EmailValidator() {} 20 | 21 | static { 22 | pattern = Pattern.compile(EMAIL_PATTERN); 23 | } 24 | 25 | /** 26 | * Validates format of email. 27 | * 28 | * @param email Email value. 29 | * @return True, if email format is valid. Otherwise, return false. 30 | */ 31 | public static boolean isEmailValid(String email) { 32 | if (StringUtils.isBlank(email)) { 33 | return false; 34 | } 35 | Matcher matcher = pattern.matcher(email); 36 | return matcher.matches(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/organisation/service/impl/OrgServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.organisation.service.impl; 2 | 3 | import java.util.Map; 4 | import org.sunbird.common.request.RequestContext; 5 | import org.sunbird.learner.organisation.dao.OrgDao; 6 | import org.sunbird.learner.organisation.dao.impl.OrgDaoImpl; 7 | import org.sunbird.learner.organisation.service.OrgService; 8 | 9 | public class OrgServiceImpl implements OrgService { 10 | 11 | private OrgDao orgDao = OrgDaoImpl.getInstance(); 12 | private static OrgService orgService = null; 13 | 14 | public static OrgService getInstance() { 15 | if (orgService == null) { 16 | orgService = new OrgServiceImpl(); 17 | } 18 | return orgService; 19 | } 20 | 21 | @Override 22 | public Map getOrgById(String orgId, RequestContext context) { 23 | return orgDao.getOrgById(orgId, context); 24 | } 25 | 26 | @Override 27 | public Map getOrgByExternalIdAndProvider( 28 | String externalId, String provider, RequestContext context) { 29 | return orgDao.getOrgByExternalId(externalId, provider, context); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/util/SchedulerManager.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.learner.util; 3 | 4 | import java.util.concurrent.ScheduledExecutorService; 5 | import java.util.concurrent.TimeUnit; 6 | import org.sunbird.common.models.util.LoggerUtil; 7 | import org.sunbird.common.models.util.ProjectUtil; 8 | 9 | /** @author Manzarul All the scheduler job will be handle by this class. */ 10 | public class SchedulerManager { 11 | private static LoggerUtil logger = new LoggerUtil(SchedulerManager.class); 12 | 13 | private static final int TTL = 14 | Integer.parseInt(ProjectUtil.getConfigValue("learner_in_memory_cache_ttl")); 15 | 16 | /* 17 | * service ScheduledExecutorService object 18 | */ 19 | public static ScheduledExecutorService service = ExecutorManager.getExecutorService(); 20 | 21 | /** all scheduler job will be configure here. */ 22 | public static void schedule() { 23 | service.scheduleWithFixedDelay(new DataCacheHandler(), 0, TTL, TimeUnit.SECONDS); 24 | logger.info( 25 | "SchedulerManager:schedule: Started scheduler job for cache refresh with ttl in sec =" 26 | + TTL); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/AuditLogTest.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.common.models.util; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | /** @author Manzarul */ 10 | public class AuditLogTest { 11 | 12 | @Test 13 | public void createAuditLog() { 14 | AuditLog log = new AuditLog(); 15 | log.setDate("2017-12-29"); 16 | log.setObjectId("objectId"); 17 | log.setObjectType("User"); 18 | log.setOperationType("create"); 19 | log.setRequestId("requesterId"); 20 | log.setUserId("userId"); 21 | Map map = new HashMap<>(); 22 | log.setLogRecord(map); 23 | Assert.assertEquals("2017-12-29", log.getDate()); 24 | Assert.assertEquals("objectId", log.getObjectId()); 25 | Assert.assertEquals("User", log.getObjectType()); 26 | Assert.assertEquals("create", log.getOperationType()); 27 | Assert.assertEquals("requesterId", log.getRequestId()); 28 | Assert.assertEquals("userId", log.getUserId()); 29 | Assert.assertEquals(0, log.getLogRecord().size()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/ResetPasswordController.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement; 2 | 3 | import controllers.BaseController; 4 | import controllers.usermanagement.validator.ResetPasswordRequestValidator; 5 | import org.sunbird.common.models.util.ActorOperations; 6 | import org.sunbird.common.request.Request; 7 | import play.mvc.Http; 8 | import play.mvc.Result; 9 | 10 | import java.util.concurrent.CompletionStage; 11 | 12 | /** 13 | * 14 | * This controller contains method for reset the user password. 15 | * 16 | */ 17 | public class ResetPasswordController extends BaseController{ 18 | 19 | /** 20 | * This method will reset the password for given userId in request. 21 | * @return Promise 22 | */ 23 | public CompletionStage resetPassword(Http.Request httpRequest) { 24 | return handleRequest( 25 | ActorOperations.RESET_PASSWORD.getValue(), 26 | httpRequest.body().asJson(), 27 | (request) -> { 28 | new ResetPasswordRequestValidator().validateResetPasswordRequest((Request) request); 29 | return null; 30 | }, 31 | getAllRequestHeaders(httpRequest), 32 | httpRequest); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/validator/ResetPasswordRequestValidator.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement.validator; 2 | 3 | import org.sunbird.common.models.util.JsonKey; 4 | import org.sunbird.common.request.BaseRequestValidator; 5 | import org.sunbird.common.request.Request; 6 | import org.sunbird.common.responsecode.ResponseCode; 7 | 8 | /** 9 | * 10 | *This class will validate the reset password request 11 | * 12 | */ 13 | public class ResetPasswordRequestValidator extends BaseRequestValidator { 14 | /** 15 | * This method will validate the mandatory param in the request. 16 | * @param request 17 | */ 18 | public void validateResetPasswordRequest(Request request){ 19 | validateParam( 20 | (String) request.getRequest().get(JsonKey.USER_ID), 21 | ResponseCode.mandatoryParamsMissing, 22 | JsonKey.USER_ID); 23 | validateParam( 24 | (String) request.getRequest().get(JsonKey.KEY), 25 | ResponseCode.mandatoryParamsMissing, 26 | JsonKey.KEY); 27 | validateParam( 28 | (String) request.getRequest().get(JsonKey.TYPE), 29 | ResponseCode.mandatoryParamsMissing, 30 | JsonKey.TYPE); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/FileUtil.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | import java.io.File; 4 | import java.util.List; 5 | import org.apache.commons.lang3.StringUtils; 6 | 7 | public abstract class FileUtil { 8 | 9 | public abstract File writeToFile(String fileName, List> dataValues); 10 | 11 | @SuppressWarnings("unchecked") 12 | protected static String getListValue(Object obj) { 13 | List data = (List) obj; 14 | if (!(data.isEmpty())) { 15 | StringBuilder sb = new StringBuilder(); 16 | for (Object value : data) { 17 | sb.append((String) value).append(","); 18 | } 19 | sb.deleteCharAt(sb.length() - 1); 20 | return sb.toString(); 21 | } 22 | return ""; 23 | } 24 | 25 | public static FileUtil getFileUtil(String format) { 26 | String tempformat = ""; 27 | if (!StringUtils.isBlank(format)) { 28 | tempformat = format.toLowerCase(); 29 | } 30 | switch (tempformat) { 31 | case "excel": 32 | return (new ExcelFileUtil()); 33 | default: 34 | return (new ExcelFileUtil()); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/error/CsvRowErrorDetails.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.error; 2 | 3 | public class CsvRowErrorDetails { 4 | 5 | int rowId; 6 | private String header; 7 | private ErrorEnum errorEnum; 8 | 9 | public CsvRowErrorDetails(int rowId, String header, ErrorEnum errorEnum) { 10 | this.rowId = rowId; 11 | this.header = header; 12 | this.errorEnum = errorEnum; 13 | } 14 | 15 | public CsvRowErrorDetails() {} 16 | 17 | public int getRowId() { 18 | return rowId; 19 | } 20 | 21 | public void setRowId(int rowId) { 22 | this.rowId = rowId; 23 | } 24 | 25 | public String getHeader() { 26 | return header; 27 | } 28 | 29 | public void setHeader(String header) { 30 | this.header = header; 31 | } 32 | 33 | public ErrorEnum getErrorEnum() { 34 | return errorEnum; 35 | } 36 | 37 | public void setErrorEnum(ErrorEnum errorEnum) { 38 | this.errorEnum = errorEnum; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "ErrorDetails{" 44 | + "rowId=" 45 | + rowId 46 | + ", header='" 47 | + header 48 | + '\'' 49 | + ", errorEnum=" 50 | + errorEnum 51 | + '}'; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/otp/dao/OTPDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.otp.dao; 2 | 3 | import java.util.Map; 4 | import org.sunbird.common.request.RequestContext; 5 | 6 | public interface OTPDao { 7 | 8 | /** 9 | * Fetch OTP details based on type (phone / email) and key. 10 | * 11 | * @param type Type of key (phone / email) 12 | * @param key Phone number or email address 13 | * @param context 14 | * @return OTP details 15 | */ 16 | Map getOTPDetails(String type, String key, RequestContext context); 17 | 18 | /** 19 | * Insert OTP details for given type (phone / email) and key 20 | * 21 | * @param type Type of key (phone / email) 22 | * @param key Phone number or email address 23 | * @param otp Generated OTP 24 | * @param context 25 | */ 26 | void insertOTPDetails(String type, String key, String otp, RequestContext context); 27 | 28 | /** 29 | * this method will be used to delete the Otp 30 | * 31 | * @param type 32 | * @param key 33 | * @param context 34 | */ 35 | void deleteOtp(String type, String key, RequestContext context); 36 | 37 | void updateAttemptCount(Map otpDetails, RequestContext context); 38 | } 39 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/models/role/Role.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.role; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | @JsonInclude(JsonInclude.Include.NON_NULL) 10 | public class Role implements Serializable { 11 | private static final long serialVersionUID = 1L; 12 | private String id; 13 | private String name; 14 | private List roleGroupId; 15 | private int status; 16 | 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | public void setId(String id) { 22 | this.id = id; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public List getRoleGroupId() { 34 | return roleGroupId; 35 | } 36 | 37 | public void setRoleGroupId(List roleGroupId) { 38 | this.roleGroupId = roleGroupId; 39 | } 40 | 41 | public int getStatus() { 42 | return status; 43 | } 44 | 45 | public void setStatus(int status) { 46 | this.status = status; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /service/app/controllers/organisationmanagement/KeyManagementController.java: -------------------------------------------------------------------------------- 1 | package controllers.organisationmanagement; 2 | 3 | import controllers.BaseController; 4 | import org.sunbird.common.models.util.ActorOperations; 5 | import org.sunbird.common.request.Request; 6 | import org.sunbird.common.request.orgvalidator.KeyManagementValidator; 7 | import play.mvc.Http; 8 | import play.mvc.Result; 9 | 10 | import java.util.concurrent.CompletionStage; 11 | 12 | 13 | /** 14 | * this Class is responsible for managing the signIn and enc keys for organisation 15 | */ 16 | public class KeyManagementController extends BaseController { 17 | 18 | 19 | /** 20 | * this action method will validate and save the enc and signIn keys into organisation db. 21 | * @return Result 22 | */ 23 | public CompletionStage assignKeys(Http.Request httpRequest) { 24 | return handleRequest( 25 | ActorOperations.ASSIGN_KEYS.getValue(), 26 | httpRequest.body().asJson(), 27 | orgRequest -> { 28 | KeyManagementValidator.getInstance((Request) orgRequest).validate(); 29 | return null; 30 | }, 31 | null, null, true, 32 | httpRequest); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/test/java/org/sunbird/notification/sms/Message91GetSMSTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.notification.sms; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 6 | import org.sunbird.notification.sms.providerimpl.Msg91SmsProvider; 7 | 8 | @PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*"}) 9 | public class Message91GetSMSTest extends BaseMessageTest { 10 | 11 | // @Test 12 | public void testSendSmsGetMethodSuccess() { 13 | Msg91SmsProvider megObj = new Msg91SmsProvider(); 14 | boolean response = megObj.sendSmsGetMethod("4321111111", "say hai!"); 15 | Assert.assertTrue(response); 16 | } 17 | 18 | @Test 19 | public void testSendSmsGetMethodFailureWithoutMessage() { 20 | Msg91SmsProvider megObj = new Msg91SmsProvider(); 21 | boolean response = megObj.sendSmsGetMethod("4321111111", ""); 22 | Assert.assertFalse(response); 23 | } 24 | 25 | @Test 26 | public void testSendSmsGetMethodFailureWithEmptySpace() { 27 | Msg91SmsProvider megObj = new Msg91SmsProvider(); 28 | boolean response = megObj.sendSmsGetMethod("4321111111", " "); 29 | Assert.assertFalse(response); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/service/UserLookupService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.models.response.Response; 6 | import org.sunbird.common.request.RequestContext; 7 | import org.sunbird.models.user.User; 8 | 9 | public interface UserLookupService { 10 | 11 | public void checkEmailUniqueness(String email, RequestContext context); 12 | 13 | public boolean checkUsernameUniqueness( 14 | String username, boolean isEncrypted, RequestContext context); 15 | 16 | public void checkEmailUniqueness(User user, String opType, RequestContext context); 17 | 18 | public void checkPhoneUniqueness(String phone, RequestContext context); 19 | 20 | public void checkPhoneUniqueness(User user, String opType, RequestContext context); 21 | 22 | public void checkExternalIdUniqueness(User user, String operation, RequestContext context); 23 | 24 | Response insertRecords(List> list, RequestContext context); 25 | 26 | void deleteRecords(List> reqList, RequestContext requestContext); 27 | 28 | void insertExternalIdIntoUserLookup( 29 | List> reqMap, String s, RequestContext requestContext); 30 | } 31 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/service/impl/UserConsentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.service.impl; 2 | 3 | import org.sunbird.common.models.response.Response; 4 | import org.sunbird.common.request.RequestContext; 5 | import org.sunbird.user.dao.UserConsentDao; 6 | import org.sunbird.user.dao.impl.UserConsentDaoImpl; 7 | import org.sunbird.user.service.UserConsentService; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | public class UserConsentServiceImpl implements UserConsentService { 13 | 14 | private static UserConsentDao userConsentDao = UserConsentDaoImpl.getInstance(); 15 | 16 | private static UserConsentService consentService = null; 17 | 18 | public static UserConsentService getInstance() { 19 | if (consentService == null) { 20 | consentService = new UserConsentServiceImpl(); 21 | } 22 | return consentService; 23 | } 24 | 25 | public Response updateConsent(Map consent, RequestContext context){ 26 | return userConsentDao.updateConsent(consent, context); 27 | } 28 | 29 | public List> getConsent(Map consentReq, RequestContext context){ 30 | return userConsentDao.getConsent(consentReq, context); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/models/systemsetting/SystemSetting.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.systemsetting; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 6 | import java.io.Serializable; 7 | 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | @JsonInclude(Include.NON_NULL) 10 | public class SystemSetting implements Serializable { 11 | private static final long serialVersionUID = 1L; 12 | private String id; 13 | private String field; 14 | private String value; 15 | 16 | public SystemSetting() {} 17 | 18 | public SystemSetting(String id, String field, String value) { 19 | this.id = id; 20 | this.field = field; 21 | this.value = value; 22 | } 23 | 24 | public String getId() { 25 | return this.id; 26 | } 27 | 28 | public String getField() { 29 | return this.field; 30 | } 31 | 32 | public String getValue() { 33 | return this.value; 34 | } 35 | 36 | public void setId(String id) { 37 | this.id = id; 38 | } 39 | 40 | public void setField(String field) { 41 | this.field = field; 42 | } 43 | 44 | public void setValue(String value) { 45 | this.value = value; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/UserMergeController.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement; 2 | 3 | import controllers.BaseController; 4 | import java.util.Optional; 5 | import java.util.concurrent.CompletionStage; 6 | import org.sunbird.common.models.util.ActorOperations; 7 | import org.sunbird.common.models.util.JsonKey; 8 | import org.sunbird.common.request.Request; 9 | import org.sunbird.validator.user.UserRequestValidator; 10 | import play.mvc.Http; 11 | import play.mvc.Result; 12 | 13 | public class UserMergeController extends BaseController { 14 | 15 | public CompletionStage mergeUser(Http.Request httpRequest) { 16 | Optional authUserToken = 17 | httpRequest.getHeaders().get(JsonKey.X_AUTHENTICATED_USER_TOKEN); 18 | Optional sourceUserToken = httpRequest.getHeaders().get(JsonKey.X_SOURCE_USER_TOKEN); 19 | return handleRequest( 20 | ActorOperations.MERGE_USER.getValue(), 21 | httpRequest.body().asJson(), 22 | req -> { 23 | Request request = (Request) req; 24 | new UserRequestValidator() 25 | .validateUserMergeRequest(request, authUserToken.get(), sourceUserToken.get()); 26 | return null; 27 | }, 28 | getAllRequestHeaders(httpRequest), 29 | httpRequest); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/src/main/resources/indices/org.json: -------------------------------------------------------------------------------- 1 | { 2 | "settings": { 3 | "index": { 4 | "number_of_shards": "5", 5 | "number_of_replicas": "1", 6 | "analysis": { 7 | "filter": { 8 | "mynGram": { 9 | "token_chars": [ 10 | "letter", 11 | "digit", 12 | "whitespace", 13 | "punctuation", 14 | "symbol" 15 | ], 16 | "min_gram": "3", 17 | "type": "ngram", 18 | "max_gram": "10" 19 | } 20 | }, 21 | "analyzer": { 22 | "cs_index_analyzer": { 23 | "filter": [ 24 | "lowercase", 25 | "mynGram" 26 | ], 27 | "type": "custom", 28 | "tokenizer": "standard" 29 | }, 30 | "keylower": { 31 | "filter": "lowercase", 32 | "type": "custom", 33 | "tokenizer": "keyword" 34 | }, 35 | "cs_search_analyzer": { 36 | "filter": [ 37 | "lowercase", 38 | "standard" 39 | ], 40 | "type": "custom", 41 | "tokenizer": "standard" 42 | } 43 | } 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/UserStatusController.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement; 2 | 3 | import controllers.BaseController; 4 | import controllers.usermanagement.validator.UserStatusRequestValidator; 5 | import org.sunbird.common.models.util.ActorOperations; 6 | import org.sunbird.common.request.Request; 7 | import play.mvc.Http; 8 | import play.mvc.Result; 9 | 10 | import java.util.concurrent.CompletionStage; 11 | 12 | public class UserStatusController extends BaseController { 13 | 14 | public CompletionStage blockUser(Http.Request httpRequest) { 15 | return handleRequest( 16 | ActorOperations.BLOCK_USER.getValue(), 17 | httpRequest.body().asJson(), 18 | request -> { 19 | new UserStatusRequestValidator().validateBlockUserRequest((Request) request); 20 | return null; 21 | }, 22 | httpRequest); 23 | } 24 | 25 | public CompletionStage unblockUser(Http.Request httpRequest) { 26 | return handleRequest( 27 | ActorOperations.UNBLOCK_USER.getValue(), 28 | httpRequest.body().asJson(), 29 | request -> { 30 | new UserStatusRequestValidator().validateUnblockUserRequest((Request) request); 31 | return null; 32 | }, 33 | httpRequest); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/EntryExitLogEvent.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public class EntryExitLogEvent { 8 | private String eid; 9 | 10 | private Map edata = new HashMap<>(); 11 | 12 | public String getEid() { 13 | return eid; 14 | } 15 | 16 | public void setEid(String eid) { 17 | this.eid = eid; 18 | } 19 | 20 | public Map getEdata() { 21 | return edata; 22 | } 23 | 24 | public void setEdata( 25 | String type, 26 | String level, 27 | String requestid, 28 | String message, 29 | List> params) { 30 | this.edata.put(JsonKey.TYPE, type); 31 | this.edata.put(JsonKey.LEVEL, level); 32 | this.edata.put(JsonKey.REQUEST_ID, requestid); 33 | this.edata.put(JsonKey.MESSAGE, message); 34 | this.edata.put(JsonKey.PARAMS, params); 35 | } 36 | 37 | public void setEdataParams(List> params) { 38 | this.edata.put(JsonKey.PARAMS, params); 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "{" + "eid='" + eid + '\'' + ", edata=" + edata + '}'; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /service/app/mapper/RequestMapper.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package mapper; 3 | 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | import org.sunbird.common.models.util.LoggerUtil; 6 | import org.sunbird.common.models.util.ProjectUtil; 7 | import org.sunbird.common.responsecode.ResponseCode; 8 | import play.libs.Json; 9 | 10 | /** 11 | * This class will map the requested json data into custom class. 12 | * 13 | * @author Manzarul 14 | */ 15 | public class RequestMapper { 16 | private static LoggerUtil logger = new LoggerUtil(RequestMapper.class); 17 | 18 | /** 19 | * Method to map request 20 | * 21 | * @param requestData JsonNode 22 | * @param obj Class 23 | * @exception RuntimeException 24 | * @return 25 | */ 26 | public static Object mapRequest(JsonNode requestData, Class obj) throws RuntimeException { 27 | 28 | if (requestData == null) 29 | throw ProjectUtil.createClientException(ResponseCode.contentTypeRequiredError); 30 | 31 | try { 32 | return Json.fromJson(requestData, obj); 33 | } catch (Exception e) { 34 | logger.error("ControllerRequestMapper error : " + e.getMessage(), e); 35 | logger.info("RequestMapper:mapRequest Requested data : " + requestData); 36 | throw ProjectUtil.createClientException(ResponseCode.invalidData); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/systemsetting/SystemSetting.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.systemsetting; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 6 | import java.io.Serializable; 7 | 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | @JsonInclude(Include.NON_NULL) 10 | public class SystemSetting implements Serializable { 11 | private static final long serialVersionUID = 1L; 12 | private String id; 13 | private String field; 14 | private String value; 15 | 16 | public SystemSetting() {} 17 | 18 | public SystemSetting(String id, String field, String value) { 19 | this.id = id; 20 | this.field = field; 21 | this.value = value; 22 | } 23 | 24 | public String getId() { 25 | return this.id; 26 | } 27 | 28 | public String getField() { 29 | return this.field; 30 | } 31 | 32 | public String getValue() { 33 | return this.value; 34 | } 35 | 36 | public void setId(String id) { 37 | this.id = id; 38 | } 39 | 40 | public void setField(String field) { 41 | this.field = field; 42 | } 43 | 44 | public void setValue(String value) { 45 | this.value = value; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/models/adminutil/AdminUtilRequest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.adminutil; 2 | 3 | import com.fasterxml.jackson.annotation.*; 4 | import org.apache.commons.lang.builder.ToStringBuilder; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | 9 | @JsonIgnoreProperties(ignoreUnknown = true) 10 | public class AdminUtilRequest implements Serializable 11 | { 12 | 13 | @JsonProperty("data") 14 | private List data = null; 15 | private final static long serialVersionUID = 8702012703305240394L; 16 | 17 | /** 18 | * No args constructor for use in serialization 19 | * 20 | */ 21 | public AdminUtilRequest() { 22 | } 23 | 24 | /** 25 | * 26 | * @param data 27 | */ 28 | public AdminUtilRequest(List data) { 29 | super(); 30 | this.data = data; 31 | } 32 | 33 | @JsonProperty("data") 34 | public List getData() { 35 | return data; 36 | } 37 | 38 | @JsonProperty("data") 39 | public void setData(List data) { 40 | this.data = data; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return new ToStringBuilder(this).append("data", data).toString(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/IdentifierFreeUpController.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement; 2 | 3 | import controllers.BaseController; 4 | import org.sunbird.common.models.util.ActorOperations; 5 | import org.sunbird.common.request.Request; 6 | import org.sunbird.common.request.UserFreeUpRequestValidator; 7 | import play.mvc.Http; 8 | import play.mvc.Result; 9 | 10 | import java.util.concurrent.CompletionStage; 11 | 12 | /** 13 | * this action method is responsible to free Up the user account attributes. 14 | * 15 | * @author anmolgupta 16 | */ 17 | public class IdentifierFreeUpController extends BaseController { 18 | 19 | 20 | /** 21 | * this action method will be used to free Up user Identifier from user DB 22 | * @return 23 | */ 24 | public CompletionStage freeUpIdentifier(Http.Request httpRequest) { 25 | return handleRequest( 26 | ActorOperations.FREEUP_USER_IDENTITY.getValue(), 27 | httpRequest.body().asJson(), 28 | req -> { 29 | Request request = (Request) req; 30 | UserFreeUpRequestValidator.getInstance(request).validate(); 31 | return null; 32 | }, 33 | null, 34 | null, 35 | true, 36 | httpRequest); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/models/util/EmailTest.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.common.models.util; 3 | 4 | import javax.mail.PasswordAuthentication; 5 | import org.junit.AfterClass; 6 | import org.junit.Assert; 7 | import org.junit.BeforeClass; 8 | import org.junit.Test; 9 | import org.jvnet.mock_javamail.Mailbox; 10 | import org.sunbird.common.models.util.mail.GMailAuthenticator; 11 | 12 | /** @author Manzarul */ 13 | public class EmailTest { 14 | 15 | private static GMailAuthenticator authenticator = null; 16 | 17 | @BeforeClass 18 | public static void setUp() { 19 | authenticator = new GMailAuthenticator("test123", "test"); 20 | // clear Mock JavaMail box 21 | Mailbox.clearAll(); 22 | } 23 | 24 | @Test 25 | public void createGmailAuthInstance() { 26 | GMailAuthenticator authenticator = new GMailAuthenticator("test123", "test"); 27 | Assert.assertNotEquals(null, authenticator); 28 | } 29 | 30 | @Test 31 | public void passwordAuthTest() { 32 | PasswordAuthentication authentication = authenticator.getPasswordAuthentication(); 33 | Assert.assertEquals("test", authentication.getPassword()); 34 | } 35 | 36 | @AfterClass 37 | public static void tearDown() { 38 | authenticator = null; 39 | Mailbox.clearAll(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Producer.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | 6 | @JsonInclude(Include.NON_NULL) 7 | public class Producer { 8 | 9 | private String id; 10 | private String pid; 11 | private String ver; 12 | 13 | public Producer() {} 14 | 15 | public Producer(String id, String ver) { 16 | super(); 17 | this.id = id; 18 | this.ver = ver; 19 | } 20 | 21 | public Producer(String id, String pid, String ver) { 22 | this.id = id; 23 | this.pid = pid; 24 | this.ver = ver; 25 | } 26 | 27 | /** @return the id */ 28 | public String getId() { 29 | return id; 30 | } 31 | 32 | /** @param id the id to set */ 33 | public void setId(String id) { 34 | this.id = id; 35 | } 36 | 37 | /** @return the pid */ 38 | public String getPid() { 39 | return pid; 40 | } 41 | 42 | /** @param pid the pid to set */ 43 | public void setPid(String pid) { 44 | this.pid = pid; 45 | } 46 | 47 | /** @return the ver */ 48 | public String getVer() { 49 | return ver; 50 | } 51 | 52 | /** @param ver the ver to set */ 53 | public void setVer(String ver) { 54 | this.ver = ver; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/main/java/org/sunbird/user/actors/UserLookupActor.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user.actors; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.actor.core.BaseActor; 6 | import org.sunbird.actor.router.ActorConfig; 7 | import org.sunbird.common.models.response.Response; 8 | import org.sunbird.common.models.util.JsonKey; 9 | import org.sunbird.common.request.Request; 10 | import org.sunbird.user.service.UserService; 11 | import org.sunbird.user.service.impl.UserServiceImpl; 12 | 13 | @ActorConfig( 14 | tasks = {"userLookup"}, 15 | asyncTasks = {}, 16 | dispatcher = "most-used-one-dispatcher" 17 | ) 18 | public class UserLookupActor extends BaseActor { 19 | 20 | @Override 21 | public void onReceive(Request request) throws Throwable { 22 | searchUser(request); 23 | } 24 | 25 | private void searchUser(Request request) { 26 | UserService userService = UserServiceImpl.getInstance(); 27 | Map reqMap = request.getRequest(); 28 | List fields = (List) reqMap.get(JsonKey.FIELDS); 29 | String key = (String) reqMap.get(JsonKey.KEY); 30 | String value = (String) reqMap.get(JsonKey.VALUE); 31 | Response response = 32 | userService.userLookUpByKey(key, value, fields, request.getRequestContext()); 33 | sender().tell(response, self()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /service/app/controllers/otp/OtpController.java: -------------------------------------------------------------------------------- 1 | package controllers.otp; 2 | 3 | import controllers.BaseController; 4 | import controllers.otp.validator.OtpRequestValidator; 5 | import org.sunbird.common.models.util.ActorOperations; 6 | import org.sunbird.common.request.Request; 7 | import play.mvc.Http; 8 | import play.mvc.Result; 9 | 10 | import java.util.concurrent.CompletionStage; 11 | 12 | public class OtpController extends BaseController { 13 | 14 | public CompletionStage generateOTP(Http.Request httpRequest) { 15 | return handleRequest( 16 | ActorOperations.GENERATE_OTP.getValue(), 17 | httpRequest.body().asJson(), 18 | (request) -> { 19 | new OtpRequestValidator().validateGenerateOtpRequest((Request) request); 20 | return null; 21 | }, 22 | getAllRequestHeaders(httpRequest), 23 | httpRequest); 24 | } 25 | 26 | public CompletionStage verifyOTP(Http.Request httpRequest) { 27 | return handleRequest( 28 | ActorOperations.VERIFY_OTP.getValue(), 29 | httpRequest.body().asJson(), 30 | (request) -> { 31 | new OtpRequestValidator().validateVerifyOtpRequest((Request) request); 32 | return null; 33 | }, 34 | getAllRequestHeaders(httpRequest), 35 | httpRequest); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/bulkupload/model/StorageDetails.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.bulkupload.model; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | 6 | public class StorageDetails { 7 | 8 | private String storageType; 9 | private String container; 10 | private String fileName; 11 | 12 | public StorageDetails(String storageType, String container, String fileName) { 13 | super(); 14 | this.storageType = storageType; 15 | this.container = container; 16 | this.fileName = fileName; 17 | } 18 | 19 | public StorageDetails() {} 20 | 21 | public String getStorageType() { 22 | return storageType; 23 | } 24 | 25 | public void setStorageType(String storageType) { 26 | this.storageType = storageType; 27 | } 28 | 29 | public String getContainer() { 30 | return container; 31 | } 32 | 33 | public void setContainer(String container) { 34 | this.container = container; 35 | } 36 | 37 | public String getFileName() { 38 | return fileName; 39 | } 40 | 41 | public void setFileName(String fileName) { 42 | this.fileName = fileName; 43 | } 44 | 45 | public String toJsonString() throws JsonProcessingException { 46 | return new ObjectMapper().writeValueAsString(this); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/models/FormUtil/FormUtilRequest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.FormUtil; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import java.io.Serializable; 5 | 6 | public class FormUtilRequest implements Serializable { 7 | 8 | private static final long serialVersionUID = 351766241059464964L; 9 | 10 | @JsonProperty("type") 11 | private String type; 12 | 13 | @JsonProperty("subType") 14 | private String subType; 15 | 16 | @JsonProperty("action") 17 | private String action; 18 | 19 | @JsonProperty("component") 20 | private String component; 21 | 22 | /** No args constructor for use in serialization */ 23 | public FormUtilRequest() {} 24 | 25 | public String getType() { 26 | return type; 27 | } 28 | 29 | public String getSubType() { 30 | return subType; 31 | } 32 | 33 | public String getAction() { 34 | return action; 35 | } 36 | 37 | public String getComponent() { 38 | return component; 39 | } 40 | 41 | public void setType(String type) { 42 | this.type = type; 43 | } 44 | 45 | public void setSubType(String subType) { 46 | this.subType = subType; 47 | } 48 | 49 | public void setAction(String action) { 50 | this.action = action; 51 | } 52 | 53 | public void setComponent(String component) { 54 | this.component = component; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /service/app/controllers/tac/validator/UserTnCRequestValidator.java: -------------------------------------------------------------------------------- 1 | package controllers.tac.validator; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.sunbird.common.exception.ProjectCommonException; 5 | import org.sunbird.common.models.util.JsonKey; 6 | import org.sunbird.common.models.util.ProjectUtil; 7 | import org.sunbird.common.request.BaseRequestValidator; 8 | import org.sunbird.common.request.Request; 9 | import org.sunbird.common.responsecode.ResponseCode; 10 | 11 | import java.text.MessageFormat; 12 | 13 | public class UserTnCRequestValidator extends BaseRequestValidator { 14 | 15 | public void validateTnCRequest(Request request) { 16 | validateParam( 17 | (String) request.get(JsonKey.VERSION), 18 | ResponseCode.mandatoryParamsMissing, 19 | JsonKey.VERSION); 20 | 21 | //if managedUserId's terms and conditions are accepted, validate userId from request 22 | String managedUserId = (String) request.getRequest().get(JsonKey.USER_ID); 23 | if (StringUtils.isNotBlank(managedUserId) && !ProjectUtil.validateUUID(managedUserId)){ 24 | throw new ProjectCommonException( 25 | ResponseCode.invalidPropertyError.getErrorCode(), 26 | MessageFormat.format(ResponseCode.invalidPropertyError.getErrorMessage(), JsonKey.USER_ID), 27 | ResponseCode.CLIENT_ERROR.getResponseCode()); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/systemsettings/src/main/java/org/sunbird/systemsettings/dao/SystemSettingDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.systemsettings.dao; 2 | 3 | import java.util.List; 4 | import org.sunbird.common.models.response.Response; 5 | import org.sunbird.common.request.RequestContext; 6 | import org.sunbird.models.systemsetting.SystemSetting; 7 | 8 | public interface SystemSettingDao { 9 | /** 10 | * Update system setting. 11 | * 12 | * @param systemSetting Setting information 13 | * @param context 14 | * @return Response containing setting identifier. 15 | */ 16 | Response write(SystemSetting systemSetting, RequestContext context); 17 | 18 | /** 19 | * Read system setting for given identifier. 20 | * 21 | * @param id System setting identifier 22 | * @param context 23 | * @return System setting information 24 | */ 25 | SystemSetting readById(String id, RequestContext context); 26 | 27 | /** 28 | * Read system setting for given field name. 29 | * 30 | * @param field System setting field name 31 | * @param context 32 | * @return System setting information 33 | */ 34 | SystemSetting readByField(String field, RequestContext context); 35 | 36 | /** 37 | * Read all system settings. 38 | * 39 | * @return Response containing list of system settings. 40 | * @param context 41 | */ 42 | List readAll(RequestContext context); 43 | } 44 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/bean/SelfDeclaredUser.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.bean; 2 | 3 | public class SelfDeclaredUser extends MigrationUser { 4 | private String schoolName; 5 | private String subOrgExternalId; 6 | private String userId; 7 | private String orgId; 8 | private String persona; 9 | private String errorType; 10 | 11 | public String getSubOrgExternalId() { 12 | return subOrgExternalId; 13 | } 14 | 15 | public void setSubOrgExternalId(String subOrgExternalId) { 16 | this.subOrgExternalId = subOrgExternalId; 17 | } 18 | 19 | public String getSchoolName() { 20 | return schoolName; 21 | } 22 | 23 | public void setSchoolName(String schoolName) { 24 | this.schoolName = schoolName; 25 | } 26 | 27 | public String getUserId() { 28 | return userId; 29 | } 30 | 31 | public void setUserId(String userId) { 32 | this.userId = userId; 33 | } 34 | 35 | public String getOrgId() { 36 | return orgId; 37 | } 38 | 39 | public void setOrgId(String orgId) { 40 | this.orgId = orgId; 41 | } 42 | 43 | public String getPersona() { 44 | return persona; 45 | } 46 | 47 | public void setPersona(String persona) { 48 | this.persona = persona; 49 | } 50 | 51 | public String getErrorType() { 52 | return errorType; 53 | } 54 | 55 | public void setErrorType(String errorType) { 56 | this.errorType = errorType; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/url/action/service/UrlActionService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.url.action.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | import org.apache.commons.collections4.CollectionUtils; 8 | import org.sunbird.common.models.util.JsonKey; 9 | import org.sunbird.learner.actors.url.action.dao.UrlActionDao; 10 | import org.sunbird.learner.actors.url.action.dao.impl.UrlActionDaoImpl; 11 | import org.sunbird.models.url.action.UrlAction; 12 | 13 | public class UrlActionService { 14 | 15 | private static UrlActionDao urlActionDao = UrlActionDaoImpl.getInstance(); 16 | 17 | public static Map getUrlActionMap(String urlId) { 18 | Map response = new HashMap<>(); 19 | List urlActionList = urlActionDao.getUrlActions(); 20 | 21 | if (CollectionUtils.isNotEmpty(urlActionList)) { 22 | for (UrlAction urlAction : urlActionList) { 23 | if (urlAction.getId().equals(urlId)) { 24 | response.put(JsonKey.ID, urlAction.getId()); 25 | response.put(JsonKey.NAME, urlAction.getName()); 26 | response.put( 27 | JsonKey.URL, urlAction.getUrl() != null ? urlAction.getUrl() : new ArrayList<>()); 28 | return response; 29 | } 30 | } 31 | } 32 | 33 | return response; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/main/java/org/sunbird/notification/utils/JsonUtil.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.notification.utils; 2 | 3 | import com.fasterxml.jackson.databind.JsonNode; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import java.io.IOException; 6 | import org.jboss.logging.Logger; 7 | 8 | public class JsonUtil { 9 | private static Logger logger = Logger.getLogger(JsonUtil.class); 10 | 11 | public static String toJson(Object object) { 12 | ObjectMapper mapper = new ObjectMapper(); 13 | try { 14 | return mapper.writeValueAsString(object); 15 | } catch (Exception e) { 16 | // ProjectLogger.log("JsonUtil:getJsonString error occured : " + e, LoggerEnum.INFO); 17 | } 18 | return null; 19 | } 20 | 21 | public static boolean isStringNullOREmpty(String value) { 22 | if (value == null || "".equals(value.trim())) { 23 | return true; 24 | } 25 | return false; 26 | } 27 | 28 | public static T getAsObject(String res, Class clazz) { 29 | ObjectMapper mapper = new ObjectMapper(); 30 | 31 | T result = null; 32 | try { 33 | JsonNode node = mapper.readTree(res); 34 | result = mapper.convertValue(node, clazz); 35 | } catch (IOException e) { 36 | // ProjectLogger.log("JsonUtil:getAsObject error occured : " + e, LoggerEnum.INFO); 37 | e.printStackTrace(); 38 | } 39 | return result; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /service/app/controllers/usermanagement/UserRoleController.java: -------------------------------------------------------------------------------- 1 | package controllers.usermanagement; 2 | 3 | import controllers.BaseController; 4 | import controllers.usermanagement.validator.UserRoleRequestValidator; 5 | import java.util.concurrent.CompletionStage; 6 | import org.sunbird.common.models.util.ActorOperations; 7 | import org.sunbird.common.models.util.JsonKey; 8 | import org.sunbird.common.request.Request; 9 | import play.mvc.Http; 10 | import play.mvc.Result; 11 | import util.Attrs; 12 | import util.Common; 13 | 14 | public class UserRoleController extends BaseController { 15 | 16 | public CompletionStage getRoles(Http.Request httpRequest) { 17 | return handleRequest(ActorOperations.GET_ROLES.getValue(), httpRequest); 18 | } 19 | 20 | public CompletionStage assignRoles(Http.Request httpRequest) { 21 | final boolean isPrivate = httpRequest.path().contains(JsonKey.PRIVATE) ? true : false; 22 | 23 | return handleRequest( 24 | ActorOperations.ASSIGN_ROLES.getValue(), 25 | httpRequest.body().asJson(), 26 | (request) -> { 27 | Request req = (Request) request; 28 | req.getContext().put(JsonKey.USER_ID, Common.getFromRequest(httpRequest, Attrs.USER_ID)); 29 | req.getContext().put(JsonKey.PRIVATE, isPrivate); 30 | new UserRoleRequestValidator().validateAssignRolesRequest(req); 31 | return null; 32 | }, 33 | httpRequest); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/datasecurity/OneWayHashing.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.common.models.util.datasecurity; 3 | 4 | import java.nio.charset.StandardCharsets; 5 | import java.security.MessageDigest; 6 | import org.sunbird.common.models.util.LoggerUtil; 7 | 8 | /** 9 | * This class will do one way data hashing. 10 | * 11 | * @author Manzarul 12 | */ 13 | public class OneWayHashing { 14 | 15 | public static LoggerUtil logger = new LoggerUtil(OneWayHashing.class); 16 | 17 | private OneWayHashing() {} 18 | 19 | /** 20 | * This method will encrypt value using SHA-256 . it is one way encryption. 21 | * 22 | * @param val String 23 | * @return String encrypted value or empty in case of exception 24 | */ 25 | public static String encryptVal(String val) { 26 | try { 27 | MessageDigest md = MessageDigest.getInstance("SHA-256"); 28 | md.update(val.getBytes(StandardCharsets.UTF_8)); 29 | byte byteData[] = md.digest(); 30 | // convert the byte to hex format method 1 31 | StringBuilder sb = new StringBuilder(); 32 | for (int i = 0; i < byteData.length; i++) { 33 | sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1)); 34 | } 35 | return sb.toString(); 36 | } catch (Exception e) { 37 | logger.error("Error while encrypting", e); 38 | } 39 | return ""; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/Target.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import java.util.Map; 6 | 7 | @JsonInclude(Include.NON_NULL) 8 | public class Target { 9 | 10 | private String id; 11 | private String type; 12 | private String ver; 13 | private Map rollup; 14 | 15 | public Target() {} 16 | 17 | public Target(String id, String type) { 18 | super(); 19 | this.id = id; 20 | this.type = type; 21 | } 22 | 23 | public Map getRollup() { 24 | return rollup; 25 | } 26 | 27 | public void setRollup(Map rollup) { 28 | this.rollup = rollup; 29 | } 30 | 31 | /** @return the id */ 32 | public String getId() { 33 | return id; 34 | } 35 | 36 | /** @param id the id to set */ 37 | public void setId(String id) { 38 | this.id = id; 39 | } 40 | 41 | /** @return the type */ 42 | public String getType() { 43 | return type; 44 | } 45 | 46 | /** @param type the type to set */ 47 | public void setType(String type) { 48 | this.type = type; 49 | } 50 | 51 | /** @return the ver */ 52 | public String getVer() { 53 | return ver; 54 | } 55 | 56 | /** @param ver the ver to set */ 57 | public void setVer(String ver) { 58 | this.ver = ver; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/main/java/org/sunbird/notification/utils/SMSFactory.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.notification.utils; 3 | 4 | import org.sunbird.common.models.util.ProjectUtil; 5 | import org.sunbird.notification.sms.provider.ISmsProvider; 6 | import org.sunbird.notification.sms.provider.ISmsProviderFactory; 7 | import org.sunbird.notification.sms.providerimpl.Msg91SmsProviderFactory; 8 | import org.sunbird.notification.sms.providerimpl.NICGatewaySmsProviderFactory; 9 | 10 | /** 11 | * This class will provide object of factory. 12 | * 13 | * @author Manzarul 14 | */ 15 | public class SMSFactory { 16 | 17 | public static final String defaultProvider = ProjectUtil.getConfigValue("sms_gateway_provider"); 18 | 19 | /** 20 | * This method will provide SMS Provide object to trigger the SMS it will by default return 21 | * Msg91SmsProvider class instance 22 | * 23 | * @return ISmsProvider 24 | */ 25 | public static ISmsProvider getInstance() { 26 | if ("91SMS".equalsIgnoreCase(defaultProvider)) { 27 | ISmsProviderFactory factory = new Msg91SmsProviderFactory(); 28 | return factory.create(); 29 | } else if ("NIC".equalsIgnoreCase(defaultProvider)) { 30 | ISmsProviderFactory factory = new NICGatewaySmsProviderFactory(); 31 | return factory.create(); 32 | } else { 33 | ISmsProviderFactory factory = new Msg91SmsProviderFactory(); 34 | return factory.create(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/user/src/test/java/org/sunbird/user/UserLoginActorTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.user; 2 | 3 | import static akka.testkit.JavaTestKit.duration; 4 | 5 | import akka.actor.ActorRef; 6 | import akka.actor.ActorSystem; 7 | import akka.actor.Props; 8 | import akka.testkit.javadsl.TestKit; 9 | import org.junit.Assert; 10 | import org.junit.Test; 11 | import org.sunbird.common.models.response.Response; 12 | import org.sunbird.common.models.util.ActorOperations; 13 | import org.sunbird.common.models.util.JsonKey; 14 | import org.sunbird.common.request.Request; 15 | import org.sunbird.common.responsecode.ResponseCode; 16 | import org.sunbird.user.actors.UserLoginActor; 17 | 18 | public class UserLoginActorTest { 19 | 20 | private static final Props props = Props.create(UserLoginActor.class); 21 | private static ActorSystem system = ActorSystem.create("system"); 22 | private String userId = "someUserId"; 23 | private TestKit probe = new TestKit(system); 24 | private ActorRef subject = system.actorOf(props); 25 | 26 | @Test 27 | public void testUpdateUserLoginTimeSuccess() { 28 | Request request = new Request(); 29 | 30 | request.setOperation(ActorOperations.USER_CURRENT_LOGIN.getValue()); 31 | request.put(JsonKey.USER_ID, userId); 32 | 33 | subject.tell(request, probe.getRef()); 34 | 35 | Response response = probe.expectMsgClass(duration("10 second"), Response.class); 36 | Assert.assertTrue(null != response && response.getResponseCode() == ResponseCode.OK); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/util/UserFlagUtil.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import org.sunbird.common.models.util.JsonKey; 6 | 7 | public class UserFlagUtil { 8 | 9 | /** 10 | * This method return int value of the boolean flag 11 | * 12 | * @param userFlagType 13 | * @param flagEnabled 14 | * @return 15 | */ 16 | public static int getFlagValue(String userFlagType, boolean flagEnabled) { 17 | int decimalValue = 0; 18 | if (userFlagType.equals(UserFlagEnum.STATE_VALIDATED.getUserFlagType()) && flagEnabled) { 19 | // if user is state-validated flag should be true then only return flagvalue 20 | decimalValue = UserFlagEnum.STATE_VALIDATED.getUserFlagValue(); 21 | } 22 | return decimalValue; 23 | } 24 | 25 | /** 26 | * This method returns boolean flags of user for the flagValue 27 | * 28 | * @param flagsValue 29 | * @return 30 | */ 31 | public static Map assignUserFlagValues(int flagsValue) { 32 | Map userFlagMap = new HashMap<>(); 33 | setDefaultValues(userFlagMap); 34 | if ((flagsValue >= UserFlagEnum.STATE_VALIDATED.getUserFlagValue())) { 35 | userFlagMap.put(UserFlagEnum.STATE_VALIDATED.getUserFlagType(), true); 36 | } 37 | return userFlagMap; 38 | } 39 | 40 | private static void setDefaultValues(Map userFlagMap) { 41 | userFlagMap.put(JsonKey.STATE_VALIDATED, false); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/role/group/service/RoleGroupService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.role.group.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | import org.apache.commons.collections.CollectionUtils; 8 | import org.sunbird.common.models.util.JsonKey; 9 | import org.sunbird.learner.actors.role.group.dao.RoleGroupDao; 10 | import org.sunbird.learner.actors.role.group.dao.impl.RoleGroupDaoImpl; 11 | import org.sunbird.models.role.group.RoleGroup; 12 | 13 | public class RoleGroupService { 14 | 15 | private static RoleGroupDao roleGroupDao = RoleGroupDaoImpl.getInstance(); 16 | 17 | public static Map getRoleGroupMap(String roleName) { 18 | Map response = new HashMap<>(); 19 | List roleGroupList = roleGroupDao.getRoleGroups(); 20 | 21 | if (CollectionUtils.isNotEmpty(roleGroupList)) { 22 | for (RoleGroup roleGroup : roleGroupList) { 23 | if (roleGroup.getId().equals(roleName)) { 24 | response.put(JsonKey.ID, roleGroup.getId()); 25 | response.put(JsonKey.NAME, roleGroup.getName()); 26 | response.put( 27 | JsonKey.URL_ACTION_ID, 28 | roleGroup.getUrlActionIds() != null 29 | ? roleGroup.getUrlActionIds() 30 | : new ArrayList<>()); 31 | return response; 32 | } 33 | } 34 | } 35 | 36 | return response; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-notification/src/main/java/org/sunbird/notification/sms/providerimpl/ProviderDetails.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.notification.sms.providerimpl; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import org.sunbird.notification.sms.Sms; 6 | 7 | /** @author Manzarul */ 8 | public class ProviderDetails implements Serializable { 9 | /** */ 10 | private static final long serialVersionUID = 6602089097922616775L; 11 | 12 | private String sender; 13 | private String route; 14 | private String country; 15 | private int unicode; 16 | private List sms; 17 | 18 | public ProviderDetails(String sender, String route, String country, int unicode, List sms) { 19 | this.sender = sender; 20 | this.route = route; 21 | this.country = country; 22 | this.sms = sms; 23 | this.unicode = unicode; 24 | } 25 | 26 | /** @return the serialversionuid */ 27 | public static long getSerialversionuid() { 28 | return serialVersionUID; 29 | } 30 | 31 | /** @return the sender */ 32 | public String getSender() { 33 | return sender; 34 | } 35 | 36 | /** @return the route */ 37 | public String getRoute() { 38 | return route; 39 | } 40 | 41 | /** @return the country */ 42 | public String getCountry() { 43 | return country; 44 | } 45 | 46 | /** @return the sms */ 47 | public List getSms() { 48 | return sms; 49 | } 50 | 51 | /** @return the unicode */ 52 | public int getUnicode() { 53 | return unicode; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/test/java/org/sunbird/common/request/RequestTest.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.common.request; 3 | 4 | import java.util.HashMap; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | /** @author Manzarul */ 9 | public class RequestTest { 10 | 11 | @Test 12 | public void testRequestBeanWithDefaultConstructor() { 13 | Request request = new Request(); 14 | request.setEnv(1); 15 | long val = System.currentTimeMillis(); 16 | request.setId(val + ""); 17 | request.setManagerName("name"); 18 | request.setOperation("operation name"); 19 | request.setRequestId("unique req id"); 20 | request.setTs(val + ""); 21 | request.setVer("v1"); 22 | request.setContext(new HashMap<>()); 23 | request.setRequest(new HashMap<>()); 24 | request.setParams(new RequestParams()); 25 | Assert.assertEquals(request.getEnv(), 1); 26 | Assert.assertEquals(request.getId(), val + ""); 27 | Assert.assertEquals(request.getManagerName(), "name"); 28 | Assert.assertEquals(request.getOperation(), "operation name"); 29 | Assert.assertEquals(request.getRequestId(), "unique req id"); 30 | Assert.assertEquals(request.getTs(), val + ""); 31 | Assert.assertEquals(request.getVer(), "v1"); 32 | Assert.assertEquals(request.getContext().size(), 0); 33 | Assert.assertEquals(request.getRequest().size(), 0); 34 | Assert.assertNotNull(request.getParams()); 35 | Assert.assertNotNull(request.toString()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /service/test/controllers/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package controllers; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import modules.OnRequestHandler; 6 | import org.junit.Test; 7 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 8 | import org.powermock.core.classloader.annotations.PrepareForTest; 9 | import org.sunbird.actor.service.SunbirdMWService; 10 | import org.sunbird.common.responsecode.ResponseCode; 11 | import play.mvc.Result; 12 | 13 | /** 14 | * Simple (JUnit) tests that can call all parts of a play app. If you are interested in mocking a 15 | * whole application, see the wiki for more details. extends WithApplication 16 | */ 17 | @PrepareForTest({SunbirdMWService.class, OnRequestHandler.class}) 18 | @PowerMockIgnore({"javax.management.*", "jdk.internal.reflect.*"}) 19 | public class ApplicationTest { 20 | 21 | @Test 22 | public void testGetApiVersionSuccess() { 23 | String apiPath = "/v1/learner/getenrolledcoures"; 24 | String version = BaseController.getApiVersion(apiPath); 25 | assertEquals("v1", version); 26 | } 27 | 28 | @Test(expected = RuntimeException.class) 29 | public void testCreateCommonExceptionResponseSuccess() { 30 | ResponseCode code = ResponseCode.getResponse(ResponseCode.authTokenRequired.getErrorCode()); 31 | code.setResponseCode(ResponseCode.CLIENT_ERROR.getResponseCode()); 32 | Result result = new BaseController().createCommonExceptionResponse(new Exception(), null); 33 | assertEquals(ResponseCode.OK.getResponseCode(), result.status()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/feed/IFeedService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.feed; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.sunbird.common.models.response.Response; 6 | import org.sunbird.common.request.RequestContext; 7 | import org.sunbird.models.user.Feed; 8 | 9 | /** @author anmolgupta this is an interface class for the user feeds */ 10 | public interface IFeedService { 11 | 12 | /** 13 | * this method will be responsible to insert the feed in the user_feed table and sync the data 14 | * with the ES 15 | * 16 | * @param feed 17 | * @param context 18 | * @return response 19 | */ 20 | Response insert(Feed feed, RequestContext context); 21 | 22 | /** 23 | * this method will be responsible to update the feed in the user_feed table and sync the data 24 | * with the ES 25 | * 26 | * @param feed 27 | * @param context 28 | * @return response 29 | */ 30 | Response update(Feed feed, RequestContext context); 31 | 32 | /** 33 | * this method will be responsible to get the records by userId from the user_feed table 34 | * 35 | * @param properties 36 | * @param context 37 | * @return List 38 | */ 39 | List getFeedsByProperties(Map properties, RequestContext context); 40 | 41 | /** 42 | * this method will be holding responsibility to delete the feed from DB and ES. 43 | * 44 | * @param id 45 | * @param context 46 | */ 47 | void delete(String id, String userId, String action, RequestContext context); 48 | } 49 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/auth-verifier/src/test/java/org/sunbird/auth/verifier/KeyManagerTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.auth.verifier; 2 | 3 | import static org.junit.Assert.assertNotNull; 4 | import static org.junit.Assert.assertNull; 5 | 6 | import java.security.PublicKey; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 10 | import org.powermock.core.classloader.annotations.PrepareForTest; 11 | import org.powermock.modules.junit4.PowerMockRunner; 12 | import org.sunbird.common.models.util.PropertiesCache; 13 | 14 | @RunWith(PowerMockRunner.class) 15 | @PrepareForTest({PropertiesCache.class}) 16 | @PowerMockIgnore({ 17 | "javax.management.*", 18 | "javax.net.ssl.*", 19 | "javax.security.*", 20 | "jdk.internal.reflect.*" 21 | }) 22 | public class KeyManagerTest { 23 | 24 | @Test 25 | public void testLoadPublicKey() throws Exception { 26 | PublicKey key = 27 | KeyManager.loadPublicKey( 28 | "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAysH/wWtg0IjBL1JZZDYvUJC42JCxVobalckr2/3d3eEiWkk7Zh/4DAPYOs4UPjAevTs5VMUjq9EZu/u4H5hNzoVmYNvhtxbhWNY3n4mxpA4Lgt4sNGiGYNNGrN34ML+7+TR3Z1dlrhA271PiuanHI11YymskQRPhBfuwK923Kl/lgI4rS9OQ4GnkvwkUPvMUIRfNt8wL9uTbWm3V9p8VTcmQbW+pPw9QhO9v95NOgXQrLnT8xwnzQE6UCTY2al3B0fc3ULmcxvK+7P1R3/0w1qJLEKSiHl0xnv4WNEfS+2UmN+8jfdSCfoyVIglQl5/tb05j89nfZZp8k24AWLxIJQIDAQAB"); 29 | assertNotNull(key); 30 | } 31 | 32 | @Test 33 | public void testGetPublicKey() { 34 | KeyData key = KeyManager.getPublicKey("keyId"); 35 | assertNull(key); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/src/main/java/org/sunbird/helper/ElasticSearchMapping.java: -------------------------------------------------------------------------------- 1 | /** */ 2 | package org.sunbird.helper; 3 | 4 | /** 5 | * This class will define Elastic search mapping. 6 | * 7 | * @author Manzarul 8 | */ 9 | public class ElasticSearchMapping { 10 | 11 | /** 12 | * This method will define ES default mapping. 13 | * 14 | * @return 15 | */ 16 | public static String createMapping() { 17 | String mapping = 18 | " { \"dynamic_templates\": [ {\"longs\": {\"match_mapping_type\": \"long\", \"mapping\": {\"type\": \"long\", \"fields\": { \"raw\": {\"type\": \"long\" } }}}},{\"booleans\": {\"match_mapping_type\": \"boolean\", \"mapping\": {\"type\": \"boolean\", \"fields\": { \"raw\": { \"type\": \"boolean\" }} }}},{\"doubles\": {\"match_mapping_type\": \"double\",\"mapping\": {\"type\": \"double\",\"fields\":{\"raw\": { \"type\": \"double\" } }}}},{ \"dates\": {\"match_mapping_type\": \"date\", \"mapping\": { \"type\": \"date\",\"fields\": {\"raw\": { \"type\": \"date\" } } }}},{\"strings\": {\"match_mapping_type\": \"string\",\"mapping\": {\"type\": \"text\",\"fielddata\": true,\"copy_to\": \"all_fields\",\"analyzer\": \"cs_index_analyzer\",\"search_analyzer\": \"cs_search_analyzer\",\"fields\": {\"raw\": {\"type\": \"text\",\"fielddata\": true,\"analyzer\": \"keylower\"}}}}}],\"properties\": {\"all_fields\": {\"type\": \"text\",\"analyzer\": \"cs_index_analyzer\",\"search_analyzer\": \"cs_search_analyzer\",\"fields\": { \"raw\": { \"type\": \"text\",\"analyzer\": \"keylower\" } }} }}"; 19 | return mapping; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-util/src/main/java/org/sunbird/models/location/Location.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.location; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @desc POJO class for Location 10 | * @author Amit Kumar 11 | */ 12 | @JsonIgnoreProperties(ignoreUnknown = true) 13 | @JsonInclude(Include.NON_NULL) 14 | public class Location implements Serializable { 15 | 16 | private static final long serialVersionUID = -7967252522327069670L; 17 | 18 | private String id; 19 | private String code; 20 | private String name; 21 | private String type; 22 | private String parentId; 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public String getCode() { 33 | return code; 34 | } 35 | 36 | public void setCode(String code) { 37 | this.code = code; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public String getType() { 49 | return type; 50 | } 51 | 52 | public void setType(String type) { 53 | this.type = type; 54 | } 55 | 56 | public String getParentId() { 57 | return parentId; 58 | } 59 | 60 | public void setParentId(String parentId) { 61 | this.parentId = parentId; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /service/app/controllers/tenantmigration/TenantMigrationController.java: -------------------------------------------------------------------------------- 1 | package controllers.tenantmigration; 2 | 3 | import controllers.BaseController; 4 | import controllers.usermanagement.validator.ShadowUserMigrateReqValidator; 5 | import java.util.concurrent.CompletionStage; 6 | import org.sunbird.common.models.util.ActorOperations; 7 | import org.sunbird.common.request.Request; 8 | import play.mvc.Http; 9 | import play.mvc.Result; 10 | import util.Attrs; 11 | import util.Common; 12 | 13 | /** @author anmolgupta */ 14 | public class TenantMigrationController extends BaseController { 15 | 16 | /** 17 | * Method to migrate user from one tenant to another. 18 | * 19 | * @return Result 20 | */ 21 | public CompletionStage userTenantMigrate(Http.Request httpRequest) { 22 | return handleRequest( 23 | ActorOperations.USER_TENANT_MIGRATE.getValue(), 24 | httpRequest.body().asJson(), 25 | null, 26 | null, 27 | null, 28 | true, 29 | httpRequest); 30 | } 31 | 32 | public CompletionStage shadowUserMigrate(Http.Request httpRequest) { 33 | String callerId = Common.getFromRequest(httpRequest, Attrs.USER_ID); 34 | return handleRequest( 35 | ActorOperations.MIGRATE_USER.getValue(), 36 | request().body().asJson(), 37 | req -> { 38 | Request request = (Request) req; 39 | ShadowUserMigrateReqValidator.getInstance(request, callerId).validate(); 40 | return null; 41 | }, 42 | null, 43 | null, 44 | true, 45 | httpRequest); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-util/src/main/java/org/sunbird/actorutil/systemsettings/SystemSettingClient.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.actorutil.systemsettings; 2 | 3 | import akka.actor.ActorRef; 4 | import com.fasterxml.jackson.core.type.TypeReference; 5 | import org.sunbird.common.request.RequestContext; 6 | import org.sunbird.models.systemsetting.SystemSetting; 7 | 8 | /** 9 | * This interface defines methods supported by System Setting service. 10 | * 11 | * @author Amit Kumar 12 | */ 13 | public interface SystemSettingClient { 14 | 15 | /** 16 | * Get system setting information for given field (setting) name. 17 | * 18 | * @param actorRef Actor reference 19 | * @param field System setting field name 20 | * @param context 21 | * @return System setting details 22 | */ 23 | SystemSetting getSystemSettingByField(ActorRef actorRef, String field, RequestContext context); 24 | 25 | /** 26 | * Get system setting information for given field (setting) and key name. 27 | * 28 | * @param actorRef Actor reference 29 | * @param field System setting field name 30 | * @param key Key (e.g. csv.mandatoryColumns) within system setting information 31 | * @param typeReference Type reference for value corresponding to specified key 32 | * @param context 33 | * @return System setting value corresponding to given field and key name 34 | */ 35 | T getSystemSettingByFieldAndKey( 36 | ActorRef actorRef, 37 | String field, 38 | String key, 39 | TypeReference typeReference, 40 | RequestContext context); 41 | } 42 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-cassandra-utils/src/test/java/org/sunbird/cassandra/CassandraTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | package org.sunbird.cassandra; 3 | 4 | import static org.junit.Assert.assertEquals; 5 | 6 | import org.junit.AfterClass; 7 | import org.junit.FixMethodOrder; 8 | import org.junit.Ignore; 9 | import org.junit.Test; 10 | import org.junit.runners.MethodSorters; 11 | import org.sunbird.common.models.util.JsonKey; 12 | import org.sunbird.common.models.util.PropertiesCache; 13 | import org.sunbird.helper.CassandraConnectionManagerImpl; 14 | import org.sunbird.helper.CassandraConnectionMngrFactory; 15 | 16 | @Ignore 17 | @FixMethodOrder(MethodSorters.NAME_ASCENDING) 18 | public class CassandraTest { 19 | 20 | private static PropertiesCache cach = PropertiesCache.getInstance(); 21 | private static String host = cach.getProperty("contactPoint"); 22 | private static String port = cach.getProperty("port"); 23 | private static CassandraConnectionManagerImpl connectionManager = 24 | (CassandraConnectionManagerImpl) CassandraConnectionMngrFactory.getObject(JsonKey.EMBEDDED); 25 | 26 | @Test 27 | public void testConnection() { 28 | boolean bool = connectionManager.createConnection(host, port, "", "", "sunbird1"); 29 | assertEquals(true, bool); 30 | } 31 | 32 | @Test 33 | public void testConnectionB() { 34 | boolean bool = connectionManager.createConnection(host, port, "", "", "sunbird12"); 35 | assertEquals(true, bool); 36 | } 37 | 38 | @AfterClass 39 | public static void shutdownhook() { 40 | connectionManager.registerShutDownHook(); 41 | } 42 | } 43 | */ 44 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/location/src/main/java/org/sunbird/location/dao/LocationDao.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.location.dao; 2 | 3 | import java.util.Map; 4 | import org.sunbird.common.models.response.Response; 5 | import org.sunbird.common.request.RequestContext; 6 | import org.sunbird.models.location.Location; 7 | 8 | /** @author Amit Kumar */ 9 | public interface LocationDao { 10 | /** 11 | * @param location Location Details 12 | * @param context 13 | * @return response Response 14 | */ 15 | Response create(Location location, RequestContext context); 16 | 17 | /** 18 | * @param location Location Details 19 | * @param context 20 | * @return response Response 21 | */ 22 | Response update(Location location, RequestContext context); 23 | 24 | /** 25 | * @param locationId its a unique identity for Location 26 | * @param context 27 | * @return response Response 28 | */ 29 | Response delete(String locationId, RequestContext context); 30 | 31 | /** 32 | * @param searchQueryMap Map it contains the filters to search Location from ES 33 | * @param context 34 | * @return response Response 35 | */ 36 | Response search(Map searchQueryMap, RequestContext context); 37 | 38 | /** 39 | * @param locationId 40 | * @param context 41 | * @return response Response 42 | */ 43 | Response read(String locationId, RequestContext context); 44 | 45 | /** 46 | * @param queryMap 47 | * @param context 48 | * @return response Response 49 | */ 50 | Response getRecordByProperty(Map queryMap, RequestContext context); 51 | } 52 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/request/orgvalidator/BaseOrgRequestValidator.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.request.orgvalidator; 2 | 3 | import java.text.MessageFormat; 4 | import org.apache.commons.lang3.StringUtils; 5 | import org.sunbird.common.exception.ProjectCommonException; 6 | import org.sunbird.common.models.util.JsonKey; 7 | import org.sunbird.common.request.BaseRequestValidator; 8 | import org.sunbird.common.request.Request; 9 | import org.sunbird.common.responsecode.ResponseCode; 10 | 11 | public class BaseOrgRequestValidator extends BaseRequestValidator { 12 | 13 | public static final int ERROR_CODE = ResponseCode.CLIENT_ERROR.getResponseCode(); 14 | 15 | public void validateOrgReference(Request request) { 16 | validateParam( 17 | (String) request.getRequest().get(JsonKey.ORGANISATION_ID), 18 | ResponseCode.mandatoryParamsMissing, 19 | JsonKey.ORGANISATION_ID); 20 | } 21 | 22 | public void validateTenantOrgChannel(Request request) { 23 | if ((null != request.getRequest().get(JsonKey.IS_TENANT) 24 | && (Boolean) request.getRequest().get(JsonKey.IS_TENANT)) 25 | && StringUtils.isEmpty((String) request.getRequest().get(JsonKey.CHANNEL))) { 26 | throw new ProjectCommonException( 27 | ResponseCode.dependentParameterMissing.getErrorCode(), 28 | MessageFormat.format( 29 | ResponseCode.dependentParameterMissing.getErrorMessage(), 30 | JsonKey.CHANNEL, 31 | JsonKey.IS_TENANT), 32 | ERROR_CODE); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/models/adminutil/AdminUtilRequestData.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.models.adminutil; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import org.apache.commons.lang.builder.ToStringBuilder; 5 | 6 | import java.io.Serializable; 7 | 8 | public class AdminUtilRequestData implements Serializable 9 | { 10 | 11 | @JsonProperty("parentId") 12 | private String parentId; 13 | @JsonProperty("sub") 14 | private String sub; 15 | private final static long serialVersionUID = 351766241059464964L; 16 | 17 | /** 18 | * No args constructor for use in serialization 19 | * 20 | */ 21 | public AdminUtilRequestData() { 22 | } 23 | 24 | /** 25 | * 26 | * @param sub 27 | * @param parentId 28 | */ 29 | public AdminUtilRequestData(String parentId, String sub) { 30 | super(); 31 | this.parentId = parentId; 32 | this.sub = sub; 33 | } 34 | 35 | @JsonProperty("parentId") 36 | public String getParentId() { 37 | return parentId; 38 | } 39 | 40 | @JsonProperty("parentId") 41 | public void setParentId(String parentId) { 42 | this.parentId = parentId; 43 | } 44 | 45 | @JsonProperty("sub") 46 | public String getSub() { 47 | return sub; 48 | } 49 | 50 | @JsonProperty("sub") 51 | public void setSub(String sub) { 52 | this.sub = sub; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return new ToStringBuilder(this).append("parentId", parentId).append("sub", sub).toString(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/test/java/org/sunbird/learner/util/FormApiUtilTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | import org.junit.Assert; 8 | import org.junit.Test; 9 | import org.sunbird.common.models.util.JsonKey; 10 | 11 | public class FormApiUtilTest { 12 | 13 | @Test 14 | public void testGetLocationTypeConfigMap() { 15 | List locationType = FormApiUtil.getLocationTypeConfigMap(getFormApiConfig()); 16 | Assert.assertTrue(locationType.contains(JsonKey.LOCATION_TYPE_SCHOOL)); 17 | } 18 | 19 | public Map getFormApiConfig() { 20 | Map formData = new HashMap<>(); 21 | Map formMap = new HashMap<>(); 22 | Map dataMap = new HashMap<>(); 23 | List> fieldsList = new ArrayList<>(); 24 | Map field = new HashMap<>(); 25 | 26 | Map children = new HashMap<>(); 27 | List> userTypeConfigList = new ArrayList<>(); 28 | Map schoolConfig = new HashMap<>(); 29 | schoolConfig.put(JsonKey.CODE, JsonKey.LOCATION_TYPE_SCHOOL); 30 | userTypeConfigList.add(schoolConfig); 31 | children.put("teacher", userTypeConfigList); 32 | field.put(JsonKey.CODE, JsonKey.PERSONA); 33 | field.put(JsonKey.CHILDREN, children); 34 | fieldsList.add(field); 35 | dataMap.put(JsonKey.FIELDS, fieldsList); 36 | formMap.put(JsonKey.DATA, dataMap); 37 | formData.put(JsonKey.FORM, formMap); 38 | return formData; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/service/src/test/java/org/sunbird/learner/actors/OrgExternalServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | import static org.powermock.api.mockito.PowerMockito.mock; 5 | import static org.powermock.api.mockito.PowerMockito.when; 6 | 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.powermock.api.mockito.PowerMockito; 11 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 12 | import org.powermock.core.classloader.annotations.PrepareForTest; 13 | import org.powermock.modules.junit4.PowerMockRunner; 14 | import org.sunbird.cassandraimpl.CassandraOperationImpl; 15 | import org.sunbird.helper.ServiceFactory; 16 | import org.sunbird.learner.organisation.external.identity.service.OrgExternalService; 17 | 18 | @RunWith(PowerMockRunner.class) 19 | @PrepareForTest({ServiceFactory.class}) 20 | @PowerMockIgnore({ 21 | "javax.management.*", 22 | "javax.net.ssl.*", 23 | "javax.security.*", 24 | "jdk.internal.reflect.*", 25 | "javax.crypto.*" 26 | }) 27 | public class OrgExternalServiceTest { 28 | private static CassandraOperationImpl cassandraOperation; 29 | private OrgExternalService orgExternalService = new OrgExternalService(); 30 | 31 | @Before 32 | public void beforeEachTest() { 33 | PowerMockito.mockStatic(ServiceFactory.class); 34 | cassandraOperation = mock(CassandraOperationImpl.class); 35 | when(ServiceFactory.getInstance()).thenReturn(cassandraOperation); 36 | } 37 | 38 | @Test 39 | public void testCreateNoteSuccess() { 40 | 41 | assertTrue(true); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/actor-core/src/main/java/org/sunbird/actor/service/SunbirdMWService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.actor.service; 2 | 3 | import akka.actor.ActorRef; 4 | import akka.actor.ActorSelection; 5 | import org.sunbird.actor.router.BackgroundRequestRouter; 6 | import org.sunbird.actor.router.RequestRouter; 7 | import org.sunbird.common.models.util.JsonKey; 8 | import org.sunbird.common.request.Request; 9 | 10 | /** @author Mahesh Kumar Gangula */ 11 | public class SunbirdMWService extends BaseMWService { 12 | 13 | public static void init() { 14 | String host = System.getenv(JsonKey.MW_SYSTEM_HOST); 15 | String port = System.getenv(JsonKey.MW_SYSTEM_PORT); 16 | getActorSystem(host, port); 17 | initRouters(); 18 | } 19 | 20 | public static void tellToRequestRouter(Request request, ActorRef sender) { 21 | String operation = request.getOperation(); 22 | ActorRef actor = RequestRouter.getActor(operation); 23 | if (null == actor) { 24 | ActorSelection select = getRemoteRouter(RequestRouter.class.getSimpleName()); 25 | select.tell(request, sender); 26 | } else { 27 | actor.tell(request, sender); 28 | } 29 | } 30 | 31 | public static void tellToBGRouter(Request request, ActorRef sender) { 32 | String operation = request.getOperation(); 33 | ActorRef actor = BackgroundRequestRouter.getActor(operation); 34 | if (null == actor) { 35 | ActorSelection select = getRemoteRouter(BackgroundRequestRouter.class.getSimpleName()); 36 | select.tell(request, sender); 37 | } else { 38 | actor.tell(request, sender); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/error/ListErrorDispatcher.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.error; 2 | 3 | import com.mchange.v1.util.ArrayUtils; 4 | import java.util.ArrayList; 5 | import java.util.Collections; 6 | import java.util.List; 7 | import org.sunbird.common.exception.ProjectCommonException; 8 | import org.sunbird.common.responsecode.ResponseCode; 9 | 10 | /** 11 | * this class will dispatch error in list format 12 | * 13 | * @author anmolgupta 14 | */ 15 | public class ListErrorDispatcher implements IErrorDispatcher { 16 | 17 | private CsvError error; 18 | 19 | private ListErrorDispatcher(CsvError error) { 20 | this.error = error; 21 | } 22 | 23 | public static ListErrorDispatcher getInstance(CsvError error) { 24 | return new ListErrorDispatcher(error); 25 | } 26 | 27 | @Override 28 | public void dispatchError() { 29 | Collections.sort(error.getErrorsList(), new RowComparator()); 30 | List errors = new ArrayList<>(); 31 | error 32 | .getErrorsList() 33 | .stream() 34 | .forEach( 35 | errorDetails -> { 36 | errors.add( 37 | String.format( 38 | "In Row %s:the Column %s:is %s", 39 | errorDetails.getRowId() + 1, 40 | errorDetails.getHeader(), 41 | errorDetails.getErrorEnum().getValue())); 42 | }); 43 | throw new ProjectCommonException( 44 | ResponseCode.invalidRequestData.getErrorCode(), 45 | ArrayUtils.stringifyContents(errors.toArray()), 46 | ResponseCode.CLIENT_ERROR.getResponseCode()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/telemetry/dto/TelemetryBJREvent.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.telemetry.dto; 2 | 3 | import java.util.Map; 4 | 5 | public class TelemetryBJREvent { 6 | 7 | private String eid; 8 | private long ets; 9 | private String mid; 10 | private Map actor; 11 | private Map context; 12 | private Map object; 13 | private Map edata; 14 | 15 | public String getEid() { 16 | return eid; 17 | } 18 | 19 | public void setEid(String eid) { 20 | this.eid = eid; 21 | } 22 | 23 | public long getEts() { 24 | return ets; 25 | } 26 | 27 | public void setEts(long ets) { 28 | this.ets = ets; 29 | } 30 | 31 | public String getMid() { 32 | return mid; 33 | } 34 | 35 | public void setMid(String mid) { 36 | this.mid = mid; 37 | } 38 | 39 | public Map getActor() { 40 | return actor; 41 | } 42 | 43 | public void setActor(Map actor) { 44 | this.actor = actor; 45 | } 46 | 47 | public Map getContext() { 48 | return context; 49 | } 50 | 51 | public void setContext(Map context) { 52 | this.context = context; 53 | } 54 | 55 | public Map getObject() { 56 | return object; 57 | } 58 | 59 | public void setObject(Map object) { 60 | this.object = object; 61 | } 62 | 63 | public Map getEdata() { 64 | return edata; 65 | } 66 | 67 | public void setEdata(Map edata) { 68 | this.edata = edata; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/PhoneValidator.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util; 2 | 3 | import com.google.i18n.phonenumbers.NumberParseException; 4 | import com.google.i18n.phonenumbers.PhoneNumberUtil; 5 | import com.google.i18n.phonenumbers.Phonenumber; 6 | import org.apache.commons.lang3.StringUtils; 7 | 8 | /** 9 | * This class will provide helper method to validate phone number and its country code. 10 | * 11 | * @author Amit Kumar 12 | */ 13 | public class PhoneValidator { 14 | private static LoggerUtil logger = new LoggerUtil(PhoneValidator.class); 15 | 16 | private PhoneValidator() {} 17 | 18 | public static boolean validatePhone(String phone, String countryCode) { 19 | PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); 20 | String code = countryCode; 21 | if (StringUtils.isNotBlank(countryCode) && (countryCode.charAt(0) != '+')) { 22 | code = "+" + countryCode; 23 | } 24 | Phonenumber.PhoneNumber phoneNumber = null; 25 | try { 26 | if (StringUtils.isBlank(countryCode)) { 27 | code = PropertiesCache.getInstance().getProperty("sunbird_default_country_code"); 28 | } 29 | String isoCode = phoneNumberUtil.getRegionCodeForCountryCode(Integer.parseInt(code)); 30 | phoneNumber = phoneNumberUtil.parse(phone, isoCode); 31 | return phoneNumberUtil.isValidNumber(phoneNumber); 32 | } catch (NumberParseException e) { 33 | logger.error( 34 | "PhoneValidator:validatePhone: Exception occurred while validating phone number = ", e); 35 | } 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/role/dao/impl/RoleDaoImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.learner.actors.role.dao.impl; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import java.util.List; 6 | import java.util.Map; 7 | import org.sunbird.cassandra.CassandraOperation; 8 | import org.sunbird.common.models.response.Response; 9 | import org.sunbird.common.models.util.JsonKey; 10 | import org.sunbird.helper.ServiceFactory; 11 | import org.sunbird.learner.actors.role.dao.RoleDao; 12 | import org.sunbird.learner.util.Util; 13 | import org.sunbird.models.role.Role; 14 | 15 | public class RoleDaoImpl implements RoleDao { 16 | 17 | private static final String TABLE_NAME = "role"; 18 | private ObjectMapper mapper = new ObjectMapper(); 19 | private static RoleDao roleDao; 20 | 21 | public static RoleDao getInstance() { 22 | if (roleDao == null) { 23 | roleDao = new RoleDaoImpl(); 24 | } 25 | return roleDao; 26 | } 27 | 28 | @SuppressWarnings("unchecked") 29 | @Override 30 | public List getRoles() { 31 | Response roleResults = 32 | getCassandraOperation().getAllRecords(Util.KEY_SPACE_NAME, TABLE_NAME, null); 33 | TypeReference> roleMapType = new TypeReference>() {}; 34 | List> roleMapList = 35 | (List>) roleResults.get(JsonKey.RESPONSE); 36 | List roleList = mapper.convertValue(roleMapList, roleMapType); 37 | return roleList; 38 | } 39 | 40 | public CassandraOperation getCassandraOperation() { 41 | return ServiceFactory.getInstance(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/response/Params.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.response; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Common response parameter bean 7 | * 8 | * @author Manzarul 9 | */ 10 | public class Params implements Serializable { 11 | 12 | private static final long serialVersionUID = -8786004970726124473L; 13 | private String resmsgid; 14 | private String msgid; 15 | private String err; 16 | private String status; 17 | private String errmsg; 18 | 19 | /** @return String */ 20 | public String getResmsgid() { 21 | return resmsgid; 22 | } 23 | 24 | /** @param resmsgid Stirng */ 25 | public void setResmsgid(String resmsgid) { 26 | this.resmsgid = resmsgid; 27 | } 28 | 29 | /** @return Stirng */ 30 | public String getMsgid() { 31 | return msgid; 32 | } 33 | 34 | /** @param msgid String */ 35 | public void setMsgid(String msgid) { 36 | this.msgid = msgid; 37 | } 38 | 39 | /** @return String */ 40 | public String getErr() { 41 | return err; 42 | } 43 | 44 | /** @param err String */ 45 | public void setErr(String err) { 46 | this.err = err; 47 | } 48 | 49 | /** @return String */ 50 | public String getStatus() { 51 | return status; 52 | } 53 | 54 | /** @param status Stirng */ 55 | public void setStatus(String status) { 56 | this.status = status; 57 | } 58 | 59 | /** @return Stirng */ 60 | public String getErrmsg() { 61 | return errmsg; 62 | } 63 | 64 | /** @param errmsg Stirng */ 65 | public void setErrmsg(String errmsg) { 66 | this.errmsg = errmsg; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-platform-core/common-util/src/main/java/org/sunbird/common/models/util/azure/AzureCloudService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.models.util.azure; 2 | 3 | import java.io.File; 4 | import java.util.List; 5 | import org.sunbird.common.request.RequestContext; 6 | 7 | /** Created by arvind on 24/8/17. */ 8 | public class AzureCloudService implements CloudService { 9 | 10 | @Override 11 | public String uploadFile( 12 | String containerName, String fileName, String fileLocation, RequestContext context) { 13 | return AzureFileUtility.uploadFile(containerName, fileName, fileLocation, context); 14 | } 15 | 16 | @Override 17 | public boolean downLoadFile( 18 | String containerName, String fileName, String downloadFolder, RequestContext context) { 19 | return AzureFileUtility.downloadFile(containerName, fileName, downloadFolder, context); 20 | } 21 | 22 | @Override 23 | public String uploadFile(String containerName, File file, RequestContext context) { 24 | return AzureFileUtility.uploadFile(containerName, file, context); 25 | } 26 | 27 | @Override 28 | public boolean deleteFile(String containerName, String fileName, RequestContext context) { 29 | return AzureFileUtility.deleteFile(containerName, fileName, context); 30 | } 31 | 32 | @Override 33 | public List listAllFiles(String containerName, RequestContext context) { 34 | return AzureFileUtility.listAllBlobbs(containerName, context); 35 | } 36 | 37 | @Override 38 | public boolean deleteContainer(String containerName, RequestContext context) { 39 | return AzureFileUtility.deleteContainer(containerName, context); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /actors/sunbird-lms-mw/actors/sunbird-utils/sunbird-es-utils/src/test/java/org/sunbird/helper/ConnectionManagerTest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.helper; 2 | 3 | import org.elasticsearch.action.bulk.BulkProcessor; 4 | import org.elasticsearch.action.get.GetRequestBuilder; 5 | import org.elasticsearch.action.support.master.AcknowledgedResponse; 6 | import org.elasticsearch.client.RestHighLevelClient; 7 | import org.elasticsearch.common.util.concurrent.FutureUtils; 8 | import org.elasticsearch.search.SearchHit; 9 | import org.elasticsearch.search.SearchHits; 10 | import org.elasticsearch.search.aggregations.Aggregations; 11 | import org.junit.Assert; 12 | import org.junit.FixMethodOrder; 13 | import org.junit.runner.RunWith; 14 | import org.junit.runners.MethodSorters; 15 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 16 | import org.powermock.core.classloader.annotations.PrepareForTest; 17 | import org.powermock.modules.junit4.PowerMockRunner; 18 | 19 | /** @author manzarul */ 20 | @FixMethodOrder(MethodSorters.NAME_ASCENDING) 21 | @RunWith(PowerMockRunner.class) 22 | @PowerMockIgnore({ 23 | "javax.management.*", 24 | "javax.net.ssl.*", 25 | "javax.security.*", 26 | "jdk.internal.reflect.*" 27 | }) 28 | @PrepareForTest({ 29 | ConnectionManager.class, 30 | AcknowledgedResponse.class, 31 | GetRequestBuilder.class, 32 | BulkProcessor.class, 33 | FutureUtils.class, 34 | SearchHit.class, 35 | SearchHits.class, 36 | Aggregations.class 37 | }) 38 | public class ConnectionManagerTest { 39 | 40 | // @Test 41 | public void testGetRestClientNull() { 42 | RestHighLevelClient client = ConnectionManager.getRestClient(); 43 | Assert.assertNull(client); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /service/app/modules/SignalHandler.java: -------------------------------------------------------------------------------- 1 | package modules; 2 | 3 | import akka.actor.ActorSystem; 4 | import java.util.concurrent.TimeUnit; 5 | import javax.inject.Inject; 6 | import javax.inject.Provider; 7 | import javax.inject.Singleton; 8 | import org.sunbird.common.models.util.LoggerUtil; 9 | import org.sunbird.common.models.util.ProjectUtil; 10 | import play.api.Application; 11 | import play.api.Play; 12 | import scala.concurrent.duration.Duration; 13 | import scala.concurrent.duration.FiniteDuration; 14 | import sun.misc.Signal; 15 | 16 | @Singleton 17 | public class SignalHandler { 18 | private static LoggerUtil logger = new LoggerUtil(SignalHandler.class); 19 | 20 | private static long stopDelay = Long.parseLong(ProjectUtil.getConfigValue("sigterm_stop_delay")); 21 | private static final FiniteDuration STOP_DELAY = Duration.create(stopDelay, TimeUnit.SECONDS); 22 | 23 | private volatile boolean isShuttingDown = false; 24 | 25 | @Inject 26 | public SignalHandler(ActorSystem actorSystem, Provider applicationProvider) { 27 | Signal.handle( 28 | new Signal("TERM"), 29 | signal -> { 30 | isShuttingDown = true; 31 | logger.info( 32 | "Termination required, swallowing SIGTERM to allow current requests to finish"); 33 | actorSystem 34 | .scheduler() 35 | .scheduleOnce( 36 | STOP_DELAY, 37 | () -> { 38 | Play.stop(applicationProvider.get()); 39 | }, 40 | actorSystem.dispatcher()); 41 | }); 42 | } 43 | 44 | public boolean isShuttingDown() { 45 | return isShuttingDown; 46 | } 47 | } 48 | --------------------------------------------------------------------------------