Package de.espirit.firstspirit.access
Class ConnectionManager
java.lang.Object
de.espirit.firstspirit.access.ConnectionManager
Factory for
Remember to connect to the server and close the connection afterwards:
connections
.
Example usage: Connection connection = ConnectionManager.getConnection("localhost", 8000, ConnectionManager.HTTP_MODE, "login", "password", );
Remember to connect to the server and close the connection afterwards:
try { connection.connect(); ... } catch (IOException e) { context.logError(e.getMessage()); } catch (AuthenticationException e) { context.logError(e.getMessage()); } catch (MaximumNumberOfSessionsExceededException e) { context.logError(e.getMessage()); } finally { try { connection.close(); } catch (IOException e) { context.logError(e.getMessage()); } }
- Since:
- 2.3
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An input stream for accessing client jars.static final class
Container for socket parameters. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Authentication method using the default admin as defined in the fs-jaas.conf.static final String
Authentication method using the client login as defined in the fs-jaas.conf.static final String
Authentication method using the default login as defined in the fs-jaas.conf.static final String
Authentication method using the system login as defined in the fs-jaas.conf.static final String
Authentication method using the Non-SSO-based web login as defined in the fs-jaas.conf.static final String
Authentication method using the SSO-based web login as defined in the fs-jaas.conf.static final byte
Default compression level.static final byte
Compression level for best compression.static final byte
Compression level for fastest compression.static final byte
Use this value to use communication without compression.static final byte
Deprecated, for removal: This API element is subject to removal in a future version.static final byte
Zstandard compression.static final byte
Use the X25519-ChaCha20-Poly1305 encryption type for communications.static final byte
Deprecated, for removal: This API element is subject to removal in a future version.since 5.2.230706, replaced byENCRYPTION_CHACHA20
static final byte
Use this value to use communication without encryption.static final byte
Use the TLS encryption type for communications.static byte
Default compression level for HTTP-mode.static byte
Default encryption level for HTTP-mode.static final int
User HTTP-mode for communicationstatic final String
Current package implementation revision.static byte
Default compression level for SOCKET-mode.static byte
Default encryption level for SOCKET-mode.static final int
Use Socket-Mode for communication -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull de.espirit.firstspirit.client.io.ServerCaller
createCaller
(String host, int port, int mode, String servletZone) Creates a server caller based on the given information.createLoginParams
(String user, String plainPassword) Creates a login parameter container based on the given user name and plain password.downloadClientJar
(String host, int port, int mode) Download fs-client.jar from serverdownloadClientJar
(String host, int port, int mode, String servletZone) Download fs-client.jar from serverstatic byte
getCompression
(int mode) Get the used compression for the specified connection mode.static Connection
getConnection
(String host, int port, int mode, @Nullable String servletzone, String module, CallbackHandler cbHandler) Create a connection accessor to a FirstSpirit server.static Connection
getConnection
(String host, int port, int mode, String login, String password) Create a connection to a FIRSTspirit server instance, the physical connection is not already established after this call.static Connection
getConnection
(String host, int port, int mode, String servletZone, String login, String password) Create a connection to a FIRSTspirit server instance, the physical connection is not already established after this call.static Connection
getConnection
(String host, int port, int mode, String servletZone, String login, Map<?, ?> loginParams) Create a connection to a FIRSTspirit server instance, the physical connection is not already established after this call.static Connection
getConnection
(String host, int port, int mode, String login, Map<?, ?> loginParams) Create a connection to a FIRSTspirit server instance, the physical connection is not already established after this call.static de.espirit.firstspirit.access.ExceptionHandler
Returns current defaultExceptionHandler
static byte
getEncryption
(int mode) Get the used encryption for the specified connection mode.static boolean
Indicates, whether to force connections.static de.espirit.firstspirit.access.Proxy
getProxy()
Get the proxy used for new connections.static boolean
Should https protocol be used for servlet communication.static void
Reset the used compression to default values.static void
Reset the used encryption to default values.static void
setCompression
(byte compression) Set the used compression.static void
setDefaultExceptionHandler
(de.espirit.firstspirit.access.ExceptionHandler handler) Sets the defaultExceptionHandler
for all connections without an own handler.static void
setEncryption
(byte encryption) Set the used encryption.static void
setProxy
(de.espirit.firstspirit.access.Proxy proxy) Set the proxy used for creating new connections.static void
setUseHttps
(boolean useHttps) Set if https protocol should be used for servlet communication.static void
testConnection
(String host, int port, int mode) Test connection parametersstatic void
testConnection
(String host, int port, int mode, String servletZone) Test connection parameters
-
Field Details
-
AUTH_DEFAULT
Authentication method using the default login as defined in the fs-jaas.conf.- Since:
- 4.0.17
- See Also:
-
AUTH_CLIENT
Authentication method using the client login as defined in the fs-jaas.conf.- Since:
- 4.0.17
- See Also:
-
AUTH_ADMIN
Authentication method using the default admin as defined in the fs-jaas.conf.- Since:
- 4.0.17
- See Also:
-
AUTH_SYSTEM
Authentication method using the system login as defined in the fs-jaas.conf.- Since:
- 4.0.17
- See Also:
-
AUTH_WEB_SSO
Authentication method using the SSO-based web login as defined in the fs-jaas.conf.- Since:
- 4.0.17
- See Also:
-
AUTH_WEB_NONSSO
Authentication method using the Non-SSO-based web login as defined in the fs-jaas.conf.- Since:
- 4.0.17
- See Also:
-
ENCRYPTION_NONE
public static final byte ENCRYPTION_NONEUse this value to use communication without encryption.- Since:
- 4.1.10
- See Also:
-
ENCRYPTION_TLS
public static final byte ENCRYPTION_TLSUse the TLS encryption type for communications.- Since:
- 4.1.10
- See Also:
-
ENCRYPTION_DH_ARC4
Deprecated, for removal: This API element is subject to removal in a future version.since 5.2.230706, replaced byENCRYPTION_CHACHA20
Use the Alleged RC4 encryption type for communications.- Since:
- 4.1.10
- See Also:
-
ENCRYPTION_CHACHA20
public static final byte ENCRYPTION_CHACHA20Use the X25519-ChaCha20-Poly1305 encryption type for communications.- Since:
- 5.2.230706
- See Also:
-
COMPRESSION_NONE
public static final byte COMPRESSION_NONEUse this value to use communication without compression.- Since:
- 4.1.10
- See Also:
-
COMPRESSION_DEFLATE
public static final byte COMPRESSION_DEFLATEDefault compression level.- Since:
- 4.1.10
- See Also:
-
COMPRESSION_DEFLATE_SPEED
public static final byte COMPRESSION_DEFLATE_SPEEDCompression level for fastest compression.- Since:
- 4.1.10
- See Also:
-
COMPRESSION_DEFLATE_BEST
public static final byte COMPRESSION_DEFLATE_BESTCompression level for best compression.- Since:
- 4.1.10
- See Also:
-
COMPRESSION_ZSTD
public static final byte COMPRESSION_ZSTDZstandard compression.- Since:
- 5.2.230702
- See Also:
-
COMPRESSION_SNAPPY
Deprecated, for removal: This API element is subject to removal in a future version.since 5.2.12, useCOMPRESSION_NONE
,COMPRESSION_DEFLATE_SPEED
, or any of the other compression flags instead.Snappy compression- Since:
- 5.0.100
- See Also:
-
REVISION
Current package implementation revision.- Since:
- 4.0.19
-
HTTP_MODE
public static final int HTTP_MODEUser HTTP-mode for communication- Since:
- 2.3
- See Also:
-
SOCKET_MODE
public static final int SOCKET_MODEUse Socket-Mode for communication- Since:
- 2.3
- See Also:
-
SOCKET_DEFAULT_COMPRESSION
public static byte SOCKET_DEFAULT_COMPRESSIONDefault compression level for SOCKET-mode.- Since:
- 5.0.100
-
SOCKET_DEFAULT_ENCRYPTION
public static byte SOCKET_DEFAULT_ENCRYPTIONDefault encryption level for SOCKET-mode.- Since:
- 5.0.100
-
HTTP_DEFAULT_COMPRESSION
public static byte HTTP_DEFAULT_COMPRESSIONDefault compression level for HTTP-mode.- Since:
- 5.0.100
-
HTTP_DEFAULT_ENCRYPTION
public static byte HTTP_DEFAULT_ENCRYPTIONDefault encryption level for HTTP-mode.- Since:
- 5.0.100
-
-
Method Details
-
getConnection
public static Connection getConnection(String host, int port, int mode, @Nullable @Nullable String servletzone, String module, CallbackHandler cbHandler) Create a connection accessor to a FirstSpirit server. To create the "physical" connection, you have to invokeConnection.connect()
at a later point.- Parameters:
host
- The name of the server's host to set up a connection for.port
- The port of the server to be used.mode
- The connection mode, one ofHTTP_MODE
orSOCKET_MODE
.servletzone
- The servlet zone to be used.module
- The login method to be used, as defined in the fs-jaas.conf.cbHandler
- The callback handler.- Since:
- 4.0.17
-
getConnection
public static Connection getConnection(String host, int port, int mode, String login, Map<?, ?> loginParams) Create a connection to a FIRSTspirit server instance, the physical connection is not already established after this call. Therefore you must callConnection.connect()
.- Parameters:
host
- hostnameport
- portmode
- connection mode, one ofHTTP_MODE
, orSOCKET_MODE
login
- login method (AuthenticationModule
).loginParams
- login parameters.- Returns:
- the connection, you have to call
Connection.connect()
to - Since:
- 4.0.17
-
getConnection
public static Connection getConnection(String host, int port, int mode, String servletZone, String login, Map<?, ?> loginParams) Create a connection to a FIRSTspirit server instance, the physical connection is not already established after this call. Therefore you must callConnection.connect()
.- Parameters:
host
- hostnameport
- portmode
- connection mode, one ofHTTP_MODE
, orSOCKET_MODE
servletZone
- servletzone, only used when mode isHTTP_MODE
login
- login method (AuthenticationModule
).loginParams
- login parameters.- Returns:
- the connection, you have to call
Connection.connect()
before you can use the connection - Since:
- 4.0.17
-
getConnection
public static Connection getConnection(String host, int port, int mode, String login, String password) Create a connection to a FIRSTspirit server instance, the physical connection is not already established after this call. Therefore you must callConnection.connect()
.- Parameters:
host
- hostnameport
- portmode
- connection mode, one ofHTTP_MODE
, orSOCKET_MODE
login
- unsernamepassword
- password- Returns:
- the connection, you have to call
Connection.connect()
to - Since:
- 2.3
-
getConnection
public static Connection getConnection(String host, int port, int mode, String servletZone, String login, String password) Create a connection to a FIRSTspirit server instance, the physical connection is not already established after this call. Therefore you must callConnection.connect()
.- Parameters:
host
- hostnameport
- portmode
- connection mode, one ofHTTP_MODE
, orSOCKET_MODE
servletZone
- servletzone, only used when mode isHTTP_MODE
login
- usernamepassword
- password- Returns:
- the connection, you have to call
Connection.connect()
before you can use the connection - Since:
- 2.3
-
getProxy
public static de.espirit.firstspirit.access.Proxy getProxy()Get the proxy used for new connections.- Returns:
- The proxy
- Since:
- 4.0.17
-
setProxy
public static void setProxy(de.espirit.firstspirit.access.Proxy proxy) Set the proxy used for creating new connections.- Parameters:
proxy
- The proxy- Since:
- 4.0.17
-
getEncryption
public static byte getEncryption(int mode) Get the used encryption for the specified connection mode.- Parameters:
mode
- connection mode, one ofHTTP_MODE
, orSOCKET_MODE
- Returns:
- the used encryption, one of
ENCRYPTION_NONE
,ENCRYPTION_TLS
,ENCRYPTION_CHACHA20
- Since:
- 4.0.17
-
setEncryption
public static void setEncryption(byte encryption) Set the used encryption. This method overrides the default encryption for all connection modes.- Parameters:
encryption
- the used encryption, one ofENCRYPTION_NONE
,ENCRYPTION_TLS
,ENCRYPTION_CHACHA20
- Since:
- 4.0.17
-
resetEncryption
public static void resetEncryption()Reset the used encryption to default values.- Since:
- 4.0.17
-
setCompression
public static void setCompression(byte compression) Set the used compression. This method overrides the default compression for all connection modes.- Parameters:
compression
- the used compression, one ofCOMPRESSION_NONE
,COMPRESSION_DEFLATE
,COMPRESSION_DEFLATE_BEST
,COMPRESSION_DEFLATE_SPEED
,COMPRESSION_ZSTD
- Since:
- 4.0.17
-
resetCompression
public static void resetCompression()Reset the used compression to default values.- Since:
- 4.0.17
-
getUseHttps
public static boolean getUseHttps()Should https protocol be used for servlet communication.- Since:
- 4.0.120
-
setUseHttps
public static void setUseHttps(boolean useHttps) Set if https protocol should be used for servlet communication.- Since:
- 4.0.120
-
getCompression
public static byte getCompression(int mode) Get the used compression for the specified connection mode.- Parameters:
mode
- connection mode, one ofHTTP_MODE
, orSOCKET_MODE
- Returns:
- the used compression, one of
COMPRESSION_NONE
,COMPRESSION_DEFLATE
,COMPRESSION_DEFLATE_BEST
,COMPRESSION_DEFLATE_SPEED
- Since:
- 4.0.17
-
testConnection
Test connection parameters- Parameters:
host
- The host o connect toport
- The server portmode
- The connection mode- Throws:
VersionMismatchException
- Throw if client has wrong versionIOException
- Thrown if there is a communication problem- Since:
- 4.0.17
-
testConnection
public static void testConnection(String host, int port, int mode, String servletZone) throws IOException Test connection parameters- Parameters:
host
- The host to connect toport
- The server portmode
- The connection modeservletZone
- The servletzone- Throws:
VersionMismatchException
- Throw if client has wrong versionIOException
- Thrown if there is a communication problem- Since:
- 4.0.17
-
downloadClientJar
public static ConnectionManager.ClientJarInputStream downloadClientJar(String host, int port, int mode) throws IOException Download fs-client.jar from server- Parameters:
host
- The server host nameport
- The server portmode
- The connection mode- Returns:
- A InputStream for reading the jar file data
- Throws:
IOException
- Thrown if there is a communication problem- Since:
- 4.0.17
-
downloadClientJar
public static ConnectionManager.ClientJarInputStream downloadClientJar(String host, int port, int mode, String servletZone) throws IOException Download fs-client.jar from server- Parameters:
host
- The server host nameport
- The server portmode
- The connection modeservletZone
- The servletzone- Returns:
- A InputStream for reading the jar file data
- Throws:
IOException
- Thrown if there is a communication problem- Since:
- 4.0.17
-
createCaller
@NotNull public static @NotNull de.espirit.firstspirit.client.io.ServerCaller createCaller(String host, int port, int mode, String servletZone) Creates a server caller based on the given information.- Parameters:
host
- The server host name.port
- The server port.mode
- The connection mode, one ofHTTP_MODE
orSOCKET_MODE
.servletZone
- The servlet zone.- Returns:
- A server caller.
- Since:
- 4.0.17
-
getForceConnect
public static boolean getForceConnect()Indicates, whether to force connections.- Returns:
true
, if to force connections.- Since:
- 4.0.17
-
createLoginParams
Creates a login parameter container based on the given user name and plain password.- Parameters:
user
- The user's name.plainPassword
- The plain given password.- Returns:
- A container to be used for transporting login information.
- Since:
- 4.0.17
-
getDefaultExceptionHandler
public static de.espirit.firstspirit.access.ExceptionHandler getDefaultExceptionHandler()Returns current defaultExceptionHandler
- Returns:
- current default
ExceptionHandler
. - Since:
- 4.0.17
-
setDefaultExceptionHandler
public static void setDefaultExceptionHandler(de.espirit.firstspirit.access.ExceptionHandler handler) Sets the defaultExceptionHandler
for all connections without an own handler.- Parameters:
handler
- new default handler.- Since:
- 4.0.17
-
COMPRESSION_NONE
,COMPRESSION_DEFLATE_SPEED
, or any of the other compression flags instead.