@Test public void testUsernameSecurityAccess() { runner.setProperty(service, StandardOPCUAService.ENDPOINT, endpoint); runner.setProperty(service, StandardOPCUAService.SECURITY_POLICY, "Basic256Sha256"); runner.setProperty(service, StandardOPCUAService.SECURITY_MODE, "SignAndEncrypt"); runner.setProperty(service, StandardOPCUAService.APPLICATION_URI, "urn:ibhlinkua_001151:IBHsoftec:IBHLinkUA"); runner.setProperty(service, StandardOPCUAService.CLIENT_KS_LOCATION, "src/test/resources/client.jks"); runner.setProperty(service, StandardOPCUAService.CLIENT_KS_PASSWORD, "password"); runner.setProperty(service, StandardOPCUAService.REQUIRE_SERVER_AUTH, "true"); runner.setProperty(service, StandardOPCUAService.TRUSTSTORE_LOCATION, "src/test/resources/trust.jks"); runner.setProperty(service, StandardOPCUAService.TRUSTSTORE_PASSWORD, "SuperSecret"); runner.setProperty(service, StandardOPCUAService.AUTH_POLICY, "Username"); runner.setProperty(service, StandardOPCUAService.USERNAME, "test1"); runner.setProperty(service, StandardOPCUAService.PASSWORD, "password"); runner.assertValid(service); runner.enableControllerService(service); List<String> tagList = Arrays.asList("ns=4;s=S71500/ET200MP-Station_2.PLC_1.GlobalVars.I_MAG1_EXT", "ns=4;s=S71500/ET200MP-Station_2.PLC_1.GlobalVars.I_MAG2_EXT"); byte[] bytes = service.getValue(tagList, "Both", true, ""); System.out.println(new String(bytes)); runner.disableControllerService(service); }
@Override public byte[] getValue(List<String> tagNames, String returnTimestamp, boolean excludeNullValue, String nullValueString) throws ProcessException { try { if (opcClient == null) { throw new ProcessException("OPC Client is null. OPC UA service was not enabled properly."); } ArrayList<NodeId> nodeIdList = new ArrayList<>(); tagNames.forEach((tagName) -> nodeIdList.add(NodeId.parse(tagName))); List<DataValue> rvList = opcClient.readValues(0, TimestampsToReturn.Both, nodeIdList).get(); StringBuilder serverResponse = new StringBuilder(); for (int i = 0; i < tagNames.size(); i++) { String valueLine; valueLine = writeCsv(tagNames.get(i), returnTimestamp, rvList.get(i), excludeNullValue, nullValueString); serverResponse.append(valueLine); } return serverResponse.toString().trim().getBytes(); } catch (Exception e) { throw new ProcessException(e); } }
StandardOPCUAService extends AbstractControllerService implements OPCUAService { @Override public byte[] getValue(List<String> tagNames, String returnTimestamp, boolean excludeNullValue, String nullValueString) throws ProcessException { try { if (opcClient == null) { throw new ProcessException("OPC Client is null. OPC UA service was not enabled properly."); } ArrayList<NodeId> nodeIdList = new ArrayList<>(); tagNames.forEach((tagName) -> nodeIdList.add(NodeId.parse(tagName))); List<DataValue> rvList = opcClient.readValues(0, TimestampsToReturn.Both, nodeIdList).get(); StringBuilder serverResponse = new StringBuilder(); for (int i = 0; i < tagNames.size(); i++) { String valueLine; valueLine = writeCsv(tagNames.get(i), returnTimestamp, rvList.get(i), excludeNullValue, nullValueString); serverResponse.append(valueLine); } return serverResponse.toString().trim().getBytes(); } catch (Exception e) { throw new ProcessException(e); } } }
StandardOPCUAService extends AbstractControllerService implements OPCUAService { @Override public byte[] getValue(List<String> tagNames, String returnTimestamp, boolean excludeNullValue, String nullValueString) throws ProcessException { try { if (opcClient == null) { throw new ProcessException("OPC Client is null. OPC UA service was not enabled properly."); } ArrayList<NodeId> nodeIdList = new ArrayList<>(); tagNames.forEach((tagName) -> nodeIdList.add(NodeId.parse(tagName))); List<DataValue> rvList = opcClient.readValues(0, TimestampsToReturn.Both, nodeIdList).get(); StringBuilder serverResponse = new StringBuilder(); for (int i = 0; i < tagNames.size(); i++) { String valueLine; valueLine = writeCsv(tagNames.get(i), returnTimestamp, rvList.get(i), excludeNullValue, nullValueString); serverResponse.append(valueLine); } return serverResponse.toString().trim().getBytes(); } catch (Exception e) { throw new ProcessException(e); } }  }
StandardOPCUAService extends AbstractControllerService implements OPCUAService { @Override public byte[] getValue(List<String> tagNames, String returnTimestamp, boolean excludeNullValue, String nullValueString) throws ProcessException { try { if (opcClient == null) { throw new ProcessException("OPC Client is null. OPC UA service was not enabled properly."); } ArrayList<NodeId> nodeIdList = new ArrayList<>(); tagNames.forEach((tagName) -> nodeIdList.add(NodeId.parse(tagName))); List<DataValue> rvList = opcClient.readValues(0, TimestampsToReturn.Both, nodeIdList).get(); StringBuilder serverResponse = new StringBuilder(); for (int i = 0; i < tagNames.size(); i++) { String valueLine; valueLine = writeCsv(tagNames.get(i), returnTimestamp, rvList.get(i), excludeNullValue, nullValueString); serverResponse.append(valueLine); } return serverResponse.toString().trim().getBytes(); } catch (Exception e) { throw new ProcessException(e); } }  @OnEnabled void onEnabled(final ConfigurationContext context); @OnDisabled void shutdown(); @Override byte[] getValue(List<String> tagNames, String returnTimestamp, boolean excludeNullValue,
                           String nullValueString); @Override String subscribe(List<String> tagNames, BlockingQueue<String> queue,
                            boolean tsChangedNotify, long minPublishInterval); @Override void unsubscribe(String subscriptionUid); @Override byte[] getNodes(String indentString, int maxRecursiveDepth, int maxReferencePerNode,
                           boolean printNonLeafNode, String rootNodeId); }
StandardOPCUAService extends AbstractControllerService implements OPCUAService { @Override public byte[] getValue(List<String> tagNames, String returnTimestamp, boolean excludeNullValue, String nullValueString) throws ProcessException { try { if (opcClient == null) { throw new ProcessException("OPC Client is null. OPC UA service was not enabled properly."); } ArrayList<NodeId> nodeIdList = new ArrayList<>(); tagNames.forEach((tagName) -> nodeIdList.add(NodeId.parse(tagName))); List<DataValue> rvList = opcClient.readValues(0, TimestampsToReturn.Both, nodeIdList).get(); StringBuilder serverResponse = new StringBuilder(); for (int i = 0; i < tagNames.size(); i++) { String valueLine; valueLine = writeCsv(tagNames.get(i), returnTimestamp, rvList.get(i), excludeNullValue, nullValueString); serverResponse.append(valueLine); } return serverResponse.toString().trim().getBytes(); } catch (Exception e) { throw new ProcessException(e); } }  @OnEnabled void onEnabled(final ConfigurationContext context); @OnDisabled void shutdown(); @Override byte[] getValue(List<String> tagNames, String returnTimestamp, boolean excludeNullValue,
                           String nullValueString); @Override String subscribe(List<String> tagNames, BlockingQueue<String> queue,
                            boolean tsChangedNotify, long minPublishInterval); @Override void unsubscribe(String subscriptionUid); @Override byte[] getNodes(String indentString, int maxRecursiveDepth, int maxReferencePerNode,
                           boolean printNonLeafNode, String rootNodeId); static final PropertyDescriptor ENDPOINT; static final PropertyDescriptor SECURITY_POLICY; static final PropertyDescriptor SECURITY_MODE; static final PropertyDescriptor APPLICATION_URI; static final PropertyDescriptor CLIENT_KS_LOCATION; static final PropertyDescriptor CLIENT_KS_PASSWORD; static final PropertyDescriptor REQUIRE_SERVER_AUTH; static final PropertyDescriptor TRUSTSTORE_LOCATION; static final PropertyDescriptor TRUSTSTORE_PASSWORD; static final PropertyDescriptor AUTH_POLICY; static final PropertyDescriptor USERNAME; static final PropertyDescriptor PASSWORD; static final PropertyDescriptor USE_PROXY; }