@Test void succeedWithSupportedMechanism() throws Exception { ScramSaslClientFactory factory = new ScramSaslClientFactory(); CallbackHandler cbh = mock(CallbackHandler.class); SaslClient client = factory.createSaslClient( new String[] { "SCRAM-SHA256", "SCRAM-SHA512" }, null, null, null, null, cbh ); assertNotNull(client); assertEquals("SCRAM-SHA512", client.getMechanismName()); }
@Override public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { if (authorizationId != null) { throw new SaslException("AuthorizationId is not supported"); } if (cbh == null) { throw new SaslException("Callback handler required"); } final Optional<Mode> mode = Mode.strongestOf(mechanisms); if (!mode.isPresent()) { return null; } try { return new ScramSaslClient(mode.get(), cbh); } catch (NoSuchAlgorithmException e) { throw new SaslException("Selected algorithm not supported.", e); } }
ScramSaslClientFactory implements SaslClientFactory { @Override public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { if (authorizationId != null) { throw new SaslException("AuthorizationId is not supported"); } if (cbh == null) { throw new SaslException("Callback handler required"); } final Optional<Mode> mode = Mode.strongestOf(mechanisms); if (!mode.isPresent()) { return null; } try { return new ScramSaslClient(mode.get(), cbh); } catch (NoSuchAlgorithmException e) { throw new SaslException("Selected algorithm not supported.", e); } } }
ScramSaslClientFactory implements SaslClientFactory { @Override public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { if (authorizationId != null) { throw new SaslException("AuthorizationId is not supported"); } if (cbh == null) { throw new SaslException("Callback handler required"); } final Optional<Mode> mode = Mode.strongestOf(mechanisms); if (!mode.isPresent()) { return null; } try { return new ScramSaslClient(mode.get(), cbh); } catch (NoSuchAlgorithmException e) { throw new SaslException("Selected algorithm not supported.", e); } }  }
ScramSaslClientFactory implements SaslClientFactory { @Override public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { if (authorizationId != null) { throw new SaslException("AuthorizationId is not supported"); } if (cbh == null) { throw new SaslException("Callback handler required"); } final Optional<Mode> mode = Mode.strongestOf(mechanisms); if (!mode.isPresent()) { return null; } try { return new ScramSaslClient(mode.get(), cbh); } catch (NoSuchAlgorithmException e) { throw new SaslException("Selected algorithm not supported.", e); } }  @Override SaslClient createSaslClient(final String[] mechanisms, final String authorizationId,
                                     final String protocol, final String serverName,
                                     final Map<String, ?> props, final CallbackHandler cbh); @Override String[] getMechanismNames(final Map<String, ?> props); }
ScramSaslClientFactory implements SaslClientFactory { @Override public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { if (authorizationId != null) { throw new SaslException("AuthorizationId is not supported"); } if (cbh == null) { throw new SaslException("Callback handler required"); } final Optional<Mode> mode = Mode.strongestOf(mechanisms); if (!mode.isPresent()) { return null; } try { return new ScramSaslClient(mode.get(), cbh); } catch (NoSuchAlgorithmException e) { throw new SaslException("Selected algorithm not supported.", e); } }  @Override SaslClient createSaslClient(final String[] mechanisms, final String authorizationId,
                                     final String protocol, final String serverName,
                                     final Map<String, ?> props, final CallbackHandler cbh); @Override String[] getMechanismNames(final Map<String, ?> props);  }