use of org.apache.sshd.common.util.buffer.Buffer in project gerrit by GerritCodeReview.
the class SshDaemon method computeHostKeys.
private List<HostKey> computeHostKeys() {
if (listen.isEmpty()) {
return Collections.emptyList();
}
final List<PublicKey> keys = myHostKeys();
final List<HostKey> r = new ArrayList<>();
for (final PublicKey pub : keys) {
final Buffer buf = new ByteArrayBuffer();
buf.putRawPublicKey(pub);
final byte[] keyBin = buf.getCompactData();
for (final String addr : advertised) {
try {
r.add(new HostKey(addr, keyBin));
} catch (JSchException e) {
sshDaemonLog.warn(String.format("Cannot format SSHD host key [%s]: %s", pub.getAlgorithm(), e.getMessage()));
}
}
}
return Collections.unmodifiableList(r);
}
use of org.apache.sshd.common.util.buffer.Buffer in project gitblit by gitblit.
the class SshKey method getRawData.
public String getRawData() {
if (rawData == null && publicKey != null) {
// build the raw data manually from the public key
Buffer buf = new ByteArrayBuffer();
// 1: identify the algorithm
buf.putRawPublicKey(publicKey);
String alg = buf.getString();
// 2: encode the key
buf.clear();
buf.putPublicKey(publicKey);
String b64 = Base64.encodeBase64String(buf.getBytes());
String c = getComment();
rawData = alg + " " + b64 + (StringUtils.isEmpty(c) ? "" : (" " + c));
}
return rawData;
}
Aggregations