Search in sources :

Example 1 with SecretsContentRecord

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

the class SecretContentDAO method createSecretContent.

public long createSecretContent(long secretId, String encryptedContent, String hmac, String creator, Map<String, String> metadata, long expiry) {
    SecretsContentRecord r = dslContext.newRecord(SECRETS_CONTENT);
    String jsonMetadata;
    try {
        jsonMetadata = mapper.writeValueAsString(metadata);
    } catch (JsonProcessingException e) {
        // Serialization of a Map<String, String> can never fail.
        throw Throwables.propagate(e);
    }
    long now = OffsetDateTime.now().toEpochSecond();
    r.setSecretid(secretId);
    r.setEncryptedContent(encryptedContent);
    r.setContentHmac(hmac);
    r.setCreatedby(creator);
    r.setCreatedat(now);
    r.setUpdatedby(creator);
    r.setUpdatedat(now);
    r.setMetadata(jsonMetadata);
    r.setExpiry(expiry);
    r.store();
    pruneOldContents(secretId);
    return r.getId();
}
Also used : SecretsContentRecord(keywhiz.jooq.tables.records.SecretsContentRecord) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 SecretsContentRecord (keywhiz.jooq.tables.records.SecretsContentRecord)1