-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add host key information for better host key verification
- Loading branch information
Showing
3 changed files
with
126 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/com/github/sparsick/testcontainers/gitserver/SshHostKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.github.sparsick.testcontainers.gitserver; | ||
|
||
import java.util.Objects; | ||
|
||
|
||
/** | ||
* Value object for SSH Host key information. | ||
*/ | ||
public class SshHostKey { | ||
|
||
private String hostname; | ||
private byte[] key; | ||
|
||
/** | ||
* SSH Host Key information | ||
* @param hostname host | ||
* @param key keystring | ||
*/ | ||
public SshHostKey(String hostname, byte[] key) { | ||
this.key = key; | ||
this.hostname = hostname; | ||
} | ||
|
||
/** | ||
* Public key of the host key. | ||
* | ||
* @return key string | ||
*/ | ||
public byte[] getKey() { | ||
return key; | ||
} | ||
|
||
/** | ||
* Name of the host | ||
* | ||
* @return name of the host | ||
*/ | ||
public String getHostname() { | ||
return hostname; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof SshHostKey)) return false; | ||
SshHostKey hostKey = (SshHostKey) o; | ||
return Objects.equals(key, hostKey.key) && Objects.equals(hostname, hostKey.hostname); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(key, hostname); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HostKey{" + | ||
"key='" + key + '\'' + | ||
", hostname='" + hostname + '\'' + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters