Skip to content

Commit

Permalink
Fix compile errors after updates of opcua driver.
Browse files Browse the repository at this point in the history
Signed-off-by: Łukasz Dywicki <[email protected]>
  • Loading branch information
splatch committed Aug 22, 2024
1 parent 20bbb8d commit 261881a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 188 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -591,19 +591,17 @@ private ExtensionObject getIdentityToken(UserTokenType tokenType, String securit
switch (tokenType) {
case userTokenTypeAnonymous:
//If we aren't using authentication tell the server we would like to log in anonymously
AnonymousIdentityToken anonymousIdentityToken = new AnonymousIdentityToken();
AnonymousIdentityToken anonymousIdentityToken = new AnonymousIdentityToken(new PascalString(securityPolicy));

extExpandedNodeId = new ExpandedNodeId(
false, //Namespace Uri Specified
false, //Server Index Specified
new NodeIdFourByte((short) 0, OpcuaNodeIdServicesObject.AnonymousIdentityToken_Encoding_DefaultBinary.getValue()),
new NodeIdFourByte((short) 0, anonymousIdentityToken.getExtensionId()),
null,
null
);

return new WireExtensionObject(extExpandedNodeId, BINARY_ENCODING_MASK, new BinaryWireExtensionObject(
new UserIdentityToken(new PascalString(securityPolicy), anonymousIdentityToken)
));
return new WireExtensionObject(extExpandedNodeId, BINARY_ENCODING_MASK, new BinaryWireExtensionObject(anonymousIdentityToken));
case userTokenTypeUserName:
//Encrypt the password using the server nonce and server public key
byte[] remoteNonce = conversation.getRemoteNonce();
Expand All @@ -619,20 +617,19 @@ private ExtensionObject getIdentityToken(UserTokenType tokenType, String securit

byte[] encryptedPassword = conversation.encryptPassword(encodeablePassword);
UserNameIdentityToken userNameIdentityToken = new UserNameIdentityToken(
new PascalString(securityPolicy),
new PascalString(this.username),
new PascalByteString(encryptedPassword.length, encryptedPassword),
new PascalString(PASSWORD_ENCRYPTION_ALGORITHM)
);

extExpandedNodeId = new ExpandedNodeId(false, //Namespace Uri Specified
false, //Server Index Specified
new NodeIdFourByte((short) 0, OpcuaNodeIdServicesObject.UserNameIdentityToken_Encoding_DefaultBinary.getValue()),
new NodeIdFourByte((short) 0, userNameIdentityToken.getExtensionId()),
null,
null);

return new WireExtensionObject(extExpandedNodeId, BINARY_ENCODING_MASK, new BinaryWireExtensionObject(
new UserIdentityToken(new PascalString(securityPolicy), userNameIdentityToken)
));
return new WireExtensionObject(extExpandedNodeId, BINARY_ENCODING_MASK, new BinaryWireExtensionObject(userNameIdentityToken));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements HasConfiguration<OpcuaConfiguration>, PlcSubscriber {

private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaProtocolLogic.class);
protected static final PascalString NULL_STRING = new PascalString("");
protected static final PascalString NULL_STRING = new PascalString(null);
private static final ExpandedNodeId NULL_EXPANDED_NODEID = new ExpandedNodeId(false,
false,
new NodeIdTwoByte((short) 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,27 @@ public CompletableFuture<OpcuaSubscriptionHandle> onSubscribeCreateMonitoredItem
new SimpleAttributeOperand(nodeId,
Arrays.asList(new QualifiedName(0, new PascalString("EventId"))),
AttributeId.Value.getValue(),
null
OpcuaProtocolLogic.NULL_STRING
),
new SimpleAttributeOperand(nodeId,
Arrays.asList(new QualifiedName(0, new PascalString("EventType"))),
AttributeId.Value.getValue(),
null
OpcuaProtocolLogic.NULL_STRING
),
new SimpleAttributeOperand(nodeId,
Arrays.asList(new QualifiedName(0, new PascalString("Severity"))),
AttributeId.Value.getValue(),
null
OpcuaProtocolLogic.NULL_STRING
),
new SimpleAttributeOperand(nodeId,
Arrays.asList(new QualifiedName(0, new PascalString("Time"))),
AttributeId.Value.getValue(),
null
OpcuaProtocolLogic.NULL_STRING
),
new SimpleAttributeOperand(nodeId,
Arrays.asList(new QualifiedName(0, new PascalString("Message"))),
AttributeId.Value.getValue(),
null
OpcuaProtocolLogic.NULL_STRING
)
);

Expand Down Expand Up @@ -244,11 +244,12 @@ private void sendPublishRequest() {
LOGGER.trace("Found a Data Change notification");
List<MonitoredItemNotification> items = ((DataChangeNotification) notification).getMonitoredItems();
onSubscriptionValue(items.stream().toArray(MonitoredItemNotification[]::new));
} else if (notification instanceof NotificationData) {
NotificationData data = (NotificationData) notification;
System.out.println("Received notification data");
// } else if (notification instanceof StatusChangeNotification) {
// StatusChangeNotification data = (StatusChangeNotification) notification;
// } else if (notification instanceof EventNotificationList) {
// EventNotificationList data = (EventNotificationList) notification;
} else {
LOGGER.warn("Unsupported Notification type");
LOGGER.warn("Unsupported Notification type {}", notification.getClass().getName());
}
}
}).whenComplete((result, error) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public static int pascalLengthToUtf8Length(int slength) {
return Math.max(slength, 0);
}

public static int extensionId(ExpandedNodeId typeId) {
public static int extensionId(ExpandedNodeId expandedNodeId) {
try {
return Integer.parseInt(typeId.getIdentifier());
return Integer.parseInt(expandedNodeId.getNodeId().getIdentifier());
} catch (NumberFormatException e) {
throw new PlcRuntimeException("Invalid node id, expected integer index, found " + typeId.getIdentifier().getClass());
throw new PlcRuntimeException("Invalid node id, expected number, found " + expandedNodeId.getNodeId().getClass().getName());
}
}
}

0 comments on commit 261881a

Please sign in to comment.