public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { for (SaslClientFactory factory : factories) { if (factory != null) { final SaslClient saslClient = factory.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, cbh); if (saslClient != null) { return saslClient; } } } return null; }
public String[] getMechanismNames(final Map<String, ?> props) { return delegate.getMechanismNames(props); }
public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { return delegate.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, cbh); }
public String[] getMechanismNames(final Map<String, ?> props) { final LinkedHashSet<String> names = new LinkedHashSet<String>(); for (SaslClientFactory factory : factories) { Collections.addAll(names, factory.getMechanismNames(props)); } return names.toArray(new String[names.size()]); } }
public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { final SaslClient saslClient = delegate.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, cbh); return saslClient == null ? null : new AbstractDelegatingSaslClient(saslClient) { public void dispose() throws SaslException { try { super.dispose(); } finally { try { cbh.handle(new Callback[] { SecurityLayerDisposedCallback.getInstance() }); } catch (Throwable ignored) { } } } }; }
public String[] getMechanismNames(final Map<String, ?> props) { final String[] names = delegate.getMechanismNames(props); final ArrayList<String> list = new ArrayList<>(names.length); for (String name : names) { if (predicate.test(name)) { list.add(name); } } return list.toArray(new String[list.size()]); }
public SaslClientContext(final SaslClientFactory saslClientFactory, final String mech, final String server_name, final CallbackHandler callback_handler, final Map<String, String> props, final Subject subject) throws SaslException { this.subject = subject; if (this.subject != null) { try { client = Subject.doAs(this.subject, (PrivilegedExceptionAction<SaslClient>)() -> saslClientFactory.createSaslClient(new String[] { mech }, null, SASL.SASL_PROTOCOL_NAME, server_name, props, callback_handler)); } catch (PrivilegedActionException e) { throw (SaslException)e.getCause(); // The createSaslServer will only throw this type of exception } } else { client = saslClientFactory.createSaslClient(new String[] { mech }, null, SASL.SASL_PROTOCOL_NAME, server_name, props, callback_handler); } }
public static SaslClientFactory getSaslClientFactory(String mech, Map<String, ?> props) { Iterator<SaslClientFactory> saslFactories = SaslUtils.getSaslClientFactories(SaslUtils.class.getClassLoader(), true); while (saslFactories.hasNext()) { SaslClientFactory saslFactory = saslFactories.next(); for (String supportedMech : saslFactory.getMechanismNames(props)) { if (mech.equals(supportedMech)) { return saslFactory; } } } throw new IllegalArgumentException("No SASL client factory for mech " + mech); } }
public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { for (String mechanism : mechanisms) { if (! predicate.test(mechanism)) { // make a copy and remove the unsupported mechanisms final ArrayList<String> list = new ArrayList<>(mechanisms.length - 1); for (String m2 : mechanisms) { if (predicate.test(m2)) { list.add(m2); } } if (list.size() == 0) { return null; } return delegate.createSaslClient(list.toArray(new String[list.size()]), authorizationId, protocol, serverName, props, cbh); } } return delegate.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, cbh); }
@Override public String[] getMechanismNames(Map<String, ?> props) { return delegate.getMechanismNames(combine(props, properties)); }
@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 { final SaslClient delegateSaslClient = delegate.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, cbh); return delegateSaslClient == null ? null : new AbstractDelegatingSaslClient(delegateSaslClient) { private final AtomicBoolean complete = new AtomicBoolean();
public String[] getMechanismNames(final Map<String, ?> props) { synchronized (loader) { final Set<String> set = new LinkedHashSet<>(); final Iterator<SaslClientFactory> iterator = loader.iterator(); SaslClientFactory clientFactory; for (;;) try { // Service loader iterators can blow up in various ways; that's why the loop is structured this way if (! iterator.hasNext()) { break; } clientFactory = iterator.next(); // let SaslException bubble up Collections.addAll(set, clientFactory.getMechanismNames(props)); } catch (ServiceConfigurationError ignored) {} return set.toArray(new String[set.size()]); } } }
public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { return delegate.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, new SocketAddressQueryCallbackHandler(cbh, localAddress, peerAddress)); }
@Override public String[] getMechanismNames(final Map<String, ?> props) { final BiPredicate<String, Provider> mechFilter = SaslFactories.getProviderFilterPredicate(props); final Set<String> names = new LinkedHashSet<>(); for (Provider currentProvider : providerSupplier.get()) { Set<Service> services = currentProvider.getServices(); if (services != null) { for (Service service : services) { if (SERVICE_TYPE.equals(service.getType())) { try { final String[] mechanismNames = ((SaslClientFactory) service.newInstance(null)).getMechanismNames(props); Collections.addAll(names, SaslFactories.filterMechanismsByProvider(mechanismNames, 0, 0, currentProvider, mechFilter)); } catch (NoSuchAlgorithmException | ClassCastException | InvalidParameterException e) { log.debug("Unable to create instance", e); } } } } } if (names.size() == 0 && log.isTraceEnabled()) { log.tracef("No %s provided by providers in %s: %s", SERVICE_TYPE, getClass().getSimpleName(), Arrays.toString(providerSupplier.get())); } return names.toArray(new String[names.size()]); } }
public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { final SaslClient saslClient; try { saslClient = doPrivileged((PrivilegedExceptionAction<SaslClient>) () -> delegate.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, cbh), context); } catch (PrivilegedActionException pae) { try { throw pae.getCause(); } catch (SaslException | RuntimeException | Error e) { throw e; } catch (Throwable throwable) { throw new UndeclaredThrowableException(throwable); } } return saslClient == null ? null : new PrivilegedSaslClient(saslClient, context); }
public String[] getMechanismNames(final Map<String, ?> props) { return delegate.getMechanismNames(props); }
public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { final ArrayList<SaslClientFactory> factoryList = new ArrayList<>(); synchronized (loader) { final Iterator<SaslClientFactory> iterator = loader.iterator(); for (;;) try { // Service loader iterators can blow up in various ways; that's why the loop is structured this way if (! iterator.hasNext()) { break; } factoryList.add(iterator.next()); } catch (ServiceConfigurationError ignored) {} } SaslClient saslClient; final String[] mechArray = new String[1]; for (String mechanism : mechanisms) { mechArray[0] = mechanism; for (SaslClientFactory clientFactory : factoryList) { // let SaslException bubble up saslClient = clientFactory.createSaslClient(mechArray, authorizationId, protocol, serverName, props, cbh); if (saslClient != null) { return saslClient; } } } // no mechs found return null; }
public String[] getMechanismNames(final Map<String, ?> props) { return delegate.getMechanismNames(props); }
public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { return delegate.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, callbacks -> { ArrayList<Callback> list = new ArrayList<>(Arrays.asList(callbacks)); final Iterator<Callback> iterator = list.iterator(); while (iterator.hasNext()) { Callback callback = iterator.next(); if (callback instanceof ChannelBindingCallback) { ((ChannelBindingCallback) callback).setBindingType(bindingType); ((ChannelBindingCallback) callback).setBindingData(bindingData); iterator.remove(); } } if (!list.isEmpty()) { cbh.handle(list.toArray(new Callback[list.size()])); } }); }
public String[] getMechanismNames(final Map<String, ?> props) { return delegate.getMechanismNames(props); }