Class ShipConnectionImpl
- java.lang.Object
-
- org.openmuc.jeebus.ship.shipconnection.ShipConnectionImpl
-
- All Implemented Interfaces:
ShipConnectionInterface,ShipConnection
public class ShipConnectionImpl extends java.lang.Object implements ShipConnection
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShipConnectionImpl.Role
-
Constructor Summary
Constructors Constructor Description ShipConnectionImpl(boolean server, int trustLevel, ShipNodeContext nodeContext, AuthenticatedConnection connection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()closes the connectionvoidcloseImmediately()voiddisableForcedTrustLevel()Stop forcing a trust level, relying instead on the trust level recorded for the peer's SKI in theKeyManagement.voiddistrustCommPartner()Set the communication partner to untrusted.voidenableConnectionDataExchange()ShipConnectionInterfacegetApiShipConn()ConnectionDataExchangegetCde()ConfigurationgetConfig()AuthenticatedConnectiongetConnection()java.lang.StringgetLogPrefix()java.lang.StringgetRemoteAddress()java.lang.StringgetRemoteSki()java.lang.StringgetSelectedFormat()intgetSelectedMajor()intgetSelectedMinor()StategetState()intgetTrustLevel()voidinitiateConnectionClose(java.lang.Integer maxTime, ConnectionCloseReasonType reason)voidinitState()Start up the SHIP state machine.booleanisConnectionCloseState()booleanisServer()voidonMessage(byte[] message)voidprepareCDEShutdown()voidrequestAccessMethods()requests access methods from client, only works as server, an exception is thrown otherwisevoidsendCdeMsg(byte[] msg)voidsendMsg(byte[] msg)sends a message to the communication partnervoidsendRawMessage(byte[] message)voidsetApiShipConn(ShipConnectionInterface shipConnInterface)voidsetConnection(AuthenticatedConnection basicCB)voidsetSelectedFormat(java.lang.String selectedFormat)voidsetSelectedMajor(int selectedMajor)voidsetSelectedMinor(int selectedMinor)voidsetSelectedVersion(int major, int minor)voidsetTrustLevel(int trustLevel)Set the trust level for this connection, overriding any trust level configured for the peer's SKI.voidsetUserInterface(UserInterface userInterface)voidstopStateTimeouts()voidtrustCommPartner()Set the communication partner to be trusted, allowing communication to proceed.booleantrustsCommPartner()
-
-
-
Constructor Detail
-
ShipConnectionImpl
public ShipConnectionImpl(boolean server, int trustLevel, ShipNodeContext nodeContext, AuthenticatedConnection connection)
-
-
Method Detail
-
initState
public void initState()
Description copied from interface:ShipConnectionStart up the SHIP state machine. Callable only once.- Specified by:
initStatein interfaceShipConnection
-
onMessage
public void onMessage(byte[] message)
-
isServer
public boolean isServer()
- Specified by:
isServerin interfaceShipConnection
-
getState
public State getState()
-
stopStateTimeouts
public void stopStateTimeouts()
-
initiateConnectionClose
public void initiateConnectionClose(java.lang.Integer maxTime, ConnectionCloseReasonType reason)
-
getTrustLevel
public int getTrustLevel()
- Specified by:
getTrustLevelin interfaceShipConnection
-
setTrustLevel
public void setTrustLevel(int trustLevel)
Set the trust level for this connection, overriding any trust level configured for the peer's SKI.- Parameters:
trustLevel- the trust level to set.- See Also:
disableForcedTrustLevel()
-
disableForcedTrustLevel
public void disableForcedTrustLevel()
Stop forcing a trust level, relying instead on the trust level recorded for the peer's SKI in theKeyManagement.- See Also:
setTrustLevel(int)
-
trustsCommPartner
public boolean trustsCommPartner()
-
trustCommPartner
public void trustCommPartner()
Set the communication partner to be trusted, allowing communication to proceed.This is only allowed if the trust level for this connection is ≥8.
-
distrustCommPartner
public void distrustCommPartner()
Set the communication partner to untrusted. This does not affect the trust level configured for this connection or for the partner's SKI.
-
getConnection
public AuthenticatedConnection getConnection()
-
setConnection
public void setConnection(AuthenticatedConnection basicCB)
-
getSelectedMajor
public int getSelectedMajor()
-
setSelectedMajor
public void setSelectedMajor(int selectedMajor)
-
getSelectedMinor
public int getSelectedMinor()
-
setSelectedMinor
public void setSelectedMinor(int selectedMinor)
-
setSelectedVersion
public void setSelectedVersion(int major, int minor)
-
getSelectedFormat
public java.lang.String getSelectedFormat()
-
setSelectedFormat
public void setSelectedFormat(java.lang.String selectedFormat)
-
getApiShipConn
public ShipConnectionInterface getApiShipConn()
-
setApiShipConn
public void setApiShipConn(ShipConnectionInterface shipConnInterface)
-
isConnectionCloseState
public boolean isConnectionCloseState()
-
getConfig
public Configuration getConfig()
-
getLogPrefix
public java.lang.String getLogPrefix()
-
getCde
public ConnectionDataExchange getCde()
-
requestAccessMethods
public void requestAccessMethods()
Description copied from interface:ShipConnectionInterfacerequests access methods from client, only works as server, an exception is thrown otherwise- Specified by:
requestAccessMethodsin interfaceShipConnectionInterface
-
enableConnectionDataExchange
public void enableConnectionDataExchange()
- Specified by:
enableConnectionDataExchangein interfaceShipConnection
-
sendCdeMsg
public void sendCdeMsg(byte[] msg)
-
setUserInterface
public void setUserInterface(UserInterface userInterface)
- Specified by:
setUserInterfacein interfaceShipConnection
-
getRemoteSki
public java.lang.String getRemoteSki()
- Specified by:
getRemoteSkiin interfaceShipConnectionInterface- Returns:
- the current SKI of the communication partner
-
getRemoteAddress
public java.lang.String getRemoteAddress()
- Specified by:
getRemoteAddressin interfaceShipConnectionInterface- Returns:
- the IP address of the communication partner
-
sendMsg
public void sendMsg(byte[] msg)
Description copied from interface:ShipConnectionInterfacesends a message to the communication partner- Specified by:
sendMsgin interfaceShipConnectionInterface- Parameters:
msg- the message to send
-
sendRawMessage
public void sendRawMessage(byte[] message)
- Specified by:
sendRawMessagein interfaceShipConnection
-
prepareCDEShutdown
public void prepareCDEShutdown()
-
closeImmediately
public void closeImmediately()
- Specified by:
closeImmediatelyin interfaceShipConnection
-
close
public void close()
Description copied from interface:ShipConnectionInterfacecloses the connection- Specified by:
closein interfaceShipConnectionInterface
-
-