Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
ROBERT Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
24
Issues
24
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TousAntiCovid sources
ROBERT Server
Commits
56b40a29
Commit
56b40a29
authored
Aug 10, 2020
by
Deniro StopCovid
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'update-to-push-notif' into 'develop'
Update to push notif See merge request
!92
parents
0f5a86d4
ba2f8451
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
1628 additions
and
1030 deletions
+1628
-1030
robert-crypto-grpc-server/src/main/java/fr/gouv/stopc/robert/crypto/grpc/server/service/impl/CryptoServerConfigurationServiceImpl.java
...er/service/impl/CryptoServerConfigurationServiceImpl.java
+5
-3
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/config/Config.java
...ain/java/fr/gouv/stopc/robertserver/ws/config/Config.java
+0
-4
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/ICaptchaController.java
.../stopc/robertserver/ws/controller/ICaptchaController.java
+1
-3
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IDeleteHistoryController.java
.../robertserver/ws/controller/IDeleteHistoryController.java
+2
-4
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IRegisterController.java
...stopc/robertserver/ws/controller/IRegisterController.java
+1
-3
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IRegisterInternalController.java
...bertserver/ws/controller/IRegisterInternalController.java
+1
-3
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IReportController.java
...v/stopc/robertserver/ws/controller/IReportController.java
+2
-4
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IStatusController.java
...v/stopc/robertserver/ws/controller/IStatusController.java
+2
-4
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IUnregisterController.java
...opc/robertserver/ws/controller/IUnregisterController.java
+2
-3
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/KpiController.java
.../gouv/stopc/robertserver/ws/controller/KpiController.java
+3
-3
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/AbstractRegisterControllerImpl.java
...er/ws/controller/impl/AbstractRegisterControllerImpl.java
+5
-0
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/RegisterControllerImpl.java
...bertserver/ws/controller/impl/RegisterControllerImpl.java
+4
-1
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/RegisterInternalControllerImpl.java
...er/ws/controller/impl/RegisterInternalControllerImpl.java
+4
-1
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/StatusControllerImpl.java
...robertserver/ws/controller/impl/StatusControllerImpl.java
+10
-2
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/UnregisterControllerImpl.java
...rtserver/ws/controller/impl/UnregisterControllerImpl.java
+11
-5
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/service/IRestApiService.java
...r/gouv/stopc/robertserver/ws/service/IRestApiService.java
+5
-0
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/service/impl/RestApiServiceImpl.java
...topc/robertserver/ws/service/impl/RestApiServiceImpl.java
+61
-2
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/utils/PropertyLoader.java
...a/fr/gouv/stopc/robertserver/ws/utils/PropertyLoader.java
+18
-0
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/utils/UriConstants.java
...ava/fr/gouv/stopc/robertserver/ws/utils/UriConstants.java
+15
-9
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/vo/PushInfoVo.java
...ain/java/fr/gouv/stopc/robertserver/ws/vo/PushInfoVo.java
+29
-0
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/vo/RegisterVo.java
...ain/java/fr/gouv/stopc/robertserver/ws/vo/RegisterVo.java
+3
-0
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/vo/ReportBatchRequestVo.java
...r/gouv/stopc/robertserver/ws/vo/ReportBatchRequestVo.java
+0
-1
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/vo/StatusVo.java
.../main/java/fr/gouv/stopc/robertserver/ws/vo/StatusVo.java
+8
-3
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/vo/UnregisterRequestVo.java
...fr/gouv/stopc/robertserver/ws/vo/UnregisterRequestVo.java
+11
-1
robert-server-ws-rest/src/main/resources/application.properties
...-server-ws-rest/src/main/resources/application.properties
+9
-0
robert-server-ws-rest/src/test/java/test/fr/gouv/stopc/robertserver/ws/DeleteHistoryControllerWsRestTest.java
...pc/robertserver/ws/DeleteHistoryControllerWsRestTest.java
+433
-426
robert-server-ws-rest/src/test/java/test/fr/gouv/stopc/robertserver/ws/RegisterControllerWsRestTest.java
...v/stopc/robertserver/ws/RegisterControllerWsRestTest.java
+1
-2
robert-server-ws-rest/src/test/java/test/fr/gouv/stopc/robertserver/ws/RegisterInternalControllerWsRestTest.java
...robertserver/ws/RegisterInternalControllerWsRestTest.java
+267
-188
robert-server-ws-rest/src/test/java/test/fr/gouv/stopc/robertserver/ws/ReportControllerWsRestTest.java
...ouv/stopc/robertserver/ws/ReportControllerWsRestTest.java
+19
-8
robert-server-ws-rest/src/test/java/test/fr/gouv/stopc/robertserver/ws/StatusControllerWsRestTest.java
...ouv/stopc/robertserver/ws/StatusControllerWsRestTest.java
+93
-7
robert-server-ws-rest/src/test/java/test/fr/gouv/stopc/robertserver/ws/UnregisterControllerWsRestTest.java
...stopc/robertserver/ws/UnregisterControllerWsRestTest.java
+425
-338
robert-server-ws-rest/src/test/java/test/fr/gouv/stopc/robertserver/ws/service/impl/RestApiServiceImplTest.java
.../robertserver/ws/service/impl/RestApiServiceImplTest.java
+168
-2
robert-server-ws-rest/src/test/resources/application.properties
...-server-ws-rest/src/test/resources/application.properties
+10
-0
No files found.
robert-crypto-grpc-server/src/main/java/fr/gouv/stopc/robert/crypto/grpc/server/service/impl/CryptoServerConfigurationServiceImpl.java
View file @
56b40a29
package
fr.gouv.stopc.robert.crypto.grpc.server.service.impl
;
import
java.time.LocalDate
;
import
java.time.ZoneOffset
;
import
java.time.ZoneId
;
import
java.time.ZonedDateTime
;
import
java.time.format.DateTimeFormatter
;
import
javax.annotation.PostConstruct
;
...
...
@@ -34,9 +35,10 @@ public class CryptoServerConfigurationServiceImpl implements ICryptoServerConfig
@PostConstruct
private
void
initTimeStartNtp
()
{
LocalDate
ld
=
LocalDate
.
parse
(
this
.
propertyLoader
.
getTimeStart
(),
DateTimeFormatter
.
BASIC_ISO_DATE
);
timeStartNtp
=
TimeUtils
.
convertUnixMillistoNtpSeconds
(
ld
.
atStartOfDay
().
toEpochSecond
(
ZoneOffset
.
UTC
));
final
ZonedDateTime
zdt
=
ld
.
atStartOfDay
().
atZone
(
ZoneId
.
of
(
"UTC"
));
timeStartNtp
=
TimeUtils
.
convertUnixMillistoNtpSeconds
(
zdt
.
toInstant
().
toEpochMilli
());
}
@Override
public
long
getServiceTimeStart
()
{
return
this
.
timeStartNtp
;
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/config/Config.java
View file @
56b40a29
...
...
@@ -6,10 +6,6 @@ import org.springframework.web.client.RestTemplate;
@Configuration
public
class
Config
{
public
static
final
String
API_V1
=
"/v1"
;
public
static
final
String
API_V2
=
"/v2"
;
@Bean
public
RestTemplate
restTemplate
()
{
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/ICaptchaController.java
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.controller
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V2
;
import
javax.validation.Valid
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.Produces
;
...
...
@@ -21,7 +19,7 @@ import fr.gouv.stopc.robertserver.ws.utils.UriConstants;
import
fr.gouv.stopc.robertserver.ws.vo.CaptchaInternalCreationVo
;
@RestController
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
API_V2
})
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
UriConstants
.
API_V2
})
public
interface
ICaptchaController
{
@PostMapping
(
value
=
UriConstants
.
CAPTCHA
)
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IDeleteHistoryController.java
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.controller
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V1
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V2
;
import
javax.validation.Valid
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.Produces
;
...
...
@@ -20,7 +17,8 @@ import fr.gouv.stopc.robertserver.ws.utils.UriConstants;
import
fr.gouv.stopc.robertserver.ws.vo.DeleteHistoryRequestVo
;
@RestController
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
API_V1
,
"${controller.path.prefix}"
+
API_V2
})
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
UriConstants
.
API_V1
,
"${controller.path.prefix}"
+
UriConstants
.
API_V2
,
"${controller.path.prefix}"
+
UriConstants
.
API_V3
})
@Consumes
(
MediaType
.
APPLICATION_JSON_VALUE
)
@Produces
(
MediaType
.
APPLICATION_JSON_VALUE
)
public
interface
IDeleteHistoryController
{
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IRegisterController.java
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.controller
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V1
;
import
javax.validation.Valid
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.Produces
;
...
...
@@ -19,7 +17,7 @@ import fr.gouv.stopc.robertserver.ws.utils.UriConstants;
import
fr.gouv.stopc.robertserver.ws.vo.RegisterVo
;
@RestController
@RequestMapping
(
value
=
"${controller.path.prefix}"
+
API_V1
)
@RequestMapping
(
value
=
"${controller.path.prefix}"
+
UriConstants
.
API_V1
)
@Consumes
(
MediaType
.
APPLICATION_JSON_VALUE
)
@Produces
(
MediaType
.
APPLICATION_JSON_VALUE
)
public
interface
IRegisterController
{
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IRegisterInternalController.java
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.controller
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V2
;
import
javax.validation.Valid
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.Produces
;
...
...
@@ -19,7 +17,7 @@ import fr.gouv.stopc.robertserver.ws.utils.UriConstants;
import
fr.gouv.stopc.robertserver.ws.vo.RegisterInternalVo
;
@RestController
@RequestMapping
(
value
=
"${controller.path.prefix}"
+
API_V2
)
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
UriConstants
.
API_V2
,
"${controller.path.prefix}"
+
UriConstants
.
API_V3
}
)
@Consumes
(
MediaType
.
APPLICATION_JSON_VALUE
)
@Produces
(
MediaType
.
APPLICATION_JSON_VALUE
)
public
interface
IRegisterInternalController
{
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IReportController.java
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.controller
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V1
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V2
;
import
javax.validation.Valid
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.Produces
;
...
...
@@ -20,7 +17,8 @@ import fr.gouv.stopc.robertserver.ws.utils.UriConstants;
import
fr.gouv.stopc.robertserver.ws.vo.ReportBatchRequestVo
;
@RestController
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
API_V1
,
"${controller.path.prefix}"
+
API_V2
})
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
UriConstants
.
API_V1
,
"${controller.path.prefix}"
+
UriConstants
.
API_V2
,
"${controller.path.prefix}"
+
UriConstants
.
API_V3
})
@Consumes
(
MediaType
.
APPLICATION_JSON_VALUE
)
@Produces
(
MediaType
.
APPLICATION_JSON_VALUE
)
public
interface
IReportController
{
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IStatusController.java
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.controller
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V1
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V2
;
import
javax.validation.Valid
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.Produces
;
...
...
@@ -20,7 +17,8 @@ import fr.gouv.stopc.robertserver.ws.utils.UriConstants;
import
fr.gouv.stopc.robertserver.ws.vo.StatusVo
;
@RestController
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
API_V1
,
"${controller.path.prefix}"
+
API_V2
})
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
UriConstants
.
API_V1
,
"${controller.path.prefix}"
+
UriConstants
.
API_V2
,
"${controller.path.prefix}"
+
UriConstants
.
API_V3
})
@Consumes
(
MediaType
.
APPLICATION_JSON_VALUE
)
@Produces
(
MediaType
.
APPLICATION_JSON_VALUE
)
public
interface
IStatusController
{
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/IUnregisterController.java
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.controller
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V1
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V2
;
import
javax.validation.Valid
;
import
javax.ws.rs.Consumes
;
...
...
@@ -19,7 +17,8 @@ import fr.gouv.stopc.robertserver.ws.utils.UriConstants;
import
fr.gouv.stopc.robertserver.ws.vo.UnregisterRequestVo
;
@RestController
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
API_V1
,
"${controller.path.prefix}"
+
API_V2
})
@RequestMapping
(
value
=
{
"${controller.path.prefix}"
+
UriConstants
.
API_V1
,
"${controller.path.prefix}"
+
UriConstants
.
API_V2
,
"${controller.path.prefix}"
+
UriConstants
.
API_V3
})
@Consumes
(
MediaType
.
APPLICATION_JSON_VALUE
)
@Produces
(
MediaType
.
APPLICATION_JSON_VALUE
)
public
interface
IUnregisterController
{
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/KpiController.java
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.controller
;
import
static
fr
.
gouv
.
stopc
.
robertserver
.
ws
.
config
.
Config
.
API_V1
;
import
java.time.LocalDate
;
import
java.util.List
;
...
...
@@ -15,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import
fr.gouv.stopc.robertserver.ws.dto.RobertServerKpi
;
import
fr.gouv.stopc.robertserver.ws.service.IKpiService
;
import
fr.gouv.stopc.robertserver.ws.utils.UriConstants
;
/**
* Endpoint definition for Kpi generation
...
...
@@ -22,7 +21,8 @@ import fr.gouv.stopc.robertserver.ws.service.IKpiService;
*
*/
@RestController
@RequestMapping
(
value
=
"${controller.internal.path.prefix}"
+
API_V1
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"${controller.internal.path.prefix}"
+
UriConstants
.
API_V1
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
class
KpiController
{
/**
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/AbstractRegisterControllerImpl.java
View file @
56b40a29
...
...
@@ -24,6 +24,7 @@ import fr.gouv.stopc.robertserver.database.service.IRegistrationService;
import
fr.gouv.stopc.robertserver.ws.dto.ClientConfigDto
;
import
fr.gouv.stopc.robertserver.ws.dto.RegisterResponseDto
;
import
fr.gouv.stopc.robertserver.ws.exception.RobertServerException
;
import
fr.gouv.stopc.robertserver.ws.service.IRestApiService
;
import
fr.gouv.stopc.robertserver.ws.utils.MessageConstants
;
import
fr.gouv.stopc.robertserver.ws.vo.RegisterVo
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -35,6 +36,7 @@ public abstract class AbstractRegisterControllerImpl {
protected
IServerConfigurationService
serverConfigurationService
;
protected
IApplicationConfigService
applicationConfigService
;
protected
ICryptoServerGrpcClient
cryptoServerClient
;
protected
IRestApiService
restApiService
;
protected
ResponseEntity
<
RegisterResponseDto
>
postCheckRegister
(
RegisterVo
registerVo
)
throws
RobertServerException
{
...
...
@@ -79,6 +81,9 @@ public abstract class AbstractRegisterControllerImpl {
registerResponseDto
.
setTuples
(
Base64
.
encode
(
identity
.
getTuples
().
toByteArray
()));
registerResponseDto
.
setTimeStart
(
this
.
serverConfigurationService
.
getServiceTimeStart
());
Optional
.
ofNullable
(
registerVo
.
getPushInfo
()).
ifPresent
(
this
.
restApiService
::
registerPushNotif
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
registerResponseDto
);
}
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/RegisterControllerImpl.java
View file @
56b40a29
...
...
@@ -14,6 +14,7 @@ import fr.gouv.stopc.robertserver.ws.controller.IRegisterController;
import
fr.gouv.stopc.robertserver.ws.dto.RegisterResponseDto
;
import
fr.gouv.stopc.robertserver.ws.exception.RobertServerException
;
import
fr.gouv.stopc.robertserver.ws.service.CaptchaService
;
import
fr.gouv.stopc.robertserver.ws.service.IRestApiService
;
import
fr.gouv.stopc.robertserver.ws.vo.RegisterVo
;
@Service
...
...
@@ -26,13 +27,15 @@ public class RegisterControllerImpl extends AbstractRegisterControllerImpl imple
final
IServerConfigurationService
serverConfigurationService
,
final
IApplicationConfigService
applicationConfigService
,
final
CaptchaService
captchaService
,
final
ICryptoServerGrpcClient
cryptoServerClient
)
{
final
ICryptoServerGrpcClient
cryptoServerClient
,
final
IRestApiService
restApiService
)
{
this
.
registrationService
=
registrationService
;
this
.
serverConfigurationService
=
serverConfigurationService
;
this
.
applicationConfigService
=
applicationConfigService
;
this
.
captchaService
=
captchaService
;
this
.
cryptoServerClient
=
cryptoServerClient
;
this
.
restApiService
=
restApiService
;
}
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/RegisterInternalControllerImpl.java
View file @
56b40a29
...
...
@@ -15,6 +15,7 @@ import fr.gouv.stopc.robertserver.ws.controller.IRegisterInternalController;
import
fr.gouv.stopc.robertserver.ws.dto.RegisterResponseDto
;
import
fr.gouv.stopc.robertserver.ws.exception.RobertServerException
;
import
fr.gouv.stopc.robertserver.ws.service.CaptchaInternalService
;
import
fr.gouv.stopc.robertserver.ws.service.IRestApiService
;
import
fr.gouv.stopc.robertserver.ws.vo.RegisterInternalVo
;
@Service
...
...
@@ -27,13 +28,15 @@ public class RegisterInternalControllerImpl extends AbstractRegisterControllerIm
final
IServerConfigurationService
serverConfigurationService
,
final
IApplicationConfigService
applicationConfigService
,
final
CaptchaInternalService
captchaInternalService
,
final
ICryptoServerGrpcClient
cryptoServerClient
)
{
final
ICryptoServerGrpcClient
cryptoServerClient
,
final
IRestApiService
restApiService
)
{
this
.
registrationService
=
registrationService
;
this
.
serverConfigurationService
=
serverConfigurationService
;
this
.
applicationConfigService
=
applicationConfigService
;
this
.
captchaInternalService
=
captchaInternalService
;
this
.
cryptoServerClient
=
cryptoServerClient
;
this
.
restApiService
=
restApiService
;
}
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/StatusControllerImpl.java
View file @
56b40a29
...
...
@@ -17,7 +17,6 @@ import fr.gouv.stopc.robert.crypto.grpc.server.messaging.GetIdFromStatusResponse
import
fr.gouv.stopc.robert.server.common.service.IServerConfigurationService
;
import
fr.gouv.stopc.robert.server.common.utils.TimeUtils
;
import
fr.gouv.stopc.robertserver.database.model.ApplicationConfigurationModel
;
import
fr.gouv.stopc.robertserver.database.model.EpochExposition
;
import
fr.gouv.stopc.robertserver.database.model.Registration
;
import
fr.gouv.stopc.robertserver.database.service.IApplicationConfigService
;
import
fr.gouv.stopc.robertserver.database.service.IRegistrationService
;
...
...
@@ -26,6 +25,7 @@ import fr.gouv.stopc.robertserver.ws.dto.ClientConfigDto;
import
fr.gouv.stopc.robertserver.ws.dto.StatusResponseDto
;
import
fr.gouv.stopc.robertserver.ws.exception.RobertServerException
;
import
fr.gouv.stopc.robertserver.ws.service.AuthRequestValidationService
;
import
fr.gouv.stopc.robertserver.ws.service.IRestApiService
;
import
fr.gouv.stopc.robertserver.ws.utils.PropertyLoader
;
import
fr.gouv.stopc.robertserver.ws.vo.StatusVo
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -44,18 +44,23 @@ public class StatusControllerImpl implements IStatusController {
private
final
PropertyLoader
propertyLoader
;
private
final
IRestApiService
restApiService
;
@Inject
public
StatusControllerImpl
(
final
IServerConfigurationService
serverConfigurationService
,
final
IRegistrationService
registrationService
,
final
IApplicationConfigService
applicationConfigService
,
final
AuthRequestValidationService
authRequestValidationService
,
final
PropertyLoader
propertyLoader
)
{
final
PropertyLoader
propertyLoader
,
final
IRestApiService
restApiService
)
{
this
.
serverConfigurationService
=
serverConfigurationService
;
this
.
registrationService
=
registrationService
;
this
.
applicationConfigService
=
applicationConfigService
;
this
.
authRequestValidationService
=
authRequestValidationService
;
this
.
propertyLoader
=
propertyLoader
;
this
.
restApiService
=
restApiService
;
}
@Override
...
...
@@ -92,6 +97,9 @@ public class StatusControllerImpl implements IStatusController {
Optional
<
ResponseEntity
>
responseEntity
=
validate
(
record
.
get
(),
response
.
getEpochId
(),
response
.
getTuples
().
toByteArray
());
if
(
responseEntity
.
isPresent
())
{
Optional
.
ofNullable
(
statusVo
.
getPushInfo
()).
ifPresent
(
this
.
restApiService
::
registerPushNotif
);
return
responseEntity
.
get
();
}
else
{
log
.
info
(
"Status request failed validation"
);
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/controller/impl/UnregisterControllerImpl.java
View file @
56b40a29
...
...
@@ -5,32 +5,34 @@ import java.util.Optional;
import
javax.inject.Inject
;
import
fr.gouv.stopc.robert.crypto.grpc.server.messaging.DeleteIdRequest
;
import
fr.gouv.stopc.robert.crypto.grpc.server.messaging.DeleteIdResponse
;
import
fr.gouv.stopc.robert.crypto.grpc.server.messaging.GetIdFromAuthResponse
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
fr.gouv.stopc.robert.
server.common.DigestSaltEnum
;
import
fr.gouv.stopc.robert.
crypto.grpc.server.messaging.DeleteIdResponse
;
import
fr.gouv.stopc.robertserver.database.model.Registration
;
import
fr.gouv.stopc.robertserver.database.service.IRegistrationService
;
import
fr.gouv.stopc.robertserver.ws.controller.IUnregisterController
;
import
fr.gouv.stopc.robertserver.ws.dto.UnregisterResponseDto
;
import
fr.gouv.stopc.robertserver.ws.service.AuthRequestValidationService
;
import
fr.gouv.stopc.robertserver.ws.service.IRestApiService
;
import
fr.gouv.stopc.robertserver.ws.vo.UnregisterRequestVo
;
import
io.micrometer.core.instrument.util.StringUtils
;
@Service
public
class
UnregisterControllerImpl
implements
IUnregisterController
{
private
final
IRegistrationService
registrationService
;
private
final
AuthRequestValidationService
authRequestValidationService
;
private
final
IRestApiService
restApiService
;
@Inject
public
UnregisterControllerImpl
(
final
IRegistrationService
registrationService
,
final
AuthRequestValidationService
authRequestValidationService
)
{
final
AuthRequestValidationService
authRequestValidationService
,
final
IRestApiService
restApiService
)
{
this
.
registrationService
=
registrationService
;
this
.
authRequestValidationService
=
authRequestValidationService
;
this
.
restApiService
=
restApiService
;;
}
@Override
...
...
@@ -54,6 +56,10 @@ public class UnregisterControllerImpl implements IUnregisterController {
UnregisterResponseDto
response
=
UnregisterResponseDto
.
builder
().
success
(
true
).
build
();
if
(
StringUtils
.
isNotBlank
(
unregisterRequestVo
.
getPushToken
()))
{
this
.
restApiService
.
unregisterPushNotif
(
unregisterRequestVo
.
getPushToken
());
}
return
ResponseEntity
.
ok
(
response
);
}
else
{
return
ResponseEntity
.
notFound
().
build
();
...
...
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/service/IRestApiService.java
View file @
56b40a29
...
...
@@ -3,8 +3,13 @@ package fr.gouv.stopc.robertserver.ws.service;
import
java.util.Optional
;
import
fr.gouv.stopc.robertserver.ws.dto.VerifyResponseDto
;
import
fr.gouv.stopc.robertserver.ws.vo.PushInfoVo
;
public
interface
IRestApiService
{
Optional
<
VerifyResponseDto
>
verifyReportToken
(
String
token
,
String
type
);
void
registerPushNotif
(
PushInfoVo
pushInfoVo
);
void
unregisterPushNotif
(
String
pushToken
);
}
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/service/impl/RestApiServiceImpl.java
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.service.impl
;
import
java.net.URI
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Optional
;
import
javax.inject.Inject
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.client.RestClientException
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.util.UriComponentsBuilder
;
...
...
@@ -15,6 +18,8 @@ import org.springframework.web.util.UriComponentsBuilder;
import
fr.gouv.stopc.robertserver.ws.dto.VerifyResponseDto
;
import
fr.gouv.stopc.robertserver.ws.service.IRestApiService
;
import
fr.gouv.stopc.robertserver.ws.utils.PropertyLoader
;
import
fr.gouv.stopc.robertserver.ws.vo.PushInfoVo
;
import
io.micrometer.core.instrument.util.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
...
...
@@ -41,7 +46,7 @@ public class RestApiServiceImpl implements IRestApiService {
try
{
ResponseEntity
<
VerifyResponseDto
>
response
=
restTemplate
.
getForEntity
(
buildReportTokenVerificationURI
(
token
,
type
),
VerifyResponseDto
.
class
);
return
Optional
.
ofNullable
(
response
.
getBody
());
}
catch
(
RestClientException
e
)
{
log
.
error
(
"Unable to verify the token due to {}"
,
e
.
getMessage
());
...
...
@@ -63,4 +68,58 @@ public class RestApiServiceImpl implements IRestApiService {
.
toUri
();
}
private
URI
buildRegistertPushNotifURI
()
{
return
UriComponentsBuilder
.
newInstance
().
scheme
(
"http"
)
.
host
(
this
.
propertyLoader
.
getPushServerHost
())
.
port
(
this
.
propertyLoader
.
getPushServerPort
())
.
path
(
this
.
propertyLoader
.
getInternalPathPrefix
())
.
path
(
this
.
propertyLoader
.
getPushApiVersion
())
.
path
(
this
.
propertyLoader
.
getPushApiPath
())
.
build
()
.
encode
()
.
toUri
();
}
private
URI
buildUnregistertPushNotifURI
(
String
pushToken
)
{
Map
<
String
,
String
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"token"
,
pushToken
);
return
UriComponentsBuilder
.
fromUri
(
this
.
buildRegistertPushNotifURI
())
.
path
(
this
.
propertyLoader
.
getPushApiTokenPath
())
.
build
(
parameters
);
}
@Override
public
void
registerPushNotif
(
PushInfoVo
pushInfoVo
)
{
if
(
Objects
.
nonNull
(
pushInfoVo
))
{
try
{
this
.
restTemplate
.
postForEntity
(
this
.
buildRegistertPushNotifURI
(),
pushInfoVo
,
Object
.
class
);
log
.
info
(
"Register to push notification successful"
);
}
catch
(
RestClientException
e
)
{
log
.
error
(
"Register to push notification failed due to {}"
,
e
.
getMessage
());
}
}
}
@Override
public
void
unregisterPushNotif
(
String
pushToken
)
{
if
(
StringUtils
.
isNotBlank
(
pushToken
))
{
try
{
this
.
restTemplate
.
exchange
(
this
.
buildUnregistertPushNotifURI
(
pushToken
),
HttpMethod
.
DELETE
,
null
,
Object
.
class
);
log
.
info
(
"Unregister to push notification successful"
);
}
catch
(
RestClientException
e
)
{
log
.
error
(
"Unregister to push notification failed due to {}"
,
e
.
getMessage
());
}
}
}
}
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/utils/PropertyLoader.java
View file @
56b40a29
...
...
@@ -70,4 +70,22 @@ public class PropertyLoader {
@Value
(
"${robert.server.captcha-challenge-timestamp-tolerance}"
)
private
Integer
captchaChallengeTimestampTolerance
;
@Value
(
"${controller.internal.path.prefix}"
)
private
String
internalPathPrefix
;
@Value
(
"${push.server.host}"
)
private
String
pushServerHost
;
@Value
(
"${push.server.port}"
)
private
String
pushServerPort
;
@Value
(
"${push.api.version}"
)
private
String
pushApiVersion
;
@Value
(
"${push.api.path}"
)
private
String
pushApiPath
;
@Value
(
"${push.api.path.token}"
)
private
String
pushApiTokenPath
;
}
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/utils/UriConstants.java
View file @
56b40a29
...
...
@@ -2,21 +2,27 @@ package fr.gouv.stopc.robertserver.ws.utils;
public
final
class
UriConstants
{
private
UriConstants
()
{
private
UriConstants
()
{
throw
new
AssertionError
();
}
throw
new
AssertionError
();
}
public
static
final
String
REPORT
=
"/report"
;
public
static
final
String
REPORT
=
"/report"
;
public
static
final
String
STATUS
=
"/status"
;
public
static
final
String
STATUS
=
"/status"
;
public
static
final
String
REGISTER
=
"/register"
;
public
static
final
String
REGISTER
=
"/register"
;
public
static
final
String
UNREGISTER
=
"/unregister"
;
public
static
final
String
UNREGISTER
=
"/unregister"
;
public
static
final
String
DELETE_HISTORY
=
"/deleteExposureHistory"
;
public
static
final
String
DELETE_HISTORY
=
"/deleteExposureHistory"
;
public
static
final
String
CAPTCHA
=
"/captcha"
;
public
static
final
String
CAPTCHA
=
"/captcha"
;
public
static
final
String
API_V1
=
"/v1"
;
public
static
final
String
API_V2
=
"/v2"
;
public
static
final
String
API_V3
=
"/v3"
;
}
robert-server-ws-rest/src/main/java/fr/gouv/stopc/robertserver/ws/vo/PushInfoVo.java
0 → 100644
View file @
56b40a29
package
fr.gouv.stopc.robertserver.ws.vo
;
import
javax.validation.constraints.NotNull
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public
class
PushInfoVo
{
@NotNull
@ToString
.
Exclude