use of io.cdap.cdap.securestore.spi.SecretNotFoundException in project cdap by caskdata.
the class DefaultSecretStore method delete.
@Override
public void delete(String namespace, String name) throws SecretNotFoundException, IOException {
TransactionRunners.run(transactionRunner, context -> {
StructuredTable table = context.getTable(StoreDefinition.SecretStore.SECRET_STORE_TABLE);
List<Field<?>> keyFields = ImmutableList.<Field<?>>builder().addAll(getKeyFields(namespace, name)).build();
if (!table.read(keyFields).isPresent()) {
throw new SecretNotFoundException(namespace, name);
}
table.delete(keyFields);
}, SecretNotFoundException.class, IOException.class);
}
use of io.cdap.cdap.securestore.spi.SecretNotFoundException in project cdap by caskdata.
the class DefaultSecretStore method get.
@Override
public <T> T get(String namespace, String name, Decoder<T> decoder) throws SecretNotFoundException, IOException {
return TransactionRunners.run(transactionRunner, context -> {
StructuredTable table = context.getTable(StoreDefinition.SecretStore.SECRET_STORE_TABLE);
List<Field<?>> keyFields = ImmutableList.<Field<?>>builder().addAll(getKeyFields(namespace, name)).build();
Optional<StructuredRow> optionalRow = table.read(keyFields);
if (!optionalRow.isPresent()) {
throw new SecretNotFoundException(namespace, name);
}
StructuredRow row = optionalRow.get();
return decoder.decode(row.getBytes(StoreDefinition.SecretStore.SECRET_DATA_FIELD));
}, SecretNotFoundException.class, IOException.class);
}
use of io.cdap.cdap.securestore.spi.SecretNotFoundException in project cdap by caskdata.
the class SecretManagerSecureStoreService method get.
@Override
public SecureStoreData get(String namespace, String name) throws Exception {
validate(namespace);
try {
Secret secret = secretManager.get(namespace, name);
SecretMetadata metadata = secret.getMetadata();
return new SecureStoreData(new SecureStoreMetadata(metadata.getName(), metadata.getDescription(), metadata.getCreationTimeMs(), metadata.getProperties()), secret.getData());
} catch (SecretNotFoundException e) {
throw new SecureKeyNotFoundException(new SecureKeyId(namespace, name), e);
}
}
Aggregations