@Override public String getMimeMappings() { JSONObject jsonObj = new JSONObject(); try { Map<String, String> mimeMappings = serviceDefaultsContext.getMimeMappings(); if (mimeMappings != null) { for (String extension : mimeMappings.keySet()) { jsonObj.put(extension, mimeMappings.get(extension)); } } } catch (Exception ex) { // This is only for JSON exceptions, but there should be no way to // hit this. } return jsonObj.toString(); }
// Note: the following is copied and modified from ServiceConfigurationBeanImpl @Override public String getAcceptOptions() { JSONObject jsonOptions = new JSONObject(); JSONObject jsonObj; AcceptOptionsContext context = serviceDefaultsContext.getAcceptOptionsContext(); try { if (context != null) { Map<String, Object> acceptOptions = context.asOptionsMap(); Map<String, String> binds = context.getBinds(); if ((binds != null) && !binds.isEmpty()) { jsonObj = new JSONObject(); for (String key : binds.keySet()) { jsonObj.put(key, binds.get(key)); } jsonOptions.put("binds", jsonObj); } String[] sslCiphers = (String[]) acceptOptions.remove("ssl.ciphers"); if (sslCiphers != null && sslCiphers.length > 0) { jsonOptions.put("ssl.ciphers", Utils.asCommaSeparatedString(asList(sslCiphers))); } boolean isSslEncryptionEnabled = (Boolean) acceptOptions.remove("ssl.encryptionEnabled"); jsonOptions.put("ssl.encryption", isSslEncryptionEnabled ? "enabled" : "disabled"); boolean wantClientAuth = (Boolean) acceptOptions.remove("ssl.wantClientAuth"); boolean needClientAuth = (Boolean) acceptOptions.remove("ssl.needClientAuth"); if (needClientAuth) { jsonOptions.put("ssl.verify-client", "required"); } else if (wantClientAuth) { jsonOptions.put("ssl.verify-client", "optional"); } else { jsonOptions.put("ssl.verify-client", "none"); } jsonOptions.put("ws.maximum.message.size", acceptOptions.remove("ws.maxMessageSize")); Integer httpKeepAlive = (Integer) acceptOptions.remove("http[http/1.1].keepAliveTimeout"); if (httpKeepAlive != null) { jsonOptions.put("http.keepalive.timeout", httpKeepAlive); } String pipeTransport = (String) acceptOptions.remove("pipe.transport"); if (pipeTransport != null) { jsonOptions.put("pipe.transport", pipeTransport); } String tcpTransport = (String) acceptOptions.remove("tcp.transport"); if (tcpTransport != null) { jsonOptions.put("tcp.transport", tcpTransport); } String sslTransport = (String) acceptOptions.remove("ssl.transport"); if (sslTransport != null) { jsonOptions.put("ssl.transport", sslTransport); } String httpTransport = (String) acceptOptions.remove("http.transport"); if (httpTransport != null) { jsonOptions.put("http.transport", httpTransport); } long tcpMaxOutboundRate = (Long) acceptOptions.remove("tcp.maximumOutboundRate"); jsonOptions.put("tcp.maximum.outbound.rate", tcpMaxOutboundRate); for (Entry<String, Object> entry : acceptOptions.entrySet()) { String key = entry.getKey(); if (key.startsWith("ws") && (key.endsWith("maxMessageSize") || key.endsWith("inactivityTimeout") || key.endsWith("extensions"))) { // skip over options already seen with the base ws.* continue; } Object value = entry.getValue(); if (value instanceof String[]) { jsonOptions.put(key, Utils.asCommaSeparatedString(asList((String[]) value))); } else { jsonOptions.put(key, value); } } } } catch (Exception ex) { // This is only for JSON exceptions, but there should be no way to // hit this. } return jsonOptions.toString(); }
@Override public String getConnectOptions() { ConnectOptionsContext context = serviceDefaultsContext.getConnectOptionsContext(); JSONObject jsonOptions = new JSONObject(); try { if (context != null) { Map<String, Object> connectOptions = context.asOptionsMap(); String[] sslCiphersArray = (String[]) connectOptions.remove("ssl.ciphers"); if (sslCiphersArray != null) { List<String> sslCiphers = Arrays.asList(sslCiphersArray); if (sslCiphers.size() > 0) { jsonOptions.put("ssl.ciphers", sslCiphers); } } // NOTE: we do NOT (at least in 4.0) show the WS extensions // or WS protocols to users (Command Center or otherwise), so don't send them out. // WebSocketWireProtocol protocol = connectOptions.getWebSocketWireProtocol(); // sb.append("websocket-wire-protocol=" + protocol); String wsVersion = (String) connectOptions.remove("ws.version"); if (wsVersion != null) { jsonOptions.put("ws.version", wsVersion); } String pipeTransport = (String) connectOptions.remove("pipe.transport"); if (pipeTransport != null) { jsonOptions.put("pipe.transport", pipeTransport); } String tcpTransport = (String) connectOptions.remove("tcp.transport"); if (tcpTransport != null) { jsonOptions.put("tcp.transport", tcpTransport); } String sslTransport = (String) connectOptions.remove("ssl.transport"); if (sslTransport != null) { jsonOptions.put("ssl.transport", sslTransport); } String httpTransport = (String) connectOptions.remove("http.transport"); if (httpTransport != null) { jsonOptions.put("http.transport", httpTransport); } for (Entry<String, Object> entry : connectOptions.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof String[]) { jsonOptions.put(key, Utils.asCommaSeparatedString(asList((String[]) value))); } else { jsonOptions.put(key, value); } } } } catch (Exception ex) { // This is only for JSON exceptions, but there should be no way to // hit this. } return jsonOptions.toString(); }