public class EndpointUtil extends Object
| Constructor and Description |
|---|
EndpointUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
containsSecureUserTokenPolicy(UserTokenPolicy[] userIdentityTokens)
containsSecureUserTokenPolicy.
|
static UserIdentityToken |
createAnonymousIdentityToken(EndpointDescription ep)
Create anonymous user identity token
|
static UserIdentityToken |
createIssuedIdentityToken(EndpointDescription ep,
ByteString senderNonce,
byte[] issuedIdentityToken)
Create user identity token based on an issued token.
|
static UserIdentityToken |
createUserNameIdentityToken(EndpointDescription ep,
ByteString senderNonce,
String username,
String password)
Create user identity token based on username and password
|
static X509IdentityToken |
createX509IdentityToken(EndpointDescription ep,
ByteString serverNonce,
Cert certificate,
PrivateKey key,
SignatureData signatureData)
createX509IdentityToken.
|
static UserTokenPolicy |
findUserTokenPolicy(EndpointDescription endpointDescription,
String policyId)
Finds the user token policy with the specified id in the given
EndpointDescription. |
static UserTokenPolicy |
findUserTokenPolicy(EndpointDescription endpointDescription,
UserTokenType type)
Finds UserTokenPolicy of given type that this stack can encrypt in the given
EndpointDescription. |
static String |
getHostname()
Figure out some random hostname for this computer
|
static Set<InetAddress> |
getInetAddresses()
Get all Internet addresses of this computer.
|
static Set<InetAddress> |
getInetAddresses(boolean enableIPv6)
Get all Internet addresses of this computer.
|
static Set<String> |
getInetAddressNames()
Get all internet address names of this computer.
|
static String |
inetAddressToName(InetAddress addr)
inetAddressToName.
|
static boolean |
needsCertificate(EndpointDescription endpointDescription)
Returns true if the given
EndpointDescription indicates it needs a Certificate to work. |
static void |
reverse(Object array)
Reverse elements of an array
|
static EndpointDescription |
select(EndpointDescription[] endpoints)
Select an endpoint that is supported by the stack and has the highest security level.
|
static EndpointDescription[] |
select(EndpointDescription[] searchSet,
int minKeySize,
int maxKeySize)
select.
|
static EndpointDescription |
select(EndpointDescription[] endpoints,
String url)
select.
|
static EndpointDescription[] |
select(EndpointDescription[] searchSet,
String url,
String protocol,
MessageSecurityMode mode,
SecurityPolicy policy,
byte[] serverCertificate)
Filter endpoints by various criteria
|
static EndpointDescription[] |
selectByMessageSecurityMode(EndpointDescription[] searchSet,
MessageSecurityMode mode)
Selects all endpoints that conform to given message security mode
|
static EndpointDescription[] |
selectByProtocol(EndpointDescription[] searchSet,
String protocol)
Selects all endpoints that conform to given protcol
|
static EndpointDescription[] |
selectBySecurityPolicy(EndpointDescription[] searchSet,
SecurityPolicy policy)
Selects all endpoints that conform to given message security mode
|
static EndpointDescription[] |
selectByUrl(EndpointDescription[] searchSet,
String url)
Selects all endpoints with the given url.
|
static EndpointDescription |
selectEndpoint(EndpointDescription[] endpoints)
Select the most suitable endpoint.
|
static EndpointDescription[] |
sortBySecurityLevel(EndpointDescription[] set)
Sorts endpoints by their security level.
|
static boolean |
supportsUserTokenType(EndpointDescription endpoint,
UserTokenType type)
Tests whether the stack and the given
EndpointDescription supports given token type. |
static List<SocketAddress> |
toSocketAddresses(String endpointUrl)
Convert endpoint url to socket addresses.
|
static List<SocketAddress> |
toSocketAddresses(String endpointUrl,
boolean enableIPv6)
Convert endpoint url to socket addresses.
|
static boolean |
urlEqualsHostIgnoreCase(String endpointUrl,
String url)
Returns true only if both are valid OPC UA addresses and are the same address, ignoring host
part and using equalsIgnoreCase for the server name.
|
static boolean |
urlEqualsHostIgnoreCase(URI uri,
URI requestedUri)
Deprecated.
use
urlEqualsHostIgnoreCase(String, String) instead, URI has known issues
(at the time of writing this) and cannot parse an IPv6 address that has a scope id
that has a hyphen. |
static boolean |
urlEqualsProtocolAndServerNameIgnoringCase(String endpointUrl,
String url)
Returns true only if both are valid OPC UA addresses and are the same address, ignoring host
and port part and using equalsIgnoreCase for the server name.
|
public static boolean containsSecureUserTokenPolicy(UserTokenPolicy[] userIdentityTokens)
containsSecureUserTokenPolicy.
userIdentityTokens - an array of UserTokenPolicy
objects.public static UserIdentityToken createAnonymousIdentityToken(EndpointDescription ep) throws ServiceResultException
ep - a EndpointDescription object.ServiceResultException - if endpoint or the stack doesn't
support Anonymous token policypublic static UserIdentityToken createIssuedIdentityToken(EndpointDescription ep, ByteString senderNonce, byte[] issuedIdentityToken) throws ServiceResultException
ep - a EndpointDescription object.senderNonce - an array of byte.issuedIdentityToken - an array of byte.ServiceResultException - if endpoint or the stack doesn't
support UserName token policypublic static UserIdentityToken createUserNameIdentityToken(EndpointDescription ep, ByteString senderNonce, String username, String password) throws ServiceResultException
ep - a EndpointDescription object.username - a String object.password - a String object.senderNonce - an array of byte.ServiceResultException - if endpoint or the stack doesn't
support UserName token policypublic static X509IdentityToken createX509IdentityToken(EndpointDescription ep, ByteString serverNonce, Cert certificate, PrivateKey key, SignatureData signatureData) throws ServiceResultException
createX509IdentityToken.
ep - a EndpointDescription object.serverNonce - an array of byte.certificate - a Cert object.key - a PrivateKey object.signatureData - a SignatureData object.X509IdentityToken object.ServiceResultException - if any.public static UserTokenPolicy findUserTokenPolicy(EndpointDescription endpointDescription, String policyId)
EndpointDescription.endpointDescription - the EndpointDescription.policyId - policy id to findpublic static UserTokenPolicy findUserTokenPolicy(EndpointDescription endpointDescription, UserTokenType type)
EndpointDescription.the - EndpointDescription.type - to findpublic static String getHostname() throws SocketException
String object.SocketException - if any.public static Set<InetAddress> getInetAddresses() throws SocketException
SocketException - if any.public static Set<InetAddress> getInetAddresses(boolean enableIPv6) throws SocketException
enableIPv6 - Set true to enable IPv6 addressing. Requires Java 7 or later on Windows
platforms.SocketException - if any.public static Set<String> getInetAddressNames() throws SocketException
SocketException - if any.public static String inetAddressToName(InetAddress addr)
inetAddressToName.
addr - a InetAddress object.String object.public static boolean needsCertificate(EndpointDescription endpointDescription)
EndpointDescription indicates it needs a Certificate to work.public static void reverse(Object array)
array - a Object object.public static EndpointDescription select(EndpointDescription[] endpoints) throws ServiceResultException
endpoints - an array of EndpointDescription objects.ServiceResultException - errorpublic static EndpointDescription[] select(EndpointDescription[] searchSet, int minKeySize, int maxKeySize)
select.
searchSet - an array of EndpointDescription objects.minKeySize - a int.maxKeySize - a int.EndpointDescription objects.public static EndpointDescription select(EndpointDescription[] endpoints, String url) throws ServiceResultException
select.
endpoints - an array of EndpointDescription objects.url - a String object.EndpointDescription object.ServiceResultException - if any.public static EndpointDescription[] select(EndpointDescription[] searchSet, String url, String protocol, MessageSecurityMode mode, SecurityPolicy policy, byte[] serverCertificate)
searchSet - set of endpointsurl - filter by url (inclusive, case insensitive) or nullprotocol - filter by protocol (inclusive) or nullmode - filter by mode or nullpolicy - filter by policy or nullserverCertificate - an array of byte.public static EndpointDescription[] selectByMessageSecurityMode(EndpointDescription[] searchSet, MessageSecurityMode mode)
searchSet - an array of EndpointDescription objects.mode - a MessageSecurityMode object.public static EndpointDescription[] selectByProtocol(EndpointDescription[] searchSet, String protocol)
searchSet - an array of EndpointDescription objects.protocol - a String object.public static EndpointDescription[] selectBySecurityPolicy(EndpointDescription[] searchSet, SecurityPolicy policy)
searchSet - an array of EndpointDescription objects.policy - a SecurityPolicy object.public static EndpointDescription[] selectByUrl(EndpointDescription[] searchSet, String url)
searchSet - an array of urlsurl - a String object.public static EndpointDescription selectEndpoint(EndpointDescription[] endpoints)
Selection uses the following precedence: 1) Protocol must be opc.tcp (as http is not implemented) 2) Security uses sign and encrypt 3) Select highest security level (determined by the server) 4) Prefer hostname over localhost
endpoints - an array of EndpointDescription objects.public static EndpointDescription[] sortBySecurityLevel(EndpointDescription[] set)
set - set of endpointspublic static boolean supportsUserTokenType(EndpointDescription endpoint, UserTokenType type)
EndpointDescription supports given token type.
This verifies that the stack knows the encryption algorithms of the token type.endpoint - the EndpointDescriptiontype - the typepublic static List<SocketAddress> toSocketAddresses(String endpointUrl) throws IllegalArgumentException
endpointUrl - a String object.IllegalArgumentException - endpointUrl is problematic some waypublic static List<SocketAddress> toSocketAddresses(String endpointUrl, boolean enableIPv6) throws IllegalArgumentException
endpointUrl - a String object.enableIPv6 - Set true to enable IPv6 addressing. Requires Java 7 or later on Windows
platforms.IllegalArgumentException - endpointUrl is problematic some waypublic static boolean urlEqualsHostIgnoreCase(String endpointUrl, String url)
@Deprecated public static boolean urlEqualsHostIgnoreCase(URI uri, URI requestedUri)
urlEqualsHostIgnoreCase(String, String) instead, URI has known issues
(at the time of writing this) and cannot parse an IPv6 address that has a scope id
that has a hyphen.public static boolean urlEqualsProtocolAndServerNameIgnoringCase(String endpointUrl, String url)
Copyright © 2026. All rights reserved.