protected void SetStateCompletedSecurityDone(ActionUnit ou) { SpecificResult.SubstituteStatus = SubstituteStatuses.Done; if (VirtualNodeId == 0) { _securityManagerInfo.Network.SetSecuritySchemes(_grantedSchemes.ToArray()); _securityManagerInfo.Network.SetSecuritySchemes(NodeId, _grantedSchemes.ToArray()); if (_grantedSchemes.Contains(SecuritySchemes.S2_ACCESS)) { _securityManagerInfo.ActivateNetworkKeyS2ForNode(_peerNodeId, SecuritySchemes.S2_ACCESS); } else if (_grantedSchemes.Contains(SecuritySchemes.S2_AUTHENTICATED)) { _securityManagerInfo.ActivateNetworkKeyS2ForNode(_peerNodeId, SecuritySchemes.S2_AUTHENTICATED); } else if (_grantedSchemes.Contains(SecuritySchemes.S2_UNAUTHENTICATED)) { _securityManagerInfo.ActivateNetworkKeyS2ForNode(_peerNodeId, SecuritySchemes.S2_UNAUTHENTICATED); } } _securityManagerInfo.IsInclusion = false; SetStateCompleted(ou); }
protected override void SetStateCompleted(ActionUnit ou) { base.SetStateCompleted(ou); _securityManagerInfo.Network.SetSecuritySchemesSpecified(_nodeInfo.NodeId); List <SecuritySchemes> schemes = new List <SecuritySchemes>(); byte[] secureCommandClasses = null; if (_supportedS2_ACCESS.IsSendDataCompleted()) { if (_supportedS2_ACCESS.Result) { if (_supportedS2_ACCESS.SpecificResult.Command != null) { var commandClasses = ((COMMAND_CLASS_SECURITY_2.SECURITY_2_COMMANDS_SUPPORTED_REPORT)_supportedS2_ACCESS.SpecificResult.Command). commandClass.TakeWhile(x => x != 0xEF).ToArray(); if (commandClasses.Length > 0) { secureCommandClasses = commandClasses; } } schemes.Add(SecuritySchemes.S2_ACCESS); } } else if (Actions.Contains(_supportedS2_ACCESS)) { _supportedS2_AUTHENTICATED.Token.SetCancelled(); _supportedS2_UNAUTHENTICATED.Token.SetCancelled(); } if (_supportedS2_AUTHENTICATED.IsSendDataCompleted()) { if (_supportedS2_AUTHENTICATED.Result) { if (_supportedS2_AUTHENTICATED.SpecificResult.Command != null) { var commandClasses = ((COMMAND_CLASS_SECURITY_2.SECURITY_2_COMMANDS_SUPPORTED_REPORT)_supportedS2_AUTHENTICATED.SpecificResult.Command). commandClass.TakeWhile(x => x != 0xEF).ToArray(); if (commandClasses.Length > 0) { secureCommandClasses = commandClasses; } } schemes.Add(SecuritySchemes.S2_AUTHENTICATED); } else if (_supportedS2_AUTHENTICATED.Result.State == ActionStates.Cancelled && _securityManagerInfo.Network.HasSecurityScheme(_nodeInfo.NodeId, SecuritySchemes.S2_AUTHENTICATED)) { schemes.Add(SecuritySchemes.S2_AUTHENTICATED); } } else if (Actions.Contains(_supportedS2_AUTHENTICATED)) { _supportedS2_UNAUTHENTICATED.Token.SetCancelled(); } if (_supportedS2_UNAUTHENTICATED.IsSendDataCompleted()) { if (_supportedS2_UNAUTHENTICATED.Result) { if (_supportedS2_UNAUTHENTICATED.SpecificResult.Command != null) { var commandClasses = ((COMMAND_CLASS_SECURITY_2.SECURITY_2_COMMANDS_SUPPORTED_REPORT)_supportedS2_UNAUTHENTICATED.SpecificResult.Command). commandClass.TakeWhile(x => x != 0xEF).ToArray(); if (commandClasses.Length > 0) { secureCommandClasses = commandClasses; } } schemes.Add(SecuritySchemes.S2_UNAUTHENTICATED); } else if (_supportedS2_UNAUTHENTICATED.Result.State == ActionStates.Cancelled && _securityManagerInfo.Network.HasSecurityScheme(_nodeInfo.NodeId, SecuritySchemes.S2_UNAUTHENTICATED)) { schemes.Add(SecuritySchemes.S2_UNAUTHENTICATED); } } if (_supportedS0.IsSendDataCompleted()) { if (_supportedS0.Result) { if (_supportedS0.SpecificResult.Command != null) { var commandClasses = ((COMMAND_CLASS_SECURITY.SECURITY_COMMANDS_SUPPORTED_REPORT)_supportedS0.SpecificResult.Command). commandClassSupport.TakeWhile(x => x != 0xEF).ToArray(); if (commandClasses.Length > 0) { secureCommandClasses = commandClasses; } } schemes.Add(SecuritySchemes.S0); } } if (schemes.Count > 0) { if (!_isInclusionTask) { _securityManagerInfo.Network.SetSecuritySchemes(_nodeInfo.NodeId, schemes.ToArray()); } _securityManagerInfo.Network.SetSecureCommandClasses(new NodeTag(_nodeInfo.NodeId), secureCommandClasses); SpecificResult.SecureCommandClasses = secureCommandClasses; if (SecuritySchemeSet.ALLS2.Contains(schemes[0])) { var peerNodeId = new InvariantPeerNodeId(_securityManagerInfo.Network.NodeId, _nodeInfo.NodeId); _securityManagerInfo.ActivateNetworkKeyS2ForNode(peerNodeId, schemes[0]); } } else { if (!_isInclusionTask) { _securityManagerInfo.Network.ResetSecuritySchemes(_nodeInfo.NodeId); SpecificResult.SecureCommandClasses = null; } } }