@Test public void toTimestampTokenTest() throws Exception { TimestampDTO timestampDTO = new TimestampDTO(Utils.fromBase64(timestampBinaries), TimestampType.INDIVIDUAL_DATA_OBJECTS_TIMESTAMP); timestampDTO.setCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE); timestampDTO.setIncludes(Arrays.asList(new TimestampIncludeDTO("reference-id-1", true))); TimestampToken timestampToken = TimestampTokenConverter.toTimestampToken(timestampDTO); assertNotNull(timestampToken); assertEquals(TimestampType.INDIVIDUAL_DATA_OBJECTS_TIMESTAMP, timestampToken.getTimeStampType()); assertEquals(CanonicalizationMethod.INCLUSIVE, timestampToken.getCanonicalizationMethod()); assertEquals(1, timestampToken.getTimestampIncludes().size()); assertEquals("reference-id-1", timestampToken.getTimestampIncludes().get(0).getURI()); assertTrue(timestampToken.getTimestampIncludes().get(0).isReferencedData()); assertTrue(Arrays.equals(Utils.fromBase64(timestampBinaries), timestampToken.getEncoded())); }
public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } }
TimestampTokenConverter { public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } } }
TimestampTokenConverter { public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } }  }
TimestampTokenConverter { public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } }  static List<TimestampToken> toTimestampTokens(List<TimestampDTO> timestampDTOs); static TimestampToken toTimestampToken(TimestampDTO timestampDTO); static TimestampDTO toTimestampDTO(TimestampToken timestampToken); }
TimestampTokenConverter { public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } }  static List<TimestampToken> toTimestampTokens(List<TimestampDTO> timestampDTOs); static TimestampToken toTimestampToken(TimestampDTO timestampDTO); static TimestampDTO toTimestampDTO(TimestampToken timestampToken);  }