static synchronized public void registerProtocol(String protocol, int port, Protocol handler) throws IllegalArgumentException { if(protocol == null) throw new IllegalArgumentException(); if(port < 0) port = 0; // port == 0 is wildcard, so use standard Protocol registry if(port == 0) {// look to the standard protocol registry if(handler == null) Protocol.unregisterProtocol(protocol); else Protocol.registerProtocol(protocol, handler); } else { for(int i = 0;i < registry.size();i++) { ProtocolEntry entry = registry.get(i); if(!entry.protocol.equals(protocol)) continue; if(entry.port != port) continue; if(handler == null) registry.remove(i); //delete else entry.handler = handler; // replace return; } registry.add(new ProtocolEntry(protocol, port, handler)); } }
/** * If set to <tt>true</tt>, the client will accept connections to any host, regardless of * whether they have valid certificates or not. This is especially useful when you are trying to * connect to a server with expired or corrupt certificates. * * @param useInsecureSSL whether or not to use insecure SSL * @throws GeneralSecurityException if a security error occurs */ public void setUseInsecureSSL(final boolean useInsecureSSL) throws GeneralSecurityException { if (useInsecureSSL) { final ProtocolSocketFactory factory = new InsecureSSLProtocolSocketFactory(); final Protocol https = new Protocol("https", factory, 443); Protocol.registerProtocol("https", https); } else { Protocol.unregisterProtocol("https"); } }
/** * If set to <tt>true</tt>, the client will accept connections to any host, regardless of * whether they have valid certificates or not. This is especially useful when you are trying to * connect to a server with expired or corrupt certificates. * * @param useInsecureSSL whether or not to use insecure SSL * @throws GeneralSecurityException if a security error occurs */ public void setUseInsecureSSL(final boolean useInsecureSSL) throws GeneralSecurityException { if (useInsecureSSL) { final ProtocolSocketFactory factory = new InsecureSSLProtocolSocketFactory(); final Protocol https = new Protocol("https", factory, 443); Protocol.registerProtocol("https", https); } else { Protocol.unregisterProtocol("https"); } }
/** * If set to <tt>true</tt>, the client will accept connections to any host, regardless of * whether they have valid certificates or not. This is especially useful when you are trying to * connect to a server with expired or corrupt certificates. * * @param useInsecureSSL whether or not to use insecure SSL * @throws GeneralSecurityException if a security error occurs */ public void setUseInsecureSSL(final boolean useInsecureSSL) throws GeneralSecurityException { if (useInsecureSSL) { final ProtocolSocketFactory factory = new InsecureSSLProtocolSocketFactory(); final Protocol https = new Protocol("https", factory, 443); Protocol.registerProtocol("https", https); } else { Protocol.unregisterProtocol("https"); } }