net.sergeych.farcall.Connector, net.sergeych.farcall.Farcall.Targetpublic class BitrustedConnector
extends java.lang.Object
implements net.sergeych.farcall.Farcall.Target, net.sergeych.farcall.Connector
| Constructor | Description |
|---|---|
BitrustedConnector(PrivateKey myKey,
java.io.InputStream input,
java.io.OutputStream output) |
Create instance but does not start handshake.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
BitrustedConnector |
connect(java.util.function.Predicate<byte[]> isTrustedKey) |
|
int |
getHandshakeTimeoutMillis() |
|
SymmetricKey |
getMySessionKey() |
|
SymmetricKey |
getRemoteSessionKey() |
|
boolean |
isConnected() |
|
java.lang.Object |
onCommand(net.sergeych.farcall.Command command) |
The handshake and transport command processing
|
java.util.Map<java.lang.String,java.lang.Object> |
receive() |
|
void |
send(java.util.Map<java.lang.String,java.lang.Object> data) |
|
void |
setHandshakeTimeoutMillis(int handshakeTimeoutMillis) |
|
void |
setRemoteKey(@org.checkerframework.checker.nullness.qual.NonNull byte[] packedKey) |
Unpack the remote public key, check if it is trusted, if the
remoteKey is null, saves new value,
otherwise checks that it is the same key, or throws IllegalArgumentException. |
public BitrustedConnector(PrivateKey myKey, java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException
myKey - input - output - java.io.IOExceptionpublic void send(java.util.Map<java.lang.String,java.lang.Object> data)
throws java.io.IOException
send in interface net.sergeych.farcall.Connectorjava.io.IOExceptionpublic java.util.Map<java.lang.String,java.lang.Object> receive()
throws java.io.IOException
receive in interface net.sergeych.farcall.Connectorjava.io.IOExceptionpublic void close()
close in interface net.sergeych.farcall.Connectorpublic BitrustedConnector connect(java.util.function.Predicate<byte[]> isTrustedKey) throws com.icodici.crypto.BitrustedConnector.Error, java.util.concurrent.TimeoutException, java.lang.InterruptedException
com.icodici.crypto.BitrustedConnector.Errorjava.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionpublic boolean isConnected()
public java.lang.Object onCommand(net.sergeych.farcall.Command command)
throws java.lang.Exception
onCommand in interface net.sergeych.farcall.Farcall.Targetcommand - java.lang.Exceptionpublic int getHandshakeTimeoutMillis()
public void setHandshakeTimeoutMillis(int handshakeTimeoutMillis)
public SymmetricKey getMySessionKey()
public SymmetricKey getRemoteSessionKey()
public void setRemoteKey(@org.checkerframework.checker.nullness.qual.NonNull byte[] packedKey)
throws EncryptionError
remoteKey is null, saves new value,
otherwise checks that it is the same key, or throws IllegalArgumentException.
Set the remote key and accurately check that it was not spoofed, e.g. only one key could be set event several times. Because of the p2p nature of the connection we have no guarantee which way the remote key will arrive first (in the "hello" command from the remote or from the hello answer from the remote), this method allows to set the remote key in right mode.
packedKey - packed remoteKeyjava.lang.IllegalArgumentException - if the remoteKey is already set to a different key.EncryptionError