Search in sources :

Example 1 with ClientsRecord

use of keywhiz.jooq.tables.records.ClientsRecord in project keywhiz by square.

the class ClientDAO method createClient.

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));
    // Do not allow empty spiffe URIs
    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();
}
Also used : ClientsRecord(keywhiz.jooq.tables.records.ClientsRecord)

Example 2 with ClientsRecord

use of keywhiz.jooq.tables.records.ClientsRecord in project keywhiz by square.

the class ClientDAO method createClient.

public long createClient(String name, String user, String description) {
    ClientsRecord r = dslContext.newRecord(CLIENTS);
    long now = OffsetDateTime.now().toEpochSecond();
    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.store();
    return r.getId();
}
Also used : ClientsRecord(keywhiz.jooq.tables.records.ClientsRecord)

Aggregations

ClientsRecord (keywhiz.jooq.tables.records.ClientsRecord)2