/** * Parse an XML element of type {@code names} which yields a protocol selector from an XML reader. * * @param reader the XML stream reader * @return the parsed protocol selector * @throws ConfigXMLParseException if the resource failed to be parsed */ static ProtocolSelector parseProtocolSelectorNamesType(ConfigurationXMLStreamReader reader) throws ConfigXMLParseException { ProtocolSelector selector = ProtocolSelector.empty(); for (String name : parseNamesType(reader)) { selector = selector.add(name); } return selector; }
private void doEvaluate(Set<Protocol> enabled, EnumMap<Protocol, String> supported) { if (prev != null) { prev.doEvaluate(enabled, supported); } applyFilter(enabled, supported); }
/** * Permanently delete the given protocol. Matching protocols cannot * be re-added by a later rule (such rules will be ignored). * * @param protocolName the name of the protocol to remove * @return a new selector which includes the new rule */ public ProtocolSelector deleteFully(final String protocolName) { return deleteFully(Protocol.forName(protocolName)); }
abstract void toString(final StringBuilder b);
final String[] supportedProtocols = protocolSelector.evaluate(preferredProviderByAlgorithm.keySet().toArray(NO_STRINGS)); if (log.isTraceEnabled()) { log.tracef("Supported protocols are: %s", Arrays.toString(supportedProtocols));
/** * Add the given protocol. * * @param protocolName the name of the protocol to add * @return a new selector which includes the new rule */ public ProtocolSelector add(final String protocolName) { return add(Protocol.forName(protocolName)); }
/** * Remove the given protocol. Matching protocols may be re-added by a later rule. * * @param protocolName the name of the protocol to remove * @return a new selector which includes the new rule */ public ProtocolSelector remove(final String protocolName) { return remove(Protocol.forName(protocolName)); }
/** * Evaluate this selector against the given list of JSSE supported protocols. * * @param supportedProtocols the supported protocols * @return the enabled protocols (not {@code null}) */ public final String[] evaluate(String[] supportedProtocols) { final EnumMap<Protocol, String> supported = new EnumMap<Protocol, String>(Protocol.class); for (String protocolName : supportedProtocols) { final Protocol protocol = Protocol.forName(protocolName); if (protocol != null) { supported.put(protocol, protocolName); } } final LinkedHashSet<Protocol> enabledSet = new LinkedHashSet<>(supported.size()); doEvaluate(enabledSet, supported); final ArrayList<String> list = new ArrayList<>(enabledSet.size()); for (Protocol protocol : enabledSet) { list.add(supported.get(protocol)); } return list.toArray(new String[enabledSet.size()]); }
void toString(final StringBuilder b) { if (prev != null && prev != EMPTY) { prev.toString(b); b.append(", then "); } b.append("add protocols ("); Iterator<Protocol> iterator = protocols.iterator(); Protocol protocol; if (iterator.hasNext()) { protocol = iterator.next(); b.append(protocol); while (iterator.hasNext()) { protocol = iterator.next(); b.append(", "); b.append(protocol); } } b.append(")"); }
void configure(SSLParameters params, String[] supportedProtocols, String[] supportedCipherSuites) { Assert.checkNotNullParam("supportedProtocols", supportedProtocols); Assert.checkNotNullParam("supportedCipherSuites", supportedCipherSuites); params.setProtocols(protocolSelector.evaluate(supportedProtocols)); params.setCipherSuites(cipherSuiteSelector.evaluate(supportedCipherSuites)); params.setUseCipherSuitesOrder(useCipherSuitesOrder); params.setWantClientAuth(wantClientAuth); // unsets need if (needClientAuth) params.setNeedClientAuth(needClientAuth); // unsets want }
/** * Add the given protocol. * * @param protocolName the name of the protocol to add * @return a new selector which includes the new rule */ public ProtocolSelector add(final String protocolName) { return add(Protocol.forName(protocolName)); }
/** * Remove the given protocol. Matching protocols may be re-added by a later rule. * * @param protocolName the name of the protocol to remove * @return a new selector which includes the new rule */ public ProtocolSelector remove(final String protocolName) { return remove(Protocol.forName(protocolName)); }
/** * Evaluate this selector against the given list of JSSE supported protocols. * * @param supportedProtocols the supported protocols * @return the enabled protocols (not {@code null}) */ public final String[] evaluate(String[] supportedProtocols) { final EnumMap<Protocol, String> supported = new EnumMap<Protocol, String>(Protocol.class); for (String protocolName : supportedProtocols) { final Protocol protocol = Protocol.forName(protocolName); if (protocol != null) { supported.put(protocol, protocolName); } } final LinkedHashSet<Protocol> enabledSet = new LinkedHashSet<>(supported.size()); doEvaluate(enabledSet, supported); final ArrayList<String> list = new ArrayList<>(enabledSet.size()); for (Protocol protocol : enabledSet) { list.add(supported.get(protocol)); } return list.toArray(new String[enabledSet.size()]); }
/** * Parse an XML element of type {@code names} which yields a protocol selector from an XML reader. * * @param reader the XML stream reader * @return the parsed protocol selector * @throws ConfigXMLParseException if the resource failed to be parsed */ static ProtocolSelector parseProtocolSelectorNamesType(ConfigurationXMLStreamReader reader) throws ConfigXMLParseException { ProtocolSelector selector = ProtocolSelector.empty(); for (String name : parseNamesType(reader)) { selector = selector.add(name); } return selector; }
private void doEvaluate(Set<Protocol> enabled, EnumMap<Protocol, String> supported) { if (prev != null) { prev.doEvaluate(enabled, supported); } applyFilter(enabled, supported); }
void toString(final StringBuilder b) { if (prev != null && prev != EMPTY) { prev.toString(b); b.append(", then "); } b.append("remove protocols ("); Iterator<Protocol> iterator = protocols.iterator(); Protocol protocol; if (iterator.hasNext()) { protocol = iterator.next(); b.append(protocol); while (iterator.hasNext()) { protocol = iterator.next(); b.append(", "); b.append(protocol); } } b.append(")"); }
private SSLParameters redefine(SSLParameters original, String[] supportedCipherSuites, String[] supportedProtocols) { final SSLParameters params = new SSLParameters(); configure(params, protocolSelector.evaluate(supportedProtocols), cipherSuiteSelector.evaluate(supportedCipherSuites)); // copy all other parameters over params.setServerNames(original.getServerNames()); params.setSNIMatchers(original.getSNIMatchers()); params.setAlgorithmConstraints(original.getAlgorithmConstraints()); params.setEndpointIdentificationAlgorithm(original.getEndpointIdentificationAlgorithm()); return params; }
/** * Add the given protocol. * * @param protocolName the name of the protocol to add * @return a new selector which includes the new rule */ public ProtocolSelector add(final String protocolName) { return add(Protocol.forName(protocolName)); }
/** * Remove the given protocol. Matching protocols may be re-added by a later rule. * * @param protocolName the name of the protocol to remove * @return a new selector which includes the new rule */ public ProtocolSelector remove(final String protocolName) { return remove(Protocol.forName(protocolName)); }
/** * Permanently delete the given protocol. Matching protocols cannot * be re-added by a later rule (such rules will be ignored). * * @param protocolName the name of the protocol to remove * @return a new selector which includes the new rule */ public ProtocolSelector deleteFully(final String protocolName) { return deleteFully(Protocol.forName(protocolName)); }