Search in sources :

Example 1 with SecretMetadata

use of io.cdap.cdap.securestore.spi.secret.SecretMetadata 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 SecretMetadata

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

the class SecretManagerSecureStoreService method list.

@Override
public List<SecureStoreMetadata> list(String namespace) throws Exception {
    validate(namespace);
    List<SecureStoreMetadata> metadataList = new ArrayList<>();
    for (SecretMetadata metadata : secretManager.list(namespace)) {
        metadataList.add(new SecureStoreMetadata(metadata.getName(), metadata.getDescription(), metadata.getCreationTimeMs(), metadata.getProperties()));
    }
    return metadataList;
}
Also used : SecureStoreMetadata(io.cdap.cdap.api.security.store.SecureStoreMetadata) SecretMetadata(io.cdap.cdap.securestore.spi.secret.SecretMetadata) ArrayList(java.util.ArrayList)

Example 3 with SecretMetadata

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

the class CloudSecretManager method list.

@Override
public Collection<SecretMetadata> list(String namespace) throws IOException {
    Collection<SecretInfo> secretInfos = store.list(namespace, encoderDecoder);
    List<SecretMetadata> metadataList = new ArrayList<>();
    for (SecretInfo secretInfo : secretInfos) {
        metadataList.add(new SecretMetadata(secretInfo.getName(), secretInfo.getDescription(), secretInfo.getCreationTimeMs(), secretInfo.getProperties()));
    }
    return metadataList;
}
Also used : SecretMetadata(io.cdap.cdap.securestore.spi.secret.SecretMetadata) ArrayList(java.util.ArrayList)

Example 4 with SecretMetadata

use of io.cdap.cdap.securestore.spi.secret.SecretMetadata 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 5 with SecretMetadata

use of io.cdap.cdap.securestore.spi.secret.SecretMetadata 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

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