1 /*
2  * hunt-amqp: AMQP library for D programming language, based on hunt-net.
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 module hunt.amqp.impl.ProtonSaslServerAuthenticatorImpl;
12 
13 import hunt.amqp.ProtonConnection;
14 import hunt.amqp.sasl.ProtonSaslAuthenticator;
15 import hunt.proton.engine.Sasl;
16 import hunt.proton.engine.Transport;
17 
18 import hunt.amqp.sasl.impl.ProtonSaslAnonymousImpl;
19 
20 /**
21  * Manage the SASL authentication process
22  */
23 //class ProtonSaslServerAuthenticatorImpl : ProtonSaslAuthenticator {
24 //
25 //  private Sasl sasl;
26 //  private boolean succeeded;
27 //
28 //  @Override
29 //  public void init(NetSocket socket, ProtonConnection protonConnection, Transport transport) {
30 //    this.sasl = transport.sasl();
31 //    sasl.server();
32 //    sasl.allowSkip(false);
33 //    sasl.setMechanisms(ProtonSaslAnonymousImpl.MECH_NAME);
34 //    succeeded = false;
35 //  }
36 //
37 //  @Override
38 //  public void process(Handler<Boolean> completionHandler) {
39 //    if (sasl is null) {
40 //      throw new IllegalStateException("Init was not called with the associated transport");
41 //    }
42 //
43 //    boolean done = false;
44 //    String[] remoteMechanisms = sasl.getRemoteMechanisms();
45 //    if (remoteMechanisms.length > 0) {
46 //      String chosen = remoteMechanisms[0];
47 //      if (ProtonSaslAnonymousImpl.MECH_NAME.equals(chosen)) {
48 //        sasl.done(SaslOutcome.PN_SASL_OK);
49 //        succeeded = true;
50 //      } else {
51 //        sasl.done(SaslOutcome.PN_SASL_AUTH);
52 //      }
53 //      done = true;
54 //    }
55 //
56 //    completionHandler.handle(done);
57 //  }
58 //
59 //  @Override
60 //  public boolean succeeded() {
61 //    return succeeded;
62 //  }
63 //}