コード例 #1
0
ファイル: RadiusClient.cs プロジェクト: QANTau/Radius.NET
		public RadiusPacket Authenticate(string username, string password)
		{
			RadiusPacket packet = new RadiusPacket(RadiusCode.ACCESS_REQUEST);
			packet.SetAuthenticator(_SharedSecret);
			byte[] encryptedPass = Utils.EncodePapPassword(Encoding.ASCII.GetBytes(password), packet.Authenticator, _SharedSecret);
			packet.SetAttribute(new RadiusAttribute(RadiusAttributeType.USER_NAME, Encoding.ASCII.GetBytes(username)));
			packet.SetAttribute(new RadiusAttribute(RadiusAttributeType.USER_PASSWORD, encryptedPass));
			return packet;
		}
コード例 #2
0
        public RadiusPacket Authenticate(string username, string password)
        {
            RadiusPacket packet = new RadiusPacket(RadiusCode.ACCESS_REQUEST);

            packet.SetAuthenticator(_SharedSecret);
            byte[] encryptedPass = Utils.EncodePapPassword(Encoding.ASCII.GetBytes(password), packet.Authenticator, _SharedSecret);
            packet.SetAttribute(new RadiusAttribute(RadiusAttributeType.USER_NAME, Encoding.ASCII.GetBytes(username)));
            packet.SetAttribute(new RadiusAttribute(RadiusAttributeType.USER_PASSWORD, encryptedPass));
            return(packet);
        }
コード例 #3
0
ファイル: RadiusClient.cs プロジェクト: pedroccrl/Radius.NET
        public RadiusPacket DisconnectRequest(string sessionId, string username, string framedIpAddress)
        {
            var packet = new RadiusPacket(RadiusCode.DISCONNECT_REQUEST);

            packet.SetAttribute(RadiusAttribute.CreateString(RadiusAttributeType.ACCT_SESSION_ID, sessionId));
            packet.SetAttribute(RadiusAttribute.CreateString(RadiusAttributeType.USER_NAME, username));
            packet.SetAttribute(RadiusAttribute.CreateAddress(RadiusAttributeType.FRAMED_IP_ADDRESS, framedIpAddress));
            packet.SetAuthenticator(_SharedSecret);

            return(packet);
        }
コード例 #4
0
        /// <summary>
        /// Sends a Server-Status packet using the shared secret of the client
        /// </summary>
        /// <returns></returns>
        public async Task <RadiusPacket> Ping()
        {
            // Create a new RADIUS packet with the Server-Status code
            RadiusPacket authPacket = new RadiusPacket(RadiusCode.SERVER_STATUS);

            // Populate the Request-Authenticator
            authPacket.SetAuthenticator(_SharedSecret);
            // Add the Message-Authenticator as a last step.  Note: Server-Status packets don't require any other attributes
            authPacket.SetMessageAuthenticator(_SharedSecret);
            // We MUST NOT retransmit Server-Status packets according to https://tools.ietf.org/html/rfc5997
            return(await SendAndReceivePacket(authPacket, 0));
        }