1 /*
2  * hunt-proton: AMQP Protocol library for D programming language.
3  *
4  * Copyright (C) 2018-2019 HuntLabs
5  *
6  * Website: https://www.huntlabs.net/
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 
12 
13 module hunt.proton.amqp.security.SaslChallenge;
14 
15 
16 import hunt.proton.amqp.Binary;
17 import hunt.proton.amqp.security.SaslFrameBody;
18 import hunt.logging;
19 
20 class SaslChallenge : SaslFrameBody
21 {
22     private Binary _challenge;
23 
24     public Binary getChallenge()
25     {
26         return _challenge;
27     }
28 
29     public void setChallenge(Binary challenge)
30     {
31         if( challenge is null )
32         {
33             logError("the challenge field is mandatory");
34         }
35 
36         _challenge = challenge;
37     }
38 
39     public Object get(int index)
40     {
41 
42         switch(index)
43         {
44             case 0:
45                 return _challenge;
46             default:
47                 return null;
48         }
49     }
50 
51     public int size()
52     {
53         return 1;
54 
55     }
56 
57     public void invoke(E)(SaslFrameBodyHandler!E handler, Binary payload, E context)
58     {
59         handler.handleChallenge(this, payload, context);
60     }
61 
62 }