diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java index e4750ff486..e81f01cd80 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java @@ -418,13 +418,10 @@ public CompletableFuture onDiscoverGetEndpointsRequest() { ); return conversation.submit(endpointsRequest, GetEndpointsResponse.class).thenApply(response -> { - List endpoints = response.getEndpoints(); Entry entry = selectEndpoint(response.getEndpoints(), this.endpoints, this.configuration.getSecurityPolicy(), this.configuration.getMessageSecurity()); if (entry == null) { - Set endpointUris = endpoints.stream() - .filter(EndpointDescription.class::isInstance) - .map(EndpointDescription.class::cast) + Set endpointUris = response.getEndpoints().stream() .map(EndpointDescription::getEndpointUrl) .map(PascalString::getStringValue) .collect(Collectors.toSet()); @@ -499,18 +496,13 @@ private static ReadBufferByteBased toBuffer(Supplier supplier) { * @param messageSecurity Message security needed by client. * @return Endpoint matching given. */ - private Entry selectEndpoint(List extensionObjects, Collection contactPoints, + private Entry selectEndpoint(List extensionObjects, Collection contactPoints, SecurityPolicy securityPolicy, MessageSecurity messageSecurity) throws PlcRuntimeException { // Get a list of the endpoints which match ours. MessageSecurityMode effectiveMessageSecurity = SecurityPolicy.NONE == securityPolicy ? MessageSecurityMode.messageSecurityModeNone : messageSecurity.getMode(); List> serverEndpoints = new ArrayList<>(); - for (ExtensionObjectDefinition extensionObject : extensionObjects) { - if (!(extensionObject instanceof EndpointDescription)) { - continue; - } - - EndpointDescription endpointDescription = (EndpointDescription) extensionObject; + for (EndpointDescription endpointDescription : extensionObjects) { if (isMatchingEndpoint(endpointDescription, contactPoints)) { boolean policyMatch = endpointDescription.getSecurityPolicyUri().getStringValue().equals(securityPolicy.getSecurityPolicyUri()); boolean msgSecurityMatch = endpointDescription.getSecurityMode().equals(effectiveMessageSecurity); @@ -519,12 +511,9 @@ private Entry selectEndpoint(List