@Test public void addConfiguredTimestampingService() throws SystemService.DuplicateConfiguredTimestampingServiceException, TimestampingServiceNotFoundException { TspType tspType = TestUtils.createTspType(TSA_2_URL, TSA_2_NAME); assertEquals(1, serverConfService.getConfiguredTimestampingServices().size()); systemService.addConfiguredTimestampingService(tspType); assertEquals(2, serverConfService.getConfiguredTimestampingServices().size()); assertEquals(TSA_2_NAME, serverConfService.getConfiguredTimestampingServices().get(1).getName()); assertEquals(TSA_2_URL, serverConfService.getConfiguredTimestampingServices().get(1).getUrl()); }
public void addConfiguredTimestampingService(TspType tspTypeToAdd) throws TimestampingServiceNotFoundException, DuplicateConfiguredTimestampingServiceException { auditLog(tspTypeToAdd); Optional<TspType> match = globalConfService.getApprovedTspsForThisInstance().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (!match.isPresent()) { throw new TimestampingServiceNotFoundException(getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "not found")); } Optional<TspType> existingTsp = getConfiguredTimestampingServices().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (existingTsp.isPresent()) { throw new DuplicateConfiguredTimestampingServiceException( getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "is already configured") ); } serverConfService.getConfiguredTimestampingServices().add(tspTypeToAdd); }
SystemService { public void addConfiguredTimestampingService(TspType tspTypeToAdd) throws TimestampingServiceNotFoundException, DuplicateConfiguredTimestampingServiceException { auditLog(tspTypeToAdd); Optional<TspType> match = globalConfService.getApprovedTspsForThisInstance().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (!match.isPresent()) { throw new TimestampingServiceNotFoundException(getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "not found")); } Optional<TspType> existingTsp = getConfiguredTimestampingServices().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (existingTsp.isPresent()) { throw new DuplicateConfiguredTimestampingServiceException( getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "is already configured") ); } serverConfService.getConfiguredTimestampingServices().add(tspTypeToAdd); } }
SystemService { public void addConfiguredTimestampingService(TspType tspTypeToAdd) throws TimestampingServiceNotFoundException, DuplicateConfiguredTimestampingServiceException { auditLog(tspTypeToAdd); Optional<TspType> match = globalConfService.getApprovedTspsForThisInstance().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (!match.isPresent()) { throw new TimestampingServiceNotFoundException(getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "not found")); } Optional<TspType> existingTsp = getConfiguredTimestampingServices().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (existingTsp.isPresent()) { throw new DuplicateConfiguredTimestampingServiceException( getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "is already configured") ); } serverConfService.getConfiguredTimestampingServices().add(tspTypeToAdd); } @Autowired  SystemService(GlobalConfService globalConfService, ServerConfService serverConfService,
            AnchorRepository anchorRepository, ConfigurationVerifier configurationVerifier,
            CurrentSecurityServerId currentSecurityServerId,
            AuditDataHelper auditDataHelper); }
SystemService { public void addConfiguredTimestampingService(TspType tspTypeToAdd) throws TimestampingServiceNotFoundException, DuplicateConfiguredTimestampingServiceException { auditLog(tspTypeToAdd); Optional<TspType> match = globalConfService.getApprovedTspsForThisInstance().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (!match.isPresent()) { throw new TimestampingServiceNotFoundException(getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "not found")); } Optional<TspType> existingTsp = getConfiguredTimestampingServices().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (existingTsp.isPresent()) { throw new DuplicateConfiguredTimestampingServiceException( getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "is already configured") ); } serverConfService.getConfiguredTimestampingServices().add(tspTypeToAdd); } @Autowired  SystemService(GlobalConfService globalConfService, ServerConfService serverConfService,
            AnchorRepository anchorRepository, ConfigurationVerifier configurationVerifier,
            CurrentSecurityServerId currentSecurityServerId,
            AuditDataHelper auditDataHelper); List<TspType> getConfiguredTimestampingServices(); void addConfiguredTimestampingService(TspType tspTypeToAdd); void deleteConfiguredTimestampingService(TspType tspTypeToDelete); byte[] generateInternalCsr(String distinguishedName); AnchorFile getAnchorFile(); AnchorFile getAnchorFileFromBytes(byte[] anchorBytes, boolean shouldVerifyAnchorInstance); void uploadInitialAnchor(byte[] anchorBytes); void replaceAnchor(byte[] anchorBytes); boolean isAnchorImported(); byte[] readAnchorFile(); String getAnchorFilenameForDownload(); }
SystemService { public void addConfiguredTimestampingService(TspType tspTypeToAdd) throws TimestampingServiceNotFoundException, DuplicateConfiguredTimestampingServiceException { auditLog(tspTypeToAdd); Optional<TspType> match = globalConfService.getApprovedTspsForThisInstance().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (!match.isPresent()) { throw new TimestampingServiceNotFoundException(getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "not found")); } Optional<TspType> existingTsp = getConfiguredTimestampingServices().stream() .filter(tsp -> tspTypeToAdd.getName().equals(tsp.getName()) && tspTypeToAdd.getUrl().equals(tsp.getUrl())) .findFirst(); if (existingTsp.isPresent()) { throw new DuplicateConfiguredTimestampingServiceException( getExceptionMessage(tspTypeToAdd.getName(), tspTypeToAdd.getUrl(), "is already configured") ); } serverConfService.getConfiguredTimestampingServices().add(tspTypeToAdd); } @Autowired  SystemService(GlobalConfService globalConfService, ServerConfService serverConfService,
            AnchorRepository anchorRepository, ConfigurationVerifier configurationVerifier,
            CurrentSecurityServerId currentSecurityServerId,
            AuditDataHelper auditDataHelper); List<TspType> getConfiguredTimestampingServices(); void addConfiguredTimestampingService(TspType tspTypeToAdd); void deleteConfiguredTimestampingService(TspType tspTypeToDelete); byte[] generateInternalCsr(String distinguishedName); AnchorFile getAnchorFile(); AnchorFile getAnchorFileFromBytes(byte[] anchorBytes, boolean shouldVerifyAnchorInstance); void uploadInitialAnchor(byte[] anchorBytes); void replaceAnchor(byte[] anchorBytes); boolean isAnchorImported(); byte[] readAnchorFile(); String getAnchorFilenameForDownload();  }