use of org.eclipse.milo.opcua.stack.core.security.SecurityPolicy in project vantiq-extension-sources by Vantiq.
the class Connection method runCertTest.
public void runCertTest(List<String> certList, boolean expectFailure) throws Exception {
List<EndpointDescription> eps = exampleServer.getServer().getEndpointDescriptions();
EnumSet<MessageSecurityMode> serverMsgModes = EnumSet.noneOf(MessageSecurityMode.class);
EnumSet<SecurityPolicy> serverSecPols = EnumSet.noneOf(SecurityPolicy.class);
for (EndpointDescription ep : eps) {
if (ep.getEndpointUrl().startsWith("opc.tpc")) {
// At present, these are all we test
serverSecPols.add(SecurityPolicy.fromUri(ep.getSecurityPolicyUri()));
serverMsgModes.add(ep.getSecurityMode());
}
}
// If expecting failure, act as if async so we can catch exceptions
boolean runSync = expectFailure;
// Below, we'll traverse the valid combinations. None's must be paired and are tested elsewhere
for (SecurityPolicy secPol : serverSecPols) {
if (!secPol.equals(SecurityPolicy.None)) {
for (MessageSecurityMode msgSec : serverMsgModes) {
if (!msgSec.equals(MessageSecurityMode.None)) {
// Defaults tested in *Upw test...
for (String certKey : certList) {
log.info("Attempting sync connection using [{}, {}] using certificate: '{}'", secPol, msgSec, certKey);
makeConnection(runSync, secPol.getUri(), msgSec.toString(), OpcConstants.CONFIG_IDENTITY_CERTIFICATE, certKey, true);
log.info("Attempting async connection using [{}, {}] using certificate: '{}'", secPol, msgSec, certKey);
makeConnection(true, secPol.getUri(), msgSec.toString(), OpcConstants.CONFIG_IDENTITY_CERTIFICATE, certKey, true);
}
}
}
}
}
}
Aggregations