Opc.Ua.Bindings.TcpChannel.ReviseSecurityMode C# (CSharp) Method

ReviseSecurityMode() protected method

Checks if it is possible to revise the security mode.
protected ReviseSecurityMode ( bool firstCall, MessageSecurityMode requestedMode ) : void
firstCall bool
requestedMode MessageSecurityMode
return void
        protected void ReviseSecurityMode(bool firstCall, MessageSecurityMode requestedMode)
        {
             bool supported = false;

            // server may support multiple security modes - check if the one the client used is supported.
            if (firstCall && !m_discoveryOnly)
            {
                foreach (EndpointDescription endpoint in m_endpoints)
                {
                    if (endpoint.SecurityMode == requestedMode)
                    {
                        if (requestedMode == MessageSecurityMode.None || 
                            endpoint.SecurityPolicyUri == m_securityPolicyUri)
                        {
                            m_securityMode = endpoint.SecurityMode;
                            m_selectedEndpoint = endpoint;
                            supported = true;
                            break;
                        }
                    }
                }
            }

            if (!supported)
            {
                throw ServiceResultException.Create(StatusCodes.BadSecurityModeRejected, "Security mode is not acceptable to the server.");
            }
        }