send method
Implementation
@override
void send(AbstractMessage message) {
if (message is Hello) {
var ticketAuthentication = TicketAuthentication(authenticationPassword);
var craAuthentication = CraAuthentication(authenticationPassword);
var scramAuthentication = ScramAuthentication(authenticationPassword);
var cryptosignAuthentication = CryptosignAuthentication(
authenticationKey,
null,
);
if (message.details.authmethods?.contains(
ticketAuthentication.getName(),
) ??
false) {
var extra = Extra();
ticketAuthentication.challenge(extra).then((authenticate) {
_hello = message;
_signature = authenticate.signature;
_authentication = ticketAuthentication;
_receiveController.add(
Challenge(ticketAuthentication.getName(), extra),
);
});
} else if (message.details.authmethods?.contains(
craAuthentication.getName(),
) ??
false) {
var extra = Extra(
salt: message.details.salt ?? 'salt',
keyLen: 32,
iterations: 1000,
challenge:
'{"authid":"${message.details.authid}","authrole":"client","authmethod":"${craAuthentication.getName()}","authprovider":"local","nonce":"local","timestamp":"1970-01-01T12:00Z","session":1}',
);
craAuthentication.challenge(extra).then((authenticate) {
_hello = message;
_signature = authenticate.signature;
_authentication = craAuthentication;
_receiveController.add(Challenge(craAuthentication.getName(), extra));
});
} else if (message.details.authmethods?.contains(
scramAuthentication.getName(),
) ??
false) {
var extra = Extra(
iterations: 1,
memory: 100,
salt: 'AQ==',
nonce: '${message.details.authextra?['nonce']}AQ==',
kdf: ScramAuthentication.kdfArgon,
);
_hello = message;
_authentication = scramAuthentication;
_scramChallenge = extra;
_scramClientNonce = message.details.authextra?['nonce'] as String?;
_receiveController.add(Challenge(scramAuthentication.getName(), extra));
} else if (message.details.authmethods?.contains(
cryptosignAuthentication.getName(),
) ??
false) {
var extra = Extra();
extra.challenge = "11";
cryptosignAuthentication.challenge(extra).then((authenticate) {
_hello = message;
_signature = authenticate.signature;
_authentication = cryptosignAuthentication;
_receiveController.add(
Challenge(cryptosignAuthentication.getName(), extra),
);
});
} else {
_receiveController.add(
Welcome(
1,
Details.forWelcome(
authId: _hello?.details.authid,
authMethod: _authentication?.getName(),
authProvider: 'local',
authRole: 'client',
realm: _hello?.realm,
),
),
);
}
} else if (message is Authenticate) {
unawaited(_handleAuthenticate(message));
}
_sentMessagesController.add(message);
}