bug4811: trim \n off public key output in REST API; add time point to generated SSH public key comment

This commit is contained in:
Axel Uhl committed 2021-01-21 22:53:34 +01:00
1 parent 91e3e50ac7
commit dfebfa60a9
2 files changed
+5 -3

No files matched your search

@@ -226,9 +226,10 @@ implements AwsLandscape<ShardingKey, MetricsT, ProcessT> {
final KeyPair keyPair = KeyPair.load(new JSch(), privKey, /* pubkey */ null); // private key is unencrypted so far; public key can be obtained:
final String creatorName = principal==null?"":principal.toString();
final ByteArrayOutputStream publicKeyBytes = new ByteArrayOutputStream();
keyPair.writePublicKey(publicKeyBytes, "public key generated by user "+creatorName);
final TimePoint now = TimePoint.now();
keyPair.writePublicKey(publicKeyBytes, "public key generated by user "+creatorName+" at "+now);
final SSHKeyPair result = new SSHKeyPair(region.getId(), creatorName,
TimePoint.now(), keyPairResponse.keyName(), publicKeyBytes.toByteArray(), privKey,
now, keyPairResponse.keyName(), publicKeyBytes.toByteArray(), privKey,
privateKeyEncryptionPassphrase);
addSSHKeyPair(result);
return result;
@@ -19,7 +19,8 @@ public class SSHKeyPairJsonSerializer implements JsonSerializer<SSHKeyPair> {
result.put(REGION_ID_FIELD, object.getRegionId());
result.put(CREATOR_NAME_FIELD, object.getCreatorName());
result.put(CREATION_TIME_MILLIS_FIELD, object.getCreationTime().asMillis());
result.put(PUBLIC_KEY_FIELD, object.getPublicKey() == null ? null : new String(object.getPublicKey()));
result.put(PUBLIC_KEY_FIELD, object.getPublicKey() == null ? null : new String(object.getPublicKey())
.trim().replaceFirst("\n$", ""));
return result;
}
}