Skip to content

Commit

Permalink
Introduce BINARY_ENCODING_MASK constant to golang 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 Oct 15, 2024
1 parent 4ee95f7 commit 47c6598
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions plc4go/internal/opcua/SecureChannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var (
nil,
nil,
)
BINARY_ENCODING_MASK = readWriteModel.NewExtensionObjectEncodingMask(false, false, true)
NULL_EXTENSION_OBJECT = readWriteModel.NewNullExtensionObjectWithMask(NULL_EXPANDED_NODEID,
readWriteModel.NewExtensionObjectEncodingMask(false, false, false),
0,
Expand Down Expand Up @@ -1560,18 +1561,21 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType,
switch tokenType {
case readWriteModel.UserTokenType_userTokenTypeAnonymous:
//If we aren't using authentication tell the server we would like to log in anonymously
anonymousIdentityToken := readWriteModel.NewAnonymousIdentityToken(readWriteModel.NewPascalString(policyId))
anonymousIdentityToken, err := readWriteModel.NewAnonymousIdentityTokenBuilder().WithPolicyId(readWriteModel.NewPascalString(policyId)).Build()
if err != nil {
s.log.Error().Err(err).Msg("error creating anonymous authentication token")
return nil
}
extExpandedNodeId := readWriteModel.NewExpandedNodeId(
false, //Namespace Uri Specified
false, //Server Index Specified
readWriteModel.NewNodeIdFourByte(
0, 321 /* TODO: disabled till we have greater segmentation: uint16(readWriteModel.OpcuaNodeIdServices_AnonymousIdentityToken_Encoding_DefaultBinary)*/),
readWriteModel.NewNodeIdFourByte(0, uint16(anonymousIdentityToken.GetExtensionId())),
nil,
nil,
)
return readWriteModel.NewBinaryExtensionObjectWithMask(
extExpandedNodeId,
readWriteModel.NewExtensionObjectEncodingMask(false, false, true),
BINARY_ENCODING_MASK,
anonymousIdentityToken,
anonymousIdentityToken.GetExtensionId(),
false,
Expand Down Expand Up @@ -1604,12 +1608,12 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType,
extExpandedNodeId := readWriteModel.NewExpandedNodeId(
false, //Namespace Uri Specified
false, //Server Index Specified
readWriteModel.NewNodeIdFourByte(0, 324 /*TODO: disabled till we have greater segmentation: uint16(readWriteModel.OpcuaNodeIdServices_UserNameIdentityToken_Encoding_DefaultBinary)*/),
readWriteModel.NewNodeIdFourByte(0, uint16(userNameIdentityToken.GetExtensionId())),
nil,
nil)
return readWriteModel.NewBinaryExtensionObjectWithMask(
extExpandedNodeId,
readWriteModel.NewExtensionObjectEncodingMask(false, false, true),
BINARY_ENCODING_MASK,
userNameIdentityToken,
userNameIdentityToken.GetExtensionId(),
false,
Expand Down

0 comments on commit 47c6598

Please sign in to comment.