public void testSetEnabledProtocolsAffectsGetter() throws Exception { SSLServerSocket socket = (SSLServerSocket) SSLServerSocketFactory.getDefault().createServerSocket(); String[] protocols = new String[] {socket.getSupportedProtocols()[0]}; socket.setEnabledProtocols(protocols); assertEquals(Arrays.asList(protocols), Arrays.asList(socket.getEnabledProtocols())); }
public String[] getSupportedProtocols() { return s.getSupportedProtocols(); }
protected String[] getEnabledProtocols(SSLServerSocket socket, String requestedProtocols) { String[] supportedProtocols = socket.getSupportedProtocols(); String[] enabledProtocols = null; if (requestedProtocols != null) { Vector vec = null; String protocol = requestedProtocols; int index = requestedProtocols.indexOf(','); if (index != -1) { int fromIndex = 0; while (index != -1) { protocol = requestedProtocols.substring(fromIndex, index).trim(); if (protocol.length() > 0) { /* * Check to see if the requested protocol is among the * supported protocols, i.e., may be enabled */ for (int i = 0; supportedProtocols != null && i < supportedProtocols.length; i++) { if (supportedProtocols[i].equals(protocol)) { if (vec == null) { vec = new Vector(); } vec.addElement(protocol); break; } } } fromIndex = index + 1; index = requestedProtocols.indexOf(',', fromIndex); } // while protocol = requestedProtocols.substring(fromIndex); } if (protocol != null) { protocol = protocol.trim(); if (protocol.length() > 0) { /* * Check to see if the requested protocol is among the * supported protocols, i.e., may be enabled */ for (int i = 0; supportedProtocols != null && i < supportedProtocols.length; i++) { if (supportedProtocols[i].equals(protocol)) { if (vec == null) { vec = new Vector(); } vec.addElement(protocol); break; } } } } if (vec != null) { enabledProtocols = new String[vec.size()]; vec.copyInto(enabledProtocols); } } return enabledProtocols; }