@Test public void createClientDropsEmptyStringSpiffeId() throws Exception { clientDAO.createClient("firstWithoutSpiffe", "creator2", "", new URI("")); clientDAO.createClient("secondWithoutSpiffe", "creator2", "", new URI("")); }
public long createClient(String name, String user, String description, @Nullable URI spiffeId) { ClientsRecord r = dslContext.newRecord(CLIENTS); long now = OffsetDateTime.now().toEpochSecond(); long generatedId = rowHmacGenerator.getNextLongSecure(); String rowHmac = rowHmacGenerator.computeRowHmac( CLIENTS.getName(), List.of(name, generatedId)); String spiffeStr = null; if (spiffeId != null && !spiffeId.toASCIIString().isEmpty()) { spiffeStr = spiffeId.toASCIIString(); } r.setId(generatedId); r.setName(name); r.setCreatedby(user); r.setCreatedat(now); r.setUpdatedby(user); r.setUpdatedat(now); r.setLastseen(null); r.setDescription(description); r.setEnabled(true); r.setAutomationallowed(false); r.setSpiffeId(spiffeStr); r.setRowHmac(rowHmac); r.store(); return r.getId(); }
ClientDAO { public long createClient(String name, String user, String description, @Nullable URI spiffeId) { ClientsRecord r = dslContext.newRecord(CLIENTS); long now = OffsetDateTime.now().toEpochSecond(); long generatedId = rowHmacGenerator.getNextLongSecure(); String rowHmac = rowHmacGenerator.computeRowHmac( CLIENTS.getName(), List.of(name, generatedId)); String spiffeStr = null; if (spiffeId != null && !spiffeId.toASCIIString().isEmpty()) { spiffeStr = spiffeId.toASCIIString(); } r.setId(generatedId); r.setName(name); r.setCreatedby(user); r.setCreatedat(now); r.setUpdatedby(user); r.setUpdatedat(now); r.setLastseen(null); r.setDescription(description); r.setEnabled(true); r.setAutomationallowed(false); r.setSpiffeId(spiffeStr); r.setRowHmac(rowHmac); r.store(); return r.getId(); } }
ClientDAO { public long createClient(String name, String user, String description, @Nullable URI spiffeId) { ClientsRecord r = dslContext.newRecord(CLIENTS); long now = OffsetDateTime.now().toEpochSecond(); long generatedId = rowHmacGenerator.getNextLongSecure(); String rowHmac = rowHmacGenerator.computeRowHmac( CLIENTS.getName(), List.of(name, generatedId)); String spiffeStr = null; if (spiffeId != null && !spiffeId.toASCIIString().isEmpty()) { spiffeStr = spiffeId.toASCIIString(); } r.setId(generatedId); r.setName(name); r.setCreatedby(user); r.setCreatedat(now); r.setUpdatedby(user); r.setUpdatedat(now); r.setLastseen(null); r.setDescription(description); r.setEnabled(true); r.setAutomationallowed(false); r.setSpiffeId(spiffeStr); r.setRowHmac(rowHmac); r.store(); return r.getId(); } private  ClientDAO(DSLContext dslContext, ClientMapper clientMapper,
      RowHmacGenerator rowHmacGenerator); }
ClientDAO { public long createClient(String name, String user, String description, @Nullable URI spiffeId) { ClientsRecord r = dslContext.newRecord(CLIENTS); long now = OffsetDateTime.now().toEpochSecond(); long generatedId = rowHmacGenerator.getNextLongSecure(); String rowHmac = rowHmacGenerator.computeRowHmac( CLIENTS.getName(), List.of(name, generatedId)); String spiffeStr = null; if (spiffeId != null && !spiffeId.toASCIIString().isEmpty()) { spiffeStr = spiffeId.toASCIIString(); } r.setId(generatedId); r.setName(name); r.setCreatedby(user); r.setCreatedat(now); r.setUpdatedby(user); r.setUpdatedat(now); r.setLastseen(null); r.setDescription(description); r.setEnabled(true); r.setAutomationallowed(false); r.setSpiffeId(spiffeStr); r.setRowHmac(rowHmac); r.store(); return r.getId(); } private  ClientDAO(DSLContext dslContext, ClientMapper clientMapper,
      RowHmacGenerator rowHmacGenerator); long createClient(String name, String user, String description,
      @Nullable URI spiffeId); void deleteClient(Client client); void sawClient(Client client, @Nullable Principal principal); Optional<Client> getClientByName(String name); Optional<Client> getClientBySpiffeId(URI spiffeId); Optional<Client> getClientById(long id); ImmutableSet<Client> getClients(); }
ClientDAO { public long createClient(String name, String user, String description, @Nullable URI spiffeId) { ClientsRecord r = dslContext.newRecord(CLIENTS); long now = OffsetDateTime.now().toEpochSecond(); long generatedId = rowHmacGenerator.getNextLongSecure(); String rowHmac = rowHmacGenerator.computeRowHmac( CLIENTS.getName(), List.of(name, generatedId)); String spiffeStr = null; if (spiffeId != null && !spiffeId.toASCIIString().isEmpty()) { spiffeStr = spiffeId.toASCIIString(); } r.setId(generatedId); r.setName(name); r.setCreatedby(user); r.setCreatedat(now); r.setUpdatedby(user); r.setUpdatedat(now); r.setLastseen(null); r.setDescription(description); r.setEnabled(true); r.setAutomationallowed(false); r.setSpiffeId(spiffeStr); r.setRowHmac(rowHmac); r.store(); return r.getId(); } private  ClientDAO(DSLContext dslContext, ClientMapper clientMapper,
      RowHmacGenerator rowHmacGenerator); long createClient(String name, String user, String description,
      @Nullable URI spiffeId); void deleteClient(Client client); void sawClient(Client client, @Nullable Principal principal); Optional<Client> getClientByName(String name); Optional<Client> getClientBySpiffeId(URI spiffeId); Optional<Client> getClientById(long id); ImmutableSet<Client> getClients();  }