@@ -8,18 +8,26 @@ module SASL
8
8
#
9
9
# TODO: use with more clients, to verify the API can accommodate them.
10
10
#
11
- # An abstract base class for implementing a SASL authentication exchange.
12
- # Different clients will each have their own adapter subclass, overridden
13
- # to match their needs.
11
+ # Represents the client to a SASL::AuthenticationExchange. By default,
12
+ # most methods simply delegate to #client. Clients should subclass
13
+ # SASL::ClientAdapter and override methods as needed to match the
14
+ # semantics of this API to their API.
14
15
#
15
- # Although the default implementations _may_ be sufficient, subclasses
16
- # will probably need to override some methods. Additionally, subclasses
17
- # may need to include a protocol adapter mixin, if the default
16
+ # Subclasses should also include a protocol adapter mixin when the default
18
17
# ProtocolAdapters::Generic isn't sufficient.
18
+ #
19
+ # === Protocol Requirements
20
+ #
21
+ # {RFC4422 §4}[https://www.rfc-editor.org/rfc/rfc4422.html#section-4]
22
+ # lists requirements for protocol specifications to offer SASL. Where
23
+ # possible, ClientAdapter delegates the handling of these requirements to
24
+ # SASL::ProtocolAdapters.
19
25
class ClientAdapter
20
26
include ProtocolAdapters ::Generic
21
27
22
28
# The client that handles communication with the protocol server.
29
+ #
30
+ # Most ClientAdapter methods are simply delegated to #client by default.
23
31
attr_reader :client
24
32
25
33
# +command_proc+ can used to avoid exposing private methods on #client.
@@ -52,13 +60,9 @@ def initialize(client, &command_proc)
52
60
def authenticate ( ...) AuthenticationExchange . authenticate ( self , ...) end
53
61
54
62
# Do the protocol, server, and client all support an initial response?
55
- #
56
- # By default, this simply delegates to <tt>client.sasl_ir_capable?</tt>.
57
63
def sasl_ir_capable? ; client . sasl_ir_capable? end
58
64
59
- # Does the server advertise support for the mechanism?
60
- #
61
- # By default, this simply delegates to <tt>client.auth_capable?</tt>.
65
+ # Does the server advertise support for the +mechanism+?
62
66
def auth_capable? ( mechanism ) ; client . auth_capable? ( mechanism ) end
63
67
64
68
# Calls command_proc with +command_name+ (see
@@ -89,15 +93,12 @@ def port; client.port end
89
93
# Exceptions in this array won't drop the connection.
90
94
def response_errors ; [ ] end
91
95
92
- # Drop the connection gracefully.
93
- #
94
- # By default, this simply delegates to <tt>client.drop_connection</tt>.
96
+ # Drop the connection gracefully, sending a "LOGOUT" command as needed.
95
97
def drop_connection ; client . drop_connection end
96
98
97
- # Drop the connection abruptly.
98
- #
99
- # By default, this simply delegates to <tt>client.drop_connection!</tt>.
99
+ # Drop the connection abruptly, closing the socket without logging out.
100
100
def drop_connection! ; client . drop_connection! end
101
+
101
102
end
102
103
end
103
104
end
0 commit comments