class SystemService {

    public void addConfiguredTimestampingService(TspType tspTypeToAdd)
            throws TimestampingServiceNotFoundException, DuplicateConfiguredTimestampingServiceException {
        auditLog(tspTypeToAdd);

        // Check that the timestamping service is an approved timestamping service
        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"));
        }

        // Check that the timestamping service is not already configured
        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 public  SystemService(GlobalConfService globalConfService, ServerConfService serverConfService,
            AnchorRepository anchorRepository, ConfigurationVerifier configurationVerifier,
            CurrentSecurityServerId currentSecurityServerId,
            AuditDataHelper auditDataHelper);

}