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
FieldsModifier and TypeFieldDescriptionstatic final StringThe default container ("default")static final StringThe default StreamBase server ("localhost").static final intThe default StreamBase TCP port number (10000).static final StreamBaseURIThe default URI (sb://localhost:10000/) pointing to localhost, no container, port 10000).static final StringURI parameter used for the passphrase for a key within a keystore for SSL with client authentication (2-way ssl).static final Stringdefault keypass maskstatic final StringURI parameter used for a keystore for SSL with client authentication (2-way ssl).static final StringURI parameter used for the passphrase for a keystore for SSL with client authentication (2-way ssl).default set of parameter containing sensitive datastatic final StringNo container specified ("")static final StringURI parameter used for password.static final StringURI parameter used internally as part of container table connection logicstatic final StringURI parameter used for secondary host name.static final StringURI parameter used for secondary port name.static final StringURI parameter used internally (only) as part of container stream connection logicstatic final StringThe system container ("system")static final StringThat environment variable used to define the uri to the serverstatic final StringThat java property used to define the uri to the serverstatic final StringURI parameter used for username. -
Constructor Summary
ConstructorsConstructorDescriptionStreamBaseURI(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 TypeMethodDescriptionbooleanCompares this URI against the supplied one.static StreamBaseURIReturns the URI found by searching the following property and environment variables: Using the string value found in thestreambase.urisystem property, if set Using the string value found in theSTREAMBASE_URIenvironment variable, if set Using the string value found in theSTREAMBASE_SERVERenvironment variable, if setDEFAULT_URIif 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.intReturn 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.intgetPort()Returns the port number.getUser()Return the user name for the connection.static booleanbooleanisSSL()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.urisystem property, if set Using the string value found in theSTREAMBASE_URIenvironment variable, if set Using the string value found in theSTREAMBASE_SERVERenvironment variable, if setDEFAULT_URIif 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_PARAMSare masked withKEY_PASSWORD_MASKstatic StringtoSafeString(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 StringtoString(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
-
DEFAULT_CONTAINER
-
SYSTEM_CONTAINER
-
NO_CONTAINER
-
DEFAULT_URI
The default URI (sb://localhost:10000/) pointing to localhost, no container, port 10000). -
USER_PARAM
-
PASSWORD_PARAM
-
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
-
MASKED_PARAMS
-
-
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
sborsbs, 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
-
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 theparamsMap- 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_PARAMSare 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
-
getParameter
-
getNumParameters
public int getNumParameters()Return the number of URI parameters- Returns:
- number of URI parameters
-
getParams
-
getUser
Return the user name for the connection.- Returns:
- The user name for the connection, or
nullif none.
-
getPassword
Return the password for the connection.- Returns:
- The password for the connection, or
nullif none.
-
getKeystore
Return the keystore for the connection.- Returns:
- The keystore for the connection, or
nullif none.
-
getKeystorePassphrase
Return the passphrase for the keystore for the connection.- Returns:
- The passphrase for the keystore for the connection, or
nullif 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
nullif 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.urisystem property, if set - Using the string value found in the
STREAMBASE_URIenvironment variable, if set - Using the string value found in the
STREAMBASE_SERVERenvironment variable, if set DEFAULT_URIif 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.urisystem property, if set - Using the string value found in the
STREAMBASE_URIenvironment variable, if set - Using the string value found in the
STREAMBASE_SERVERenvironment variable, if set DEFAULT_URIif 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
-
hasPrefix
- Parameters:
s-- Returns:
- true iff the supplied string looks like the beginning of a StreamBase URI
-