Skip to content

Commit

Permalink
add configuration option for TETRA GW authentication token
Browse files Browse the repository at this point in the history
  • Loading branch information
robo-w committed May 24, 2024
1 parent a2e7796 commit aee3b68
Show file tree
Hide file tree
Showing 39 changed files with 139 additions and 86 deletions.
2 changes: 1 addition & 1 deletion config/config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso-config</groupId>
<artifactId>coceso-config-base</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>coceso-config</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion config/db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso-config</groupId>
<artifactId>coceso-config-base</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>coceso-config-db</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso</groupId>
<artifactId>base</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<groupId>at.wrk.coceso-config</groupId>
Expand Down
2 changes: 1 addition & 1 deletion config/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso-config</groupId>
<artifactId>coceso-config-base</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>coceso-config-web</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class WebAppInitializer implements WebApplicationInitializer {

@Override
public void onStartup(ServletContext context) throws ServletException {
public void onStartup(ServletContext context) {
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(CocesoWebMvcConfigurer.class);

Expand Down
2 changes: 1 addition & 1 deletion geocode/geocode-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.geocode</groupId>
<artifactId>geocode-base</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>geocode-impl</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion geocode/geocode/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.geocode</groupId>
<artifactId>geocode-base</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>geocode</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion geocode/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso</groupId>
<artifactId>base</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<groupId>at.wrk.geocode</groupId>
Expand Down
2 changes: 1 addition & 1 deletion main/db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso</groupId>
<artifactId>main</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>coceso-db</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion main/entity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso</groupId>
<artifactId>main</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>coceso-entity</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package at.wrk.coceso.entity.enums;

public enum Ambulance {
KTWsitzend, KTWliegend, RTW, RTWmitNEF;
KTW_sitzend,
KTW_liegend,
RTW,
RTW_mit_NEF;

@Override
public String toString() {
return name().replace("_", " ");
}
}
2 changes: 1 addition & 1 deletion main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso</groupId>
<artifactId>base</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>main</artifactId>
Expand Down
7 changes: 0 additions & 7 deletions main/resources/ReleaseNotes/2.7.8.md

This file was deleted.

11 changes: 11 additions & 0 deletions main/resources/ReleaseNotes/2.8.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Coordination Center Software - Release Notes

## Version 2.8.0

**Release date: ???**

* Fix direction of received talkbursts via message interface
* Updated ambulance types for Vienna usage
* Update to latest 3rd party dependencies
* Add configuration option for TETRA GW authentication token
* Rename configuration option for SMS authentication token for consistency
2 changes: 1 addition & 1 deletion main/service-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso</groupId>
<artifactId>main</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>coceso-service-impl</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private Incident createTransport(final Patient patient, final TransportForm form
incident.setBlue(true);

if (form.getAmbulance() != null) {
incident.setInfo(form.getAmbulance().name());
incident.setInfo(form.getAmbulance().toString());
}

incident.setPriority(form.isPriority());
Expand Down
2 changes: 1 addition & 1 deletion main/service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso</groupId>
<artifactId>main</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>coceso-service</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion main/taglib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso</groupId>
<artifactId>main</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>coceso-taglib</artifactId>
Expand Down
11 changes: 9 additions & 2 deletions main/view/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>at.wrk.coceso</groupId>
<artifactId>main</artifactId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>

<artifactId>coceso-view</artifactId>
Expand Down Expand Up @@ -311,7 +311,7 @@
<plugin>
<groupId>biz.gabrys.maven.plugins</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
<version>1.1</version>
<version>1.2.1</version>
<configuration>
<compilerType>local</compilerType>
<sourceDirectory>src/main/webapp/static/less</sourceDirectory>
Expand All @@ -329,6 +329,13 @@
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ alarm.text.gateway.sms.type=gammu
# The URI of the SMS gateway. For example 'https://sms-gw.local:8082/sms/send'
alarm.text.gateway.uri=

# The authentication token to authenticate agains the SMS gateway. For the type 'internal' it must contain a valid BASIC encoded authentication string.
alarm.text.gateway.authenticationToken=
# The authentication token to authenticate against the SMS gateway. For the type 'internal' it must contain a valid BASIC encoded authentication string.
alarm.text.gateway.sms.authentication.token=

# The prefix which shall be used to validate phone numbers
alarm.text.gateway.phone.number.prefix=+43
Expand All @@ -47,3 +47,6 @@ alarm.text.gateway.phone.number.default.country.code=+43

# The URI of the TETRA gateway. For example 'https://tetra-gw.local:8081/'
alarm.text.gateway.tetra.uri=

# The authentication token against the TETRA gateway. If left empty, no authentication will be used.
alarm.text.gateway.tetra.authentication.token=
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Global messages for all languages
coceso=CoCeSo
coceso.version=v2.7.8-SNAPSHOT
coceso.version=v2.8.0-SNAPSHOT
2 changes: 1 addition & 1 deletion plugin/alarm-text/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>coceso-plugins-base</artifactId>
<groupId>at.wrk.coceso-plugins</groupId>
<version>2.7.8-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import javax.annotation.Nullable;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Optional;

@Component
public class AlarmTextConfiguration {
Expand All @@ -20,21 +21,26 @@ public class AlarmTextConfiguration {
private final URI tetraGatewayUri;
private final String validPrefix;
private final String defaultCountryCode;
private final String authenticationToken;
private final String tetraAuthenticationToken;
private final String smsAuthenticationToken;

public AlarmTextConfiguration(
@Value("${alarm.text.gateway.sms.uri:}") final String smsGatewayUriString,
@Value("${alarm.text.gateway.sms.type:}") final String smsGatewayType,
@Value("${alarm.text.gateway.tetra.uri:}") final String tetraGatewayUriString,
@Value("${alarm.text.gateway.phone.number.prefix:}") final String validPhonePrefix,
@Value("${alarm.text.gateway.phone.number.default.country.code:}") final String defaultCountryCode,
@Value("${alarm.text.gateway.authenticationToken:}") final String authenticationToken) {
@Value("${alarm.text.gateway.authenticationToken:}") final String legacyAuthenticationToken,
@Value("${alarm.text.gateway.sms.authentication.token:}") final String smsAuthenticationToken,
@Value("${alarm.text.gateway.tetra.authentication.token:}") final String tetraAuthenticationToken) {
this.smsGatewayUri = parseHttpUriFromString(smsGatewayUriString);
this.smsGatewayType = StringUtils.isNotBlank(smsGatewayType) ? smsGatewayType : DEFAULT_SMS_GATEWAY_TYPE;
this.tetraGatewayUri = parseHttpUriFromString(tetraGatewayUriString);
this.validPrefix = StringUtils.trimToNull(validPhonePrefix);
this.defaultCountryCode = StringUtils.trimToNull(defaultCountryCode);
this.authenticationToken = StringUtils.trimToNull(authenticationToken);
this.tetraAuthenticationToken = tetraAuthenticationToken;
this.smsAuthenticationToken = Optional.ofNullable(StringUtils.trimToNull(smsAuthenticationToken))
.orElse(legacyAuthenticationToken);
}

@Nullable
Expand All @@ -61,8 +67,13 @@ public String getDefaultCountryCode() {
}

@Nullable
public String getAuthenticationToken() {
return authenticationToken;
public String getSmsAuthenticationToken() {
return smsAuthenticationToken;
}

@Nullable
public String getTetraAuthenticationToken() {
return tetraAuthenticationToken;
}

private static URI parseHttpUriFromString(final String uriString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SendTextMessageRequestFactory {
public SendTextMessageRequestFactory(
final AlarmTextConfiguration alarmTextConfiguration,
final Gson gson) {
this.authenticationToken = alarmTextConfiguration.getAuthenticationToken();
this.authenticationToken = alarmTextConfiguration.getSmsAuthenticationToken();
gatewayType = Optional.ofNullable(alarmTextConfiguration.getSmsGatewayType())
.map(TYPE_MAPPING::get)
.orElse(SmsGatewayType.GAMMU);
Expand All @@ -42,7 +42,7 @@ public SendTextMessageRequestFactory(
public Optional<HttpEntity<String>> createHttpEntityOfRequest(final String alarmText, final List<String> targets) {
Optional<HttpEntity<String>> httpEntity = Optional.empty();

if (authenticationToken != null) {
if (authenticationToken != null || gatewayType == SmsGatewayType.GAMMU) {
SendTextMessageRequest request = createRequest(alarmText, targets);

String jsonRequest = gson.toJson(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class AsyncTetraAlarmTextSender implements AlarmTextSender {
private final AsyncRestTemplate asyncRestTemplate;
private final TetraSendAlarmTextCallback callback;
private final URI gatewayUrl;
private final String authenticationToken;

@Autowired
public AsyncTetraAlarmTextSender(
Expand All @@ -37,6 +38,7 @@ public AsyncTetraAlarmTextSender(
this.asyncRestTemplate = asyncRestTemplate;
this.callback = callback;
this.gatewayUrl = buildSendUrl(alarmTextConfiguration.getTetraGatewayUri());
this.authenticationToken = alarmTextConfiguration.getTetraAuthenticationToken();
}

private static URI buildSendUrl(final URI alarmTextGatewayUrl) {
Expand All @@ -53,7 +55,7 @@ public SendAlarmTextResult sendAlarmText(final String alarmText, final List<Stri
SendAlarmTextResult result;

if (gatewayUrl == null) {
LOG.debug("No TETRA gateway configured. Cannot send SDS to mobiles.");
LOG.debug("No TETRA gateway configured. Cannot send SDS to mobiles '{}'.", targets);
result = SendAlarmTextResult.NO_GATEWAY_CONFIGURED;
} else {
result = SendAlarmTextResult.SUCCESS;
Expand All @@ -67,12 +69,20 @@ public SendAlarmTextResult sendAlarmText(final String alarmText, final List<Stri
private void sendSds(final String alarmText, final String targetIssi) {
SendSdsRequest request = new SendSdsRequest(targetIssi, alarmText, OutgoingSdsType.INDIVIDUAL_ACK);
HttpEntity<String> httpEntity = serializeRequest(request);
LOG.debug("Sending alarm text to target '{}'.", targetIssi);
ListenableFuture<ResponseEntity<String>> responseFuture = asyncRestTemplate.postForEntity(gatewayUrl, httpEntity, String.class);
responseFuture.addCallback(callback);
}

private HttpEntity<String> serializeRequest(final SendSdsRequest request) {
String jsonRequest = gson.toJson(request);
return HttpEntities.createHttpEntityForJsonString(jsonRequest);
HttpEntity<String> httpEntity;
if (authenticationToken != null) {
httpEntity = HttpEntities.createHttpEntityForJsonStringWithBearerTokenAuthentication(jsonRequest, authenticationToken);
} else {
httpEntity = HttpEntities.createHttpEntityForJsonString(jsonRequest);
}

return httpEntity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class TetraSendAlarmTextCallback implements ListenableFutureCallback<Resp
@Override
public void onFailure(final Throwable throwable) {
LOG.warn("Failed to send alarm text to TETRA gateway. Message: {}", throwable.getMessage());
LOG.debug("Underyling exception", throwable);
LOG.debug("Underlying exception", throwable);
}

@Override
Expand Down
Loading

0 comments on commit aee3b68

Please sign in to comment.