public SaslMechanism getSaslMechanism(String[] serverMechanisms) {
Set<String> server = new HashSet<String>(Arrays.asList(serverMechanisms));
if (server.contains(mechanism)) {
if (mechanism.equals("PLAIN")) {
return new PlainMechanism();
}
else if (mechanism.equals("EXTERNAL")) {
return new ExternalMechanism();
}
}