Search in sources :

Example 1 with Secret

use of io.cdap.cdap.securestore.spi.secret.Secret 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);
    }
}
Also used : Secret(io.cdap.cdap.securestore.spi.secret.Secret) SecureStoreData(io.cdap.cdap.api.security.store.SecureStoreData) SecureKeyId(io.cdap.cdap.proto.id.SecureKeyId) SecureStoreMetadata(io.cdap.cdap.api.security.store.SecureStoreMetadata) SecretMetadata(io.cdap.cdap.securestore.spi.secret.SecretMetadata) SecureKeyNotFoundException(io.cdap.cdap.common.SecureKeyNotFoundException) SecretNotFoundException(io.cdap.cdap.securestore.spi.SecretNotFoundException)

Example 2 with Secret

use of io.cdap.cdap.securestore.spi.secret.Secret in project cdap by caskdata.

the class CloudSecretManager method get.

@Override
public Secret get(String namespace, String name) throws SecretNotFoundException, IOException {
    SecretInfo secretInfo = store.get(namespace, name, encoderDecoder);
    byte[] decrypted = client.decrypt(CRYPTO_KEY_PREFIX + namespace, secretInfo.getSecretData());
    return new Secret(decrypted, new SecretMetadata(secretInfo.getName(), secretInfo.getDescription(), secretInfo.getCreationTimeMs(), secretInfo.getProperties()));
}
Also used : Secret(io.cdap.cdap.securestore.spi.secret.Secret) SecretMetadata(io.cdap.cdap.securestore.spi.secret.SecretMetadata)

Example 3 with Secret

use of io.cdap.cdap.securestore.spi.secret.Secret in project cdap by caskdata.

the class SecretManagerSecureStoreService method put.

@Override
public void put(String namespace, String name, String data, @Nullable String description, Map<String, String> properties) throws Exception {
    validate(namespace);
    secretManager.store(namespace, new Secret(data.getBytes(StandardCharsets.UTF_8), new SecretMetadata(name, description, System.currentTimeMillis(), ImmutableMap.copyOf(properties))));
}
Also used : Secret(io.cdap.cdap.securestore.spi.secret.Secret) SecretMetadata(io.cdap.cdap.securestore.spi.secret.SecretMetadata)

Aggregations

Secret (io.cdap.cdap.securestore.spi.secret.Secret)3 SecretMetadata (io.cdap.cdap.securestore.spi.secret.SecretMetadata)3 SecureStoreData (io.cdap.cdap.api.security.store.SecureStoreData)1 SecureStoreMetadata (io.cdap.cdap.api.security.store.SecureStoreMetadata)1 SecureKeyNotFoundException (io.cdap.cdap.common.SecureKeyNotFoundException)1 SecureKeyId (io.cdap.cdap.proto.id.SecureKeyId)1 SecretNotFoundException (io.cdap.cdap.securestore.spi.SecretNotFoundException)1