@Test public void noTSPSourceDefinedTest() { RemoteTimestampService remoteTimestampService = new RemoteTimestampService(); byte[] contentToBeTimestamped = "Hello World!".getBytes(); byte[] digestValue = DSSUtils.digest(DigestAlgorithm.SHA1, contentToBeTimestamped); Exception exception = assertThrows(NullPointerException.class, () -> remoteTimestampService.getTimestampResponse(DigestAlgorithm.SHA1, digestValue)); assertEquals("TSPSource must be not null!", exception.getMessage()); }
public TimestampResponseDTO getTimestampResponse(final DigestAlgorithm digestAlgorithm, final byte[] value) throws DSSException { Objects.requireNonNull(tspSource, "TSPSource must be not null!"); LOG.info("Timestamp request in process..."); Objects.requireNonNull(digestAlgorithm, "digestAlgorithm must be not null!"); Objects.requireNonNull(value, "value must be not null!"); TimestampBinary timestampBinary = tspSource.getTimeStampResponse(digestAlgorithm, value); if (timestampBinary != null && Utils.isArrayNotEmpty(timestampBinary.getBytes())) { LOG.info("Timestamp is obtained."); return toTimestampResponseDTO(timestampBinary); } throw new DSSException("The obtained TimestampToken response is null or empty!"); }
RemoteTimestampService { public TimestampResponseDTO getTimestampResponse(final DigestAlgorithm digestAlgorithm, final byte[] value) throws DSSException { Objects.requireNonNull(tspSource, "TSPSource must be not null!"); LOG.info("Timestamp request in process..."); Objects.requireNonNull(digestAlgorithm, "digestAlgorithm must be not null!"); Objects.requireNonNull(value, "value must be not null!"); TimestampBinary timestampBinary = tspSource.getTimeStampResponse(digestAlgorithm, value); if (timestampBinary != null && Utils.isArrayNotEmpty(timestampBinary.getBytes())) { LOG.info("Timestamp is obtained."); return toTimestampResponseDTO(timestampBinary); } throw new DSSException("The obtained TimestampToken response is null or empty!"); } }
RemoteTimestampService { public TimestampResponseDTO getTimestampResponse(final DigestAlgorithm digestAlgorithm, final byte[] value) throws DSSException { Objects.requireNonNull(tspSource, "TSPSource must be not null!"); LOG.info("Timestamp request in process..."); Objects.requireNonNull(digestAlgorithm, "digestAlgorithm must be not null!"); Objects.requireNonNull(value, "value must be not null!"); TimestampBinary timestampBinary = tspSource.getTimeStampResponse(digestAlgorithm, value); if (timestampBinary != null && Utils.isArrayNotEmpty(timestampBinary.getBytes())) { LOG.info("Timestamp is obtained."); return toTimestampResponseDTO(timestampBinary); } throw new DSSException("The obtained TimestampToken response is null or empty!"); }  }
RemoteTimestampService { public TimestampResponseDTO getTimestampResponse(final DigestAlgorithm digestAlgorithm, final byte[] value) throws DSSException { Objects.requireNonNull(tspSource, "TSPSource must be not null!"); LOG.info("Timestamp request in process..."); Objects.requireNonNull(digestAlgorithm, "digestAlgorithm must be not null!"); Objects.requireNonNull(value, "value must be not null!"); TimestampBinary timestampBinary = tspSource.getTimeStampResponse(digestAlgorithm, value); if (timestampBinary != null && Utils.isArrayNotEmpty(timestampBinary.getBytes())) { LOG.info("Timestamp is obtained."); return toTimestampResponseDTO(timestampBinary); } throw new DSSException("The obtained TimestampToken response is null or empty!"); }  void setTSPSource(TSPSource tspSource); TimestampResponseDTO getTimestampResponse(final DigestAlgorithm digestAlgorithm, final byte[] value); }
RemoteTimestampService { public TimestampResponseDTO getTimestampResponse(final DigestAlgorithm digestAlgorithm, final byte[] value) throws DSSException { Objects.requireNonNull(tspSource, "TSPSource must be not null!"); LOG.info("Timestamp request in process..."); Objects.requireNonNull(digestAlgorithm, "digestAlgorithm must be not null!"); Objects.requireNonNull(value, "value must be not null!"); TimestampBinary timestampBinary = tspSource.getTimeStampResponse(digestAlgorithm, value); if (timestampBinary != null && Utils.isArrayNotEmpty(timestampBinary.getBytes())) { LOG.info("Timestamp is obtained."); return toTimestampResponseDTO(timestampBinary); } throw new DSSException("The obtained TimestampToken response is null or empty!"); }  void setTSPSource(TSPSource tspSource); TimestampResponseDTO getTimestampResponse(final DigestAlgorithm digestAlgorithm, final byte[] value);  }