Repository: corona-warn-app/cwa-server
File: services/distribution/src/main/java/app/coronawarn/server/services/distribution/assembly/appconfig/ApplicationConfigurationV2PublicationConfig.java (Java)

Code before:
            .setRegion(deserializedHourConfig.getRegion())
            .setDate(deserializedHourConfig.getDate())
            .setHour(deserializedHourConfig.getHour())
            .setEtag(deserializedHourConfig.getEtag())
            .build()).collect(Collectors.toList());
  }

  private DGCParameters buildDgcParameters(
      DistributionServiceConfig distributionServiceConfig, String serviceKeyDigest) {
    final Integer waitAfterPublicKeyRegistrationInSeconds = distributionServiceConfig.getAppConfigParameters()
        .getDgcParameters().getTestCertificateParameters().getWaitAfterPublicKeyRegistrationInSeconds();
    final Integer waitForRetryInSeconds = distributionServiceConfig.getAppConfigParameters().getDgcParameters()
        .getTestCertificateParameters().getWaitForRetryInSeconds();
    final DGCTestCertificateParameters testCertificateParameters = DGCTestCertificateParameters.newBuilder()
        .setWaitAfterPublicKeyRegistrationInSeconds(waitAfterPublicKeyRegistrationInSeconds)
        .setWaitForRetryInSeconds(waitForRetryInSeconds)
        .build();
    return DGCParameters.newBuilder()
        .setTestCertificateParameters(testCertificateParameters)
        .setExpirationThresholdInDays(distributionServiceConfig.getAppConfigParameters()
            .getDgcParameters().getExpirationThresholdInDays())
        .setBlockListParameters(DGCBlocklistParameters.newBuilder()
            .addAllBlockedUvciChunks(buildBlockedUvciChunks(distributionServiceConfig.getAppConfigParameters()
                .getDgcParameters().getBlockListParameters().getBlockedUvciChunks()))
            .build())
        .setReissueServicePublicKeyDigest(ByteString.copyFromUtf8(serviceKeyDigest))
        .build();
  }

  private List<DGCBlockedUVCIChunk> buildBlockedUvciChunks(
      List<DgcBlockedUvciChunk> deserializedBlockedUvciChunks) {
    return deserializedBlockedUvciChunks.stream().filter(dgcBlockedUvciChunk ->
            TimeUtils.getNow().getEpochSecond() >= dgcBlockedUvciChunk.getValidFrom())
        .map(deserializedBlockedUvciChunk -> DGCBlockedUVCIChunk.newBuilder()
            .addAllIndices(deserializedBlockedUvciChunk.getIndices())
            .setHash(ByteString.copyFrom(deserializedBlockedUvciChunk.getHash()))
            .build()).collect(Collectors.toList());
  }
}


Review comment (suggestion):
```suggestion
        .setReissueServicePublicKeyDigest(ByteString.copyFrom(serviceKeyDigest))
```

Code after:
            .setRegion(deserializedHourConfig.getRegion())
            .setDate(deserializedHourConfig.getDate())
            .setHour(deserializedHourConfig.getHour())
            .setEtag(deserializedHourConfig.getEtag())
            .build()).collect(Collectors.toList());
  }

  private DGCParameters buildDgcParameters(
      DistributionServiceConfig distributionServiceConfig, byte[] serviceKeyDigest) {
    final Integer waitAfterPublicKeyRegistrationInSeconds = distributionServiceConfig.getAppConfigParameters()
        .getDgcParameters().getTestCertificateParameters().getWaitAfterPublicKeyRegistrationInSeconds();
    final Integer waitForRetryInSeconds = distributionServiceConfig.getAppConfigParameters().getDgcParameters()
        .getTestCertificateParameters().getWaitForRetryInSeconds();
    final DGCTestCertificateParameters testCertificateParameters = DGCTestCertificateParameters.newBuilder()
        .setWaitAfterPublicKeyRegistrationInSeconds(waitAfterPublicKeyRegistrationInSeconds)
        .setWaitForRetryInSeconds(waitForRetryInSeconds)
        .build();
    return DGCParameters.newBuilder()
        .setTestCertificateParameters(testCertificateParameters)
        .setExpirationThresholdInDays(distributionServiceConfig.getAppConfigParameters()
            .getDgcParameters().getExpirationThresholdInDays())
        .setBlockListParameters(DGCBlocklistParameters.newBuilder()
            .addAllBlockedUvciChunks(buildBlockedUvciChunks(distributionServiceConfig.getAppConfigParameters()
                .getDgcParameters().getBlockListParameters().getBlockedUvciChunks()))
            .build())
        .setReissueServicePublicKeyDigest(ByteString.copyFrom((serviceKeyDigest)))
        .build();
  }

  private List<DGCBlockedUVCIChunk> buildBlockedUvciChunks(
      List<DgcBlockedUvciChunk> deserializedBlockedUvciChunks) {
    return deserializedBlockedUvciChunks.stream().filter(dgcBlockedUvciChunk ->
            TimeUtils.getNow().getEpochSecond() >= dgcBlockedUvciChunk.getValidFrom())
        .map(deserializedBlockedUvciChunk -> DGCBlockedUVCIChunk.newBuilder()
            .addAllIndices(deserializedBlockedUvciChunk.getIndices())
            .setHash(ByteString.copyFrom(deserializedBlockedUvciChunk.getHash()))
            .build()).collect(Collectors.toList());
  }
}