Class AbstractGatewayConnection
java.lang.Object
com.inductiveautomation.ignition.client.gateway_interface.AbstractGatewayConnection
- All Implemented Interfaces:
GatewayConnection
,GatewayInterface.GatewayExceptionMonitor
,PushNotificationListener
,GatewayConstants
,EventListener
- Direct Known Subclasses:
ClientGatewayConnection
,DesignerGatewayConnection
public abstract class AbstractGatewayConnection
extends Object
implements GatewayConstants, GatewayConnection, PushNotificationListener, GatewayInterface.GatewayExceptionMonitor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PropertyChangeSupport
static final String
static final String
static final String
static final String
protected int
protected HttpURL
The current address that we are communicating withA list of all gateway addresses that were passed in.protected String
protected TimeZone
static final String
protected ScopeVersionHash
protected int
static final String
protected LaunchContext
protected EventListenerList
protected static final org.apache.log4j.Logger
Used for internal logging ONLY.static final String
static final String
static final String
protected int
static final String
static final String
static final String
protected int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Fields inherited from interface com.inductiveautomation.ignition.common.gateway.GatewayConstants
_DATE_FORMATTER, ARG_MESSAGETYPE, ARG_MODULEID, ATR_INDEX, ATR_LENGTH, ATR_NAME, ATR_TYPE, booleanNull, byteNull, charNull, CONNECT_TIMEOUT, DATE_FORMAT_STRING, doubleNull, ELM_ARG, ELM_COLLIST, ELM_COLUMN, ELM_COMPRESSEDROWS, ELM_DATA, ELM_ERRORCODE, ELM_ERRORMESSAGE, ELM_EXCLS, ELM_EXMSG, ELM_EXOVERRIDES_TOSTRING, ELM_EXSTRING, ELM_MBODY, ELM_MESSAGE, ELM_MTYPE, ELM_NOTIFICATION, ELM_NOTIFICATIONS, ELM_RESPONSE, ELM_ROW, ELM_ROWS, ELM_SERIALIZED_RESPONSE, ELM_SETCOOKIE, ELM_STACKTRACE, ELM_STELM, ELM_STELM_DECL, ELM_STELM_FILE, ELM_STELM_LINE, ELM_STELM_METH, ERRNO_ASYNC_CALL, ERRNO_ASYNC_CALL_CANCELED, ERRNO_ASYNC_CALL_FAILED, ERRNO_BROWSE_ERROR, ERRNO_COMM_ERROR, ERRNO_CONNECTION_MODE, ERRNO_DBCONNECTION_NAMING, ERRNO_DBCONNECTION_SQL, ERRNO_HISTORY_QUERY_ERROR, ERRNO_INSECURE_REDIRECT, ERRNO_INTERNAL, ERRNO_INVALIDARGS, ERRNO_INVOCATION_EXCEPTION, ERRNO_LICENE_RESTRICTED, ERRNO_LOGIN_CANCELLED, ERRNO_LOGIN_FAILED, ERRNO_LOGIN_FAILED_LICENSING, ERRNO_NAMING, ERRNO_NO_SESSION, ERRNO_NON_ACTIVE_NODE, ERRNO_NON_MASTER_NODE, ERRNO_NOT_AUTHORIZED, ERRNO_NOTIMP, ERRNO_OK, ERRNO_PARSE, ERRNO_PASSWORD_EXPIRED, ERRNO_PONG, ERRNO_POST_ERROR, ERRNO_PROJECT_PULL, ERRNO_PROJECT_PUSH, ERRNO_RUNTIME_EXPIRED, ERRNO_SQL, ERRNO_SQLTAGS_PROVIDER_DISABLED, ERRNO_SQLTAGS_PROVIDER_FAULTED, ERRNO_SQLTAGS_PROVIDER_LOADING, ERRNO_SQLTAGS_PROVIDER_MISSING, ERRNO_SQLTAGS_SEND_TAGS, ERRNO_SSL_REQUIRED, ERRNO_TIMEOUT, ERRNO_TRIAL_EXPIRED, ERRNO_VERSION_INCOMPATABILITY, ERROR_MESSAGE_TYPE, floatNull, intNull, longNull, MODE_DISCONNECTED, MODE_FULL, MODE_READ_ONLY, MTYPE_COPY_IMAGE, MTYPE_CREATE_IMAGE_FOLDER, MTYPE_DBTEST, MTYPE_GET_NEW_RESOURCEID, MTYPE_INVALID, MTYPE_INVOKE_FUNCTION, MTYPE_LIST_AUTHS, MTYPE_LIST_COLS, MTYPE_LIST_DBS, MTYPE_LIST_IDPS, MTYPE_LIST_IMAGES, MTYPE_LIST_MODULES, MTYPE_LIST_ROLES, MTYPE_LIST_SECURITY_LEVELS, MTYPE_LIST_SQLTAG_PROVIDERS, MTYPE_LIST_TABLES, MTYPE_LIST_ZONES, MTYPE_PING, MTYPE_PLATFORM_EDITION, MTYPE_PUBLIC_PING, MTYPE_REMOVE_IMAGE, MTYPE_RENAME_IMAGE_FOLDER, MTYPE_REPORT_ERROR, MTYPE_SEND_EMAIL, MTYPE_SQLTAGS_ADD_SCANCLASS, MTYPE_SQLTAGS_ADD_TAGS, MTYPE_SQLTAGS_EDIT_SCANCLASS, MTYPE_SQLTAGS_EDIT_TAGS, MTYPE_SQLTAGS_ERROR_LIST, MTYPE_SQLTAGS_FSQL_BROWSE, MTYPE_SQLTAGS_FSQL_LIST, MTYPE_SQLTAGS_GET_SCANCLASS, MTYPE_SQLTAGS_LIST, MTYPE_SQLTAGS_META_LIST, MTYPE_SQLTAGS_POLL, MTYPE_SQLTAGS_REMOVE_SCANCLASS, MTYPE_SQLTAGS_REMOVE_TAGS, MTYPE_SQLTAGS_WRITE, MTYPE_STATUS_POLL, MTYPE_UPLOAD_IMAGE, MTYPE_VERSION_CHECK, OPC_BROWSE_TIMEOUT, PROTECT_DIALOG_TYPE, shortNull, SOCKET_TIMEOUT, WARNING_MESSAGE_TYPE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnectionListener
(ConnectionListener listener) void
Different from the ConnectionListener in the sense that this listener is intended for use in redundant setups, where the status of the inactive connection must be updated along with the status of the active connection.void
void
addPropertyChangeListener
(String propName, PropertyChangeListener l) void
void
Connect to the gateway(s) specifiedvoid
protected abstract org.apache.commons.lang3.tuple.Pair<AuthenticatedUser,
String> doIdpLoginFinish
(String projectName) protected abstract AuthenticatedUser
doLogin
(GatewayInterface gatewayInterface, String projectName, AuthChallenge challenge) protected abstract org.apache.commons.lang3.tuple.Pair<AuthenticatedUser,
String> doTokenLogin
(GatewayInterface gatewayInterface, String projectName, String encodedAuthToken) protected void
fireConnectionEvent
(String message) protected void
fireConnectionEvent
(String messageLookup, HttpURL gatewayAddr, boolean appendGatewayAddr) Overloaded method to allow a gateway's connection status to be updated.protected void
fireConnectionEvent
(String messageLookup, HttpURL gatewayAddr, Exception ex, boolean appendGatewayAddr) Overloaded method to allow a gateway's connection status to be updated.protected void
protected void
fishForAliveServer
(boolean reLogin) Synchronized method- Tests communication with known servers, and sets the gateway interface to the first gateway that in can connect to.Returns a list of all possible Gateway addresses that are known to the client.The encrypted auth challenge that was used to log inint
Returns the current connection mode: MODE_FULL MODE_READ_ONLY MODE_DISCONNECTEDint
protected String
Returns the address of the gateway that is currently being communicated with.Returns the string version of the currently connected gateway's "Node Role", which will be one of: Independent Master BackupReturns the url to the web portion of the gateway, like "http[s]://<address>:<port>[/context]"int
The number of concurrent HTTP connections allowed.int
Platform edition.The name of the project that we are currently logged into, if any.getRoles()
The set of roles that the actively logged in user has, if any.Returns "http" or "https" depending on our transport schemeprotected abstract int
getScope()
Returns the scope for this connection.The set of security zones that the actively logged in user has, if any.int
The username of the actively logged in user, if any.idpLoginFinish
(String projectName) boolean
Whether or not we are currently supposed to be in a connected state.static boolean
boolean
boolean
boolean
boolean
login
(String projectName, AuthChallenge challenge) void
logout()
protected GatewayInterface
newGatewayInterface
(HttpURL addr) Creates a new GatewayInterface for the given URL, settings its connect and socket timeouts appropriatelyvoid
protected abstract void
protected abstract void
Called when the version is detected to have changed on the gateway.void
receiveNotification
(PushNotification notification) void
removeConnectionListener
(ConnectionListener listener) void
void
void
removePropertyChangeListener
(String propName, PropertyChangeListener l) void
void
Removes all PushNotificationListeners that are of same class as the passed class.protected void
setConnected
(boolean connected) void
setConnectionMode
(int connectionMode) protected void
setConnectionUp
(boolean connectionUp) Synchronized methodvoid
setConnectTimeout
(int connectTimeout) protected void
Sets the new gateway interface, and adds this as a gateway exception listener and a push notification listener.void
setHttpConcurrency
(int concurrency) protected void
setIndependentAddressList
(List<HttpURL> addresses, boolean reLogin) void
setOpcBrowseTimeout
(int opcBrowseTimeout) protected void
setProjectName
(String projectName) void
setSocketTimeout
(int socketTimeout) tokenLogin
(String projectName, String encodedAuthToken) protected String
Returns the HttpURL with the correct security scheme, like: "https://myserver:443/ContextPath"void
Manually update the status of all connection listeners.protected boolean
void
updateBackupAddresses
(List<HttpURL> list) Synchronized methodvoid
Updates the gateway timezone and role infovoid
updateMasterAddresses
(List<HttpURL> list) Synchronized methodMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.inductiveautomation.ignition.client.gateway_interface.GatewayConnection
idpLoginStart
-
Field Details
-
REDUNDANT_MASTER
-
REDUNDANT_BACKUP
-
INDEPENDENT
- See Also:
-
CONNECT_UNKNOWN
- See Also:
-
CONNECTING
- See Also:
-
CONNECT_SUCCESS
- See Also:
-
CONNECT_FAIL
- See Also:
-
RELOGIN
- See Also:
-
NON_ACTIVE
- See Also:
-
NEW_ADDRESSES
- See Also:
-
NO_NEW_ADDRESSES
- See Also:
-
GET_ADDRESSES_ERROR
- See Also:
-
STATUS_CONNECT_UNKNOWN
public static final int STATUS_CONNECT_UNKNOWN- See Also:
-
STATUS_CONNECTING
public static final int STATUS_CONNECTING- See Also:
-
STATUS_CONNECTED
public static final int STATUS_CONNECTED- See Also:
-
STATUS_CONNECT_FAIL
public static final int STATUS_CONNECT_FAIL- See Also:
-
STATUS_CONNECT_INACTIVE
public static final int STATUS_CONNECT_INACTIVE- See Also:
-
STATUS_CONNECTED_INCOMPATIBLE
public static final int STATUS_CONNECTED_INCOMPATIBLE- See Also:
-
STATUS_CONNECT_WARNING
public static final int STATUS_CONNECT_WARNING- See Also:
-
log
protected static final org.apache.log4j.Logger log -
LOGGER_STATUS_LOOKUP
Used for internal logging ONLY. Do not use to display messages to the user, as these strings are not internationalized. -
connectTimeout
protected int connectTimeout -
socketTimeout
protected int socketTimeout -
opcBrowseTimeout
protected int opcBrowseTimeout -
httpConcurrency
protected int httpConcurrency -
changeSupport
-
listenerList
-
currentAddress
The current address that we are communicating with -
gatewayAddresses
A list of all gateway addresses that were passed in. The client starts in independent mode and cycles thru these addresses in the fishForAliveServer() method. The addresses are used later if a version mismatch exception is thrown when reconnecting to a gateway. Redundant master and backup addresses are not maintained in this list. They are held in the potentialMasterList and potentialBackup list respectively. -
launchContext
-
gatewayTimeZone
-
gatewayNodeRole
-
hash
-
-
Constructor Details
-
AbstractGatewayConnection
-
-
Method Details
-
getEncodedAuthToken
-
connect
Description copied from interface:GatewayConnection
Connect to the gateway(s) specified- Specified by:
connect
in interfaceGatewayConnection
-
disconnect
public void disconnect()- Specified by:
disconnect
in interfaceGatewayConnection
-
setIndependentAddressList
protected void setIndependentAddressList(List<HttpURL> addresses, boolean reLogin) throws AbstractGatewayConnection.UnrecoverableIdpAuthSessionException, VersionMismatchException -
newGatewayInterface
Creates a new GatewayInterface for the given URL, settings its connect and socket timeouts appropriately -
getScope
protected abstract int getScope()Returns the scope for this connection. Used to create an accurate version hash. -
updateMasterAddresses
Synchronized method -
updateBackupAddresses
Synchronized method -
fishForAliveServer
protected void fishForAliveServer(boolean reLogin) throws AbstractGatewayConnection.UnrecoverableIdpAuthSessionException, VersionMismatchException Synchronized method- Tests communication with known servers, and sets the gateway interface to the first gateway that in can connect to. For redundant connections, this method also sets the gateway interface to either the last known master or the last known backup in a connection failure scenario. The connection status of the master and the backup is determined in a separate thread in the RedundancyMonitorTask. -
tryToLogin
protected boolean tryToLogin() throws AbstractGatewayConnection.UnrecoverableIdpAuthSessionException -
setGatewayInterface
Sets the new gateway interface, and adds this as a gateway exception listener and a push notification listener. Also updates the gateway timezone. -
updateGatewayMetaInfo
public void updateGatewayMetaInfo()Updates the gateway timezone and role info -
getGatewayNodeRole
Description copied from interface:GatewayConnection
Returns the string version of the currently connected gateway's "Node Role", which will be one of:- Independent
- Master
- Backup
- Specified by:
getGatewayNodeRole
in interfaceGatewayConnection
-
doLogin
protected abstract AuthenticatedUser doLogin(GatewayInterface gatewayInterface, String projectName, AuthChallenge challenge) throws GatewayException - Throws:
GatewayException
-
login
- Specified by:
login
in interfaceGatewayConnection
- Throws:
GatewayException
-
doTokenLogin
protected abstract org.apache.commons.lang3.tuple.Pair<AuthenticatedUser,String> doTokenLogin(GatewayInterface gatewayInterface, String projectName, String encodedAuthToken) throws GatewayException - Throws:
GatewayException
-
tokenLogin
public AuthenticatedUser tokenLogin(String projectName, String encodedAuthToken) throws GatewayException - Specified by:
tokenLogin
in interfaceGatewayConnection
- Throws:
GatewayException
-
doIdpLoginFinish
protected abstract org.apache.commons.lang3.tuple.Pair<AuthenticatedUser,String> doIdpLoginFinish(String projectName) throws GatewayException - Throws:
GatewayException
-
idpLoginFinish
- Specified by:
idpLoginFinish
in interfaceGatewayConnection
- Throws:
GatewayException
-
logout
public void logout()- Specified by:
logout
in interfaceGatewayConnection
-
setConnectionUp
protected void setConnectionUp(boolean connectionUp) Synchronized method -
onVersionMismatch
protected abstract void onVersionMismatch()Called when the version is detected to have changed on the gateway. Connection will be closed at this point. -
onUnrecoverableIdpAuthSession
protected abstract void onUnrecoverableIdpAuthSession() -
notifyGatewayException
- Specified by:
notifyGatewayException
in interfaceGatewayInterface.GatewayExceptionMonitor
-
receiveNotification
- Specified by:
receiveNotification
in interfacePushNotificationListener
-
isConnectionRelated
-
getConnectionMode
public int getConnectionMode()Description copied from interface:GatewayConnection
Returns the current connection mode:- MODE_FULL
- MODE_READ_ONLY
- MODE_DISCONNECTED
- Specified by:
getConnectionMode
in interfaceGatewayConnection
-
setConnectionMode
public void setConnectionMode(int connectionMode) - Specified by:
setConnectionMode
in interfaceGatewayConnection
-
getAllAddresses
Description copied from interface:GatewayConnection
Returns a list of all possible Gateway addresses that are known to the client. This list includes redundant master and backup addresses. The list is used for client restarts.- Specified by:
getAllAddresses
in interfaceGatewayConnection
-
getGatewayAddress
Description copied from interface:GatewayConnection
Returns the address of the gateway that is currently being communicated with.- Specified by:
getGatewayAddress
in interfaceGatewayConnection
-
getGatewayInterface
- Specified by:
getGatewayInterface
in interfaceGatewayConnection
-
getGatewayWebURL
Description copied from interface:GatewayConnection
Returns the url to the web portion of the gateway, like "http[s]://<address>:<port>[/context]"- Specified by:
getGatewayWebURL
in interfaceGatewayConnection
-
getScheme
Description copied from interface:GatewayConnection
Returns "http" or "https" depending on our transport scheme- Specified by:
getScheme
in interfaceGatewayConnection
-
getGatewayTimeZone
- Specified by:
getGatewayTimeZone
in interfaceGatewayConnection
-
isConnectionUp
public boolean isConnectionUp()- Specified by:
isConnectionUp
in interfaceGatewayConnection
-
isSessionValid
public boolean isSessionValid()- Specified by:
isSessionValid
in interfaceGatewayConnection
-
isConnected
public boolean isConnected()Whether or not we are currently supposed to be in a connected state. If this is true and connectionUp is false, then we are reconnecting- Specified by:
isConnected
in interfaceGatewayConnection
-
setConnected
protected void setConnected(boolean connected) -
toString
Returns the HttpURL with the correct security scheme, like: "https://myserver:443/ContextPath" -
addPushNotificationListener
- Specified by:
addPushNotificationListener
in interfaceGatewayConnection
-
removePushNotificationListener
- Specified by:
removePushNotificationListener
in interfaceGatewayConnection
-
removePushNotificationListeners
Removes all PushNotificationListeners that are of same class as the passed class.- Specified by:
removePushNotificationListeners
in interfaceGatewayConnection
- Parameters:
c
- The type of listener to remove
-
firePushNotification
-
addPropertyChangeListener
- Specified by:
addPropertyChangeListener
in interfaceGatewayConnection
-
removePropertyChangeListener
- Specified by:
removePropertyChangeListener
in interfaceGatewayConnection
-
addPropertyChangeListener
- Specified by:
addPropertyChangeListener
in interfaceGatewayConnection
-
removePropertyChangeListener
- Specified by:
removePropertyChangeListener
in interfaceGatewayConnection
-
addConnectionListener
- Specified by:
addConnectionListener
in interfaceGatewayConnection
-
removeConnectionListener
- Specified by:
removeConnectionListener
in interfaceGatewayConnection
-
fireConnectionEvent
protected void fireConnectionEvent(String messageLookup, HttpURL gatewayAddr, boolean appendGatewayAddr) Overloaded method to allow a gateway's connection status to be updated. A BundleUtil lookup is made to get the actual string from the passed lookup. Be sure that the actual string returned from lookup contains at least one '%s' to display the gateway address. This method will also update the internal masterConnectionStatus and backupConnectionStatus variables for redundant systems, and the connectionStatus variable for independent systems. -
fireConnectionEvent
protected void fireConnectionEvent(String messageLookup, HttpURL gatewayAddr, Exception ex, boolean appendGatewayAddr) Overloaded method to allow a gateway's connection status to be updated. A BundleUtil lookup is made to get the actual string from the passed lookup. Be sure that the actual string returned from lookup contains at least one '%s' to display the gateway address. This method will also update the internal masterConnectionStatus and backupConnectionStatus variables for redundant systems, and the connectionStatus variable for independent systems.- Parameters:
messageLookup
- the String to pass to BundleUtil.get(), such as "GatewayConnectionManager.TestingWith"gatewayAddr
- the Gateway HttpURL used in the connection eventex
- exception that has just occurred. Pass in null if there were no exceptions thrown.
-
fireConnectionEvent
-
isLoggedIn
public boolean isLoggedIn() -
getProjectName
Description copied from interface:GatewayConnection
The name of the project that we are currently logged into, if any.- Specified by:
getProjectName
in interfaceGatewayConnection
-
getUsername
Description copied from interface:GatewayConnection
The username of the actively logged in user, if any.- Specified by:
getUsername
in interfaceGatewayConnection
-
getAuthChallenge
Description copied from interface:GatewayConnection
The encrypted auth challenge that was used to log in- Specified by:
getAuthChallenge
in interfaceGatewayConnection
-
getRoles
Description copied from interface:GatewayConnection
The set of roles that the actively logged in user has, if any.- Specified by:
getRoles
in interfaceGatewayConnection
-
getSecurityZones
Description copied from interface:GatewayConnection
The set of security zones that the actively logged in user has, if any.- Specified by:
getSecurityZones
in interfaceGatewayConnection
-
getConnectTimeout
public int getConnectTimeout()- Specified by:
getConnectTimeout
in interfaceGatewayConnection
-
setConnectTimeout
public void setConnectTimeout(int connectTimeout) - Specified by:
setConnectTimeout
in interfaceGatewayConnection
-
getSocketTimeout
public int getSocketTimeout()- Specified by:
getSocketTimeout
in interfaceGatewayConnection
-
setSocketTimeout
public void setSocketTimeout(int socketTimeout) - Specified by:
setSocketTimeout
in interfaceGatewayConnection
-
getOpcBrowseTimeout
public int getOpcBrowseTimeout()- Specified by:
getOpcBrowseTimeout
in interfaceGatewayConnection
-
setOpcBrowseTimeout
public void setOpcBrowseTimeout(int opcBrowseTimeout) - Specified by:
setOpcBrowseTimeout
in interfaceGatewayConnection
-
getHttpConcurrency
public int getHttpConcurrency()Description copied from interface:GatewayConnection
The number of concurrent HTTP connections allowed. 0 or less means unlimited.- Specified by:
getHttpConcurrency
in interfaceGatewayConnection
-
setHttpConcurrency
public void setHttpConcurrency(int concurrency) - Specified by:
setHttpConcurrency
in interfaceGatewayConnection
-
setProjectName
-
addConnectionStatusListener
Description copied from interface:GatewayConnection
Different from the ConnectionListener in the sense that this listener is intended for use in redundant setups, where the status of the inactive connection must be updated along with the status of the active connection. The passed ConnectionStatusListener will be continually updated with master/independent and backup connection status every few seconds.- Specified by:
addConnectionStatusListener
in interfaceGatewayConnection
-
removeConnectionStatusListener
- Specified by:
removeConnectionStatusListener
in interfaceGatewayConnection
-
triggerConnectionStatusListeners
public void triggerConnectionStatusListeners()Description copied from interface:GatewayConnection
Manually update the status of all connection listeners. Use this in situations where listeners need an immediate update without waiting for the normal thread task to fire (such as when first displaying a status panel).- Specified by:
triggerConnectionStatusListeners
in interfaceGatewayConnection
-
getPlatformEdition
Description copied from interface:GatewayConnection
Platform edition. Standard edition = "", Edge edition = "edge"- Specified by:
getPlatformEdition
in interfaceGatewayConnection
-
getEdgeProjectName
- Specified by:
getEdgeProjectName
in interfaceGatewayConnection
- Returns:
- the name of the Edge project as defined by the user on the edge gateway settings
- Throws:
GatewayException
-
isPlatformLicensed
public boolean isPlatformLicensed()- Specified by:
isPlatformLicensed
in interfaceGatewayConnection
-