Package com.streambase.sb.client
Class StreamBaseURI
java.lang.Object
com.streambase.sb.client.StreamBaseURI
A Uniform Resource Identifier containing information necessary
to connect to a StreamBase server. For more information about
URIs, please see the StreamBase documentation.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default container ("default")static final String
The default StreamBase server ("localhost").static final int
The default StreamBase TCP port number (10000).static final StreamBaseURI
The default URI (sb://localhost:10000/) pointing to localhost, no container, port 10000).static final String
URI parameter used for the passphrase for a key within a keystore for SSL with client authentication (2-way ssl).static final String
default keypass maskstatic final String
URI parameter used for a keystore for SSL with client authentication (2-way ssl).static final String
URI parameter used for the passphrase for a keystore for SSL with client authentication (2-way ssl).default set of parameter containing sensitive datastatic final String
No container specified ("")static final String
URI parameter used for password.static final String
URI parameter used internally as part of container table connection logicstatic final String
URI parameter used for secondary host name.static final String
URI parameter used for secondary port name.static final String
URI parameter used internally (only) as part of container stream connection logicstatic final String
The system container ("system")static final String
That environment variable used to define the uri to the serverstatic final String
That java property used to define the uri to the serverstatic final String
URI parameter used for username. -
Constructor Summary
ConstructorDescriptionStreamBaseURI
(String uri) Constructor that parses a StreamBase URI passed in as a String.StreamBaseURI
(String host, int port) Constructor roughly equivalent tonew StreamBaseURI("sb://host:port/")
.StreamBaseURI
(String host, int port, Map<String, String> params) Equivalent to StreamBaseURI(host, NO_CONTAINER, port, params)StreamBaseURI
(String host, String container, int port) Constructor roughly equivalent tonew StreamBaseURI("sb://host:port/container")
.Constructor roughly equivalent tonew StreamBaseURI("scheme://host:port/container;param1=value1(...)")
, where scheme is either "sb" or "sbs" depending on whether useSSL is true or false, and param1=value1(...)StreamBaseURI
(String host, String container, int port, String user, String password) Constructor roughly equivalent tonew StreamBaseURI("sb://host:port/container;user=user;password=password")
.Equivalent to StreamBaseURI(host, container, port, false, params) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares this URI against the supplied one.static StreamBaseURI
Returns the URI found by searching the following property and environment variables: Using the string value found in thestreambase.uri
system property, if set Using the string value found in theSTREAMBASE_URI
environment variable, if set Using the string value found in theSTREAMBASE_SERVER
environment variable, if setDEFAULT_URI
if no value has been found aboveReturn a copy of this URI without any paramsReturns a Base64-encoded username + password if authentication is enabled, or null otherwise.Returns the container name component of the URI.getHost()
Returns the host name component of the URI.Return the passphrase for the key within the keystore for the connection.Return the keystore for the connection.Return the passphrase for the keystore for the connection.int
Return the number of URI parametersReturns a parameter with a given key, or null if none exists.getParameter
(String key) Returns a parameter with a given key, or null if none exists.Returns an unmodifiable map of all parameters.Return the password for the connection.int
getPort()
Returns the port number.getUser()
Return the user name for the connection.static boolean
boolean
isSSL()
static List<StreamBaseURI>
Returns the list of URIs found by searching the following property and environment variables for a comma separated URI list: Using the string value found in thestreambase.uri
system property, if set Using the string value found in theSTREAMBASE_URI
environment variable, if set Using the string value found in theSTREAMBASE_SERVER
environment variable, if setDEFAULT_URI
if no value has been above The supplied URIs must conform to a valid High Availability URI list, for example they must all reference the same container.static List<StreamBaseURI>
listFromString
(String uriStrings) Parse a comma-separated list of URIs in a string into a List<StreamBaseURI>.LiketoString()
except that all sensitive data defined in the setMASKED_PARAMS
are masked withKEY_PASSWORD_MASK
static String
toSafeString
(Collection<StreamBaseURI> uris) Create a string representation of a list of uris, that is safe for logging.toString()
Returns a string representation of the URI.static String
toString
(Collection<StreamBaseURI> uris) Create a string representation of a list of uris.
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORTThe default StreamBase TCP port number (10000).- See Also:
-
DEFAULT_HOST
The default StreamBase server ("localhost").- See Also:
-
DEFAULT_CONTAINER
The default container ("default")- See Also:
-
SYSTEM_CONTAINER
The system container ("system")- See Also:
-
NO_CONTAINER
No container specified ("")- See Also:
-
DEFAULT_URI
The default URI (sb://localhost:10000/) pointing to localhost, no container, port 10000). -
USER_PARAM
URI parameter used for username.- See Also:
-
PASSWORD_PARAM
URI parameter used for password.- See Also:
-
SECONDARY_HOST_PARAM
URI parameter used for secondary host name. ("host2")- See Also:
-
SECONDARY_PORT_PARAM
URI parameter used for secondary port name. ("port2")- See Also:
-
KEYSTORE_PARAM
URI parameter used for a keystore for SSL with client authentication (2-way ssl). ("keystore")- See Also:
-
KEYSTORE_PASS_PARAM
URI parameter used for the passphrase for a keystore for SSL with client authentication (2-way ssl). ("keystorepass")- See Also:
-
KEY_PASS_PARAM
URI parameter used for the passphrase for a key within a keystore for SSL with client authentication (2-way ssl). ("keypass")- See Also:
-
STREAM_PARAM
URI parameter used internally (only) as part of container stream connection logic- See Also:
-
QT_PARAM
URI parameter used internally as part of container table connection logic- See Also:
-
URI_PROPERTY_NAME
That java property used to define the uri to the server- See Also:
-
URI_ENVIRONMENT_VARIABLE
That environment variable used to define the uri to the server- See Also:
-
KEY_PASSWORD_MASK
default keypass mask- See Also:
-
MASKED_PARAMS
default set of parameter containing sensitive data
-
-
Constructor Details
-
StreamBaseURI
Constructor that parses a StreamBase URI passed in as a String. The format for a StreamBase URI is:scheme://host[:port][/container][/][[;param=value]...]
- scheme: use
sb
orsbs
, the latter to enable a secure SSL connection - host: an ip address or hostname of the target server
- port: (optional) target TCP port number, defaults to
DEFAULT_PORT
- container: (optional) target container name, defaults to
NO_CONTAINER
- ;param=value: (optional) each occurrence sets a key/value parameter mapping for additional arguments; unknown arguments result in a URIException being thrown. Refer to the documentation or the public constants defined in StreamBaseURI ending in _PARAM for valid parameter names
- Parameters:
uri
- a URI to parse- Throws:
URIException
- if the URI syntax is invalid, or if an unknown parameter name is found
- scheme: use
-
StreamBaseURI
Constructor roughly equivalent tonew StreamBaseURI("sb://host:port/container")
.- Parameters:
host
- a host name to connect tocontainer
- a container to connect toport
- a port number to connect to- See Also:
-
StreamBaseURI
Constructor roughly equivalent tonew StreamBaseURI("sb://host:port/")
.- Parameters:
host
- a host name to connect toport
- a port number to connect to- See Also:
-
StreamBaseURI
Constructor roughly equivalent tonew StreamBaseURI("sb://host:port/container;user=user;password=password")
.- Parameters:
host
- a host name to connect tocontainer
- a container to connect toport
- a port number to connect touser
- a user name for the connectionpassword
- a password for the connection- See Also:
-
StreamBaseURI
public StreamBaseURI(String host, String container, int port, boolean useSSL, Map<String, String> params) Constructor roughly equivalent tonew StreamBaseURI("scheme://host:port/container;param1=value1(...)")
, where scheme is either "sb" or "sbs" depending on whether useSSL is true or false, and param1=value1(...) stands for every entry in theparams
Map- Parameters:
host
- a host name to connect tocontainer
- a container to connect toport
- a port number to connect touseSSL
- whether to use an SSL connection to the server or notparams
- a Map of String parameters for the URI, or null to indicate no parameters. This map is not checked for correctness.
-
StreamBaseURI
Equivalent to StreamBaseURI(host, container, port, false, params)- Parameters:
host
- a host name to connect tocontainer
- a container to connect toport
- a port number to connect toparams
- a Map of String parameters for the URI, or null to indicate no parameters. This map is not checked for correctness.- See Also:
-
StreamBaseURI
Equivalent to StreamBaseURI(host, NO_CONTAINER, port, params)- Parameters:
host
- a host name to connect toport
- a port number to connect toparams
- a Map of String parameters for the URI, or null to indicate no parameters. This map is not checked for correctness.- See Also:
-
-
Method Details
-
listFromString
Parse a comma-separated list of URIs in a string into a List<StreamBaseURI>. The string of URIs supplied must conform to a valid HA URI list, for example they must all reference the same container.- Parameters:
uriStrings
-- Returns:
- list of StreamBaseURI's
- Throws:
URIException
-
toString
Create a string representation of a list of uris.
Use
toSafeString(Collection)
if sensitive data need to be masked.- Parameters:
uris
-- Returns:
- string representation of a list of uris
- Since:
- 6.1
-
toSafeString
Create a string representation of a list of uris, that is safe for logging. SeesafeString()
- Parameters:
uris
-- Returns:
- string representation of a list of uris
- Since:
- 10.4
-
toString
Returns a string representation of the URI.
Log messages should use
safeString()
instead, where sensitive data are masked. -
safeString
LiketoString()
except that all sensitive data defined in the setMASKED_PARAMS
are masked withKEY_PASSWORD_MASK
-
getBaseURI
Return a copy of this URI without any params -
getHost
Returns the host name component of the URI. -
getContainer
Returns the container name component of the URI. May return an empty string if no container was specified. -
getPort
public int getPort()Returns the port number. -
getParam
Returns a parameter with a given key, or null if none exists.- Parameters:
key
- the key for the parameter or null if not found
-
getParameter
Returns a parameter with a given key, or null if none exists.- Parameters:
key
- the key for the parameter or null if not found
-
getNumParameters
public int getNumParameters()Return the number of URI parameters- Returns:
- number of URI parameters
-
getParams
Returns an unmodifiable map of all parameters. -
getUser
Return the user name for the connection.- Returns:
- The user name for the connection, or
null
if none.
-
getPassword
Return the password for the connection.- Returns:
- The password for the connection, or
null
if none.
-
getKeystore
Return the keystore for the connection.- Returns:
- The keystore for the connection, or
null
if none.
-
getKeystorePassphrase
Return the passphrase for the keystore for the connection.- Returns:
- The passphrase for the keystore for the connection, or
null
if none.
-
getKeyPassphrase
Return the passphrase for the key within the keystore for the connection.- Returns:
- The passphrase for the key within the keystore for the connection, or
null
if none. - Since:
- 7.3.10
-
isSSL
public boolean isSSL()- Returns:
- true if this is an SSL URI.
-
fromEnvironment
Returns the URI found by searching the following property and environment variables:- Using the string value found in the
streambase.uri
system property, if set - Using the string value found in the
STREAMBASE_URI
environment variable, if set - Using the string value found in the
STREAMBASE_SERVER
environment variable, if set DEFAULT_URI
if no value has been found above
- Throws:
URIException
- if the URI found in any of the search locations is invalid
- Using the string value found in the
-
listFromEnvironment
Returns the list of URIs found by searching the following property and environment variables for a comma separated URI list:- Using the string value found in the
streambase.uri
system property, if set - Using the string value found in the
STREAMBASE_URI
environment variable, if set - Using the string value found in the
STREAMBASE_SERVER
environment variable, if set DEFAULT_URI
if no value has been above
- Throws:
URIException
- if any URI found is invalid
- Using the string value found in the
-
getBasicAuthenticationString
Returns a Base64-encoded username + password if authentication is enabled, or null otherwise. -
equals
Compares this URI against the supplied one. Note that the host names must textually match exactly (i.e., no cleverness is applied to implement "host equality"). -
hasPrefix
- Parameters:
s
-- Returns:
- true iff the supplied string looks like the beginning of a StreamBase URI
-