use of com.walmartlabs.concord.common.secret.KeyPair in project concord by walmartlabs.
the class SecretManager method createKeyPair.
/**
* Stores a new SSH key pair using the provided public and private keys.
*/
public DecryptedKeyPair createKeyPair(UUID orgId, UUID projectId, String name, String storePassword, InputStream publicKey, InputStream privateKey, SecretVisibility visibility, String secretStoreType) throws IOException {
orgManager.assertAccess(orgId, true);
KeyPair k = buildKeyPair(publicKey, privateKey);
UUID id = create(name, orgId, projectId, k, storePassword, visibility, secretStoreType, INSERT);
return new DecryptedKeyPair(id, k.getPublicKey());
}
use of com.walmartlabs.concord.common.secret.KeyPair in project concord by walmartlabs.
the class SecretIT method testSecretPasswordUpdate.
@Test
public void testSecretPasswordUpdate() throws Exception {
String orgName = "org_" + randomString();
OrganizationsApi orgApi = new OrganizationsApi(getApiClient());
orgApi.createOrUpdate(new OrganizationEntry().setName(orgName));
// ---
String initPassword = "q1q1Q1Q1";
String secretName = "secret_" + randomString();
generateKeyPair(orgName, null, secretName, false, initPassword);
// ---
String newPassword = "q2q2Q2Q2";
UpdateSecretRequest request = UpdateSecretRequest.builder().currentPassword(initPassword).newPassword(newPassword).build();
// ---
SecretClient secretsApi = new SecretClient(getApiClient());
secretsApi.updateSecret(orgName, secretName, request);
KeyPair kp = secretsApi.getData(orgName, secretName, newPassword, SecretEntry.TypeEnum.KEY_PAIR);
assertNotNull(kp);
}
use of com.walmartlabs.concord.common.secret.KeyPair in project concord by walmartlabs.
the class SecretServiceImpl method exportKeyAsFile.
@Override
public Map<String, String> exportKeyAsFile(Context ctx, String instanceId, String workDir, String orgName, String name, String password) throws Exception {
KeyPair kp = get(ctx, orgName, name, password, SecretEntry.TypeEnum.KEY_PAIR);
Path baseDir = Paths.get(workDir);
Path tmpDir = assertTempDir(baseDir);
Path privateKey = Files.createTempFile(tmpDir, "private", ".key");
Files.write(privateKey, kp.getPrivateKey());
Path publicKey = Files.createTempFile(tmpDir, "public", ".key");
Files.write(publicKey, kp.getPublicKey());
Map<String, String> m = new HashMap<>();
m.put("private", baseDir.relativize(privateKey).toString());
m.put("public", baseDir.relativize(publicKey).toString());
return m;
}
Aggregations