OPCFoundation / UA-Java-Legacy

This repository is provided by OPC Foundation as legacy support for an Java version for OPC UA.
https://github.com/OPCFoundation/UA-.NETStandard
Other
354 stars 226 forks source link

UserTokenPolicy with SecurityPolicyUri blank instead of null #219

Open damianozucconi opened 3 years ago

damianozucconi commented 3 years ago

Hi, I'm using UA-Java-Legacy 1.4.1 connecting to a Schneider PLC endpoint with security none. I found that its EndpointDescription contains a UserTokenPolicy UserName with SecurityPolicyUri = "" (not null) So when I try to activate sessionchannel with username and password, EndpointUtil.createUserNameIdentityToken throws exception with message UserName not supported despite of it is actually available This is caused by EndpointDescription.findUserTokenPolicy that uses SecurityPolicy.getSecurityPolicy and checks: if (securityPolicyUri == null) return NONE; but not something like if (securityPolicyUri == null || securityPolicyUri.trim().equals("")) return NONE;

So a connection with UAExpert is possible (with a security warning because account data is not encrypted) but with UA-Java-Legacy I get a UserName not supported message.