コード例 #1
0
 /// <summary>
 /// Handles the authentication failure.
 /// </summary>
 public override void HandleAuthenticationFailure()
 {
     var defaultPair = DefaultPrivacyProvider.DefaultPair;
     Response = new ResponseMessage(
         Request.Version,
         new Header(
             new Integer32(Request.MessageId()),
             new Integer32(Messenger.MaxMessageSize),
             0), // no need to encrypt.
         new SecurityParameters(
             Group.EngineId,
             new Integer32(Group.EngineBoots),
             new Integer32(Group.EngineTime),
             Request.Parameters.UserName,
             defaultPair.AuthenticationProvider.CleanDigest,
             defaultPair.Salt),
         new Scope(
             Group.EngineId,
             OctetString.Empty,
             new ResponsePdu(
                 Request.RequestId(),
                 ErrorCode.AuthorizationError,
                 0,
                 Request.Pdu().Variables)),
         defaultPair,
         true,
         null);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #2
0
 public void TestConstructor()
 {
     var response = new ResponseMessage(
         VersionCode.V3,
         new Header(
             new Integer32(500),
             new Integer32(4000),
             new OctetString(new byte[] {0x4}),
             new Integer32(3)),
         new SecurityParameters(
             OctetString.Empty,
             new Integer32(0),
             new Integer32(0),
             new OctetString("lextm"),
             OctetString.Empty,
             OctetString.Empty),
         new Scope(
             OctetString.Empty,
             OctetString.Empty,
             new ResponsePdu(0x2C6B, ErrorCode.NoError, 0, new List<Variable>{ new Variable(new ObjectIdentifier("1.3.6.1.1.2.5.0"), new Integer32(400))})),
         DefaultPrivacyProvider.DefaultPair,
         true);
     var registry = new UserRegistry();
     registry.Add(new OctetString("lextm"), DefaultPrivacyProvider.DefaultPair);
     var messages = MessageFactory.ParseMessages(response.ToBytes(), registry);
     Assert.AreEqual(1, messages.Count);
 }
コード例 #3
0
 /// <summary>
 /// Handles the authentication failure.
 /// </summary>
 internal override void HandleAuthenticationFailure()
 {
     var defaultPair = DefaultPrivacyProvider.DefaultPair;
     Response = new ResponseMessage(
         Request.Version,
         new Header(
             new Integer32(Request.MessageId),
             new Integer32(Messenger.MaxMessageSize),
             new OctetString(new[] { (byte)Levels.Reportable }),
             new Integer32(3)),
         new SecurityParameters(
             Group.EngineId,
             new Integer32(Group.EngineBoots),
             new Integer32(Group.EngineTime),
             Request.Parameters.UserName,
             defaultPair.AuthenticationProvider.CleanDigest,
             defaultPair.Salt),
         new Scope(
             Group.EngineId,
             OctetString.Empty,
             new ResponsePdu(
                 Request.RequestId,
                 ErrorCode.AuthorizationError,
                 0,
                 Request.Pdu.Variables)),
         defaultPair,
         true);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #4
0
 /// <summary>
 /// Generates too big message.
 /// </summary>
 public override void GenerateTooBig()
 {
     Response = new ResponseMessage(
         Request.RequestId(),
         Request.Version,
         Request.Parameters.UserName,
         ErrorCode.TooBig,
         0,
         Request.Pdu().Variables);
 }
コード例 #5
0
 /// <summary>
 /// Copies the request variable bindings to response.
 /// </summary>
 /// <param name="status">The status.</param>
 /// <param name="index">The index.</param>
 public override void CopyRequest(ErrorCode status, int index)
 {
     Response = new ResponseMessage(
         Request.RequestId(),
         Request.Version,
         Request.Parameters.UserName,
         status,
         index,
         Request.Pdu().Variables);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #6
0
 /// <summary>
 /// Generates the response.
 /// </summary>
 /// <param name="variables">The variables.</param>
 public override void GenerateResponse(IList<Variable> variables)
 {
     Response = new ResponseMessage(
         Request.RequestId(),
         Request.Version,
         Request.Parameters.UserName,
         ErrorCode.NoError,
         0,
         variables);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #7
0
 public override void CopyRequest(ErrorCode status, int index)
 {
     var userName = Request.Parameters.UserName;
     var privacy = Users.Find(userName);
     var time = Group.EngineTimeData;
     Response = new ResponseMessage(
             Request.Version,
             new Header(
                 new Integer32(Request.MessageId()),
                 new Integer32(Messenger.MaxMessageSize),
                 privacy.ToSecurityLevel()),
             new SecurityParameters(
                 Group.EngineId,
                 new Integer32(time[0]),
                 new Integer32(time[1]),
                 userName,
                 privacy.AuthenticationProvider.CleanDigest,
                 privacy.Salt),
             new Scope(
                 Group.EngineId,
                 OctetString.Empty,
                 new ResponsePdu(
                     Request.RequestId(),
                     status,
                     index,
                     Request.Pdu().Variables)),
             privacy,
             true,
             null);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #8
0
 /// <summary>
 /// Generates the response.
 /// </summary>
 /// <param name="variables">The variables.</param>
 public override void GenerateResponse(IList<Variable> variables)
 {
     var userName = Request.Parameters.UserName;
     var privacy = Users.Find(userName);
     Response = new ResponseMessage(
         Request.Version,
         new Header(
             new Integer32(Request.MessageId()),
             new Integer32(Messenger.MaxMessageSize),
             privacy.ToSecurityLevel()),
         new SecurityParameters(
             Group.EngineId,
             new Integer32(Group.EngineBoots),
             new Integer32(Group.EngineTime),
             userName,
             privacy.AuthenticationProvider.CleanDigest,
             privacy.Salt),
         new Scope(
             Group.EngineId,
             OctetString.Empty,
             new ResponsePdu(
                 Request.RequestId(),
                 ErrorCode.NoError,
                 0,
                 variables)),
         privacy,
         true,
         null);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #9
0
 internal override void CopyRequest(ErrorCode status, int index)
 {
     var userName = Request.Parameters.UserName;
     IPrivacyProvider privacy = Users.Find(userName);
     Response = new ResponseMessage(
             Request.Version,
             new Header(
                 new Integer32(Request.MessageId),
                 new Integer32(Messenger.MaxMessageSize),
                 new OctetString(new[] { (byte)Levels.Reportable }),
                 new Integer32(3)),
             new SecurityParameters(
                 Group.EngineId,
                 new Integer32(Group.EngineBoots),
                 new Integer32(Group.EngineTime),
                 userName,
                 privacy.AuthenticationProvider.CleanDigest,
                 privacy.Salt),
             new Scope(
                 Group.EngineId,
                 OctetString.Empty,
                 new ResponsePdu(
                     Request.RequestId,
                     status,
                     index,
                     Request.Pdu.Variables)),
             privacy,
             true);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }