@Override public SSLSupport getSSLSupport(Socket s) { return factory.getSSLSupport(s); } // START SJSAS 6439313
@Override public SSLSupport getSSLSupport(SSLEngine sslEngine) { return new JSSE14Support(sslEngine); }
public Object[] getPeerCertificateChain() throws IOException { return getPeerCertificateChain(false); }
@Override public ServerSocket createSocket(int port) throws IOException { if (!initialized) { init(); } ServerSocket socket = sslProxy.createServerSocket(port); initServerSocket(socket); return socket; }
/** * Gets the initialized key managers. */ protected KeyManager[] getKeyManagers(String algorithm, String keyAlias) throws Exception { KeyManager[] kms; String keystorePass = getKeystorePassword(); KeyStore ks = getKeystore(keystorePass); if (keyAlias != null && !ks.isKeyEntry(keyAlias)) { throw new IOException(sm.getString("jsse.alias_no_key_entry", keyAlias)); } KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); kmf.init(ks, keystorePass.toCharArray()); kms = kmf.getKeyManagers(); if (keyAlias != null) { for (int i = 0; i < kms.length; i++) { kms[i] = new JSSEKeyManager((X509KeyManager) kms[i], keyAlias); } } return kms; }
/** * Gets the SSL server's truststore. */ protected KeyStore getTrustStore() throws IOException { KeyStore ts = null; String truststore = (String) attributes.get("truststore"); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Truststore file= {0}", truststore); } String truststoreType = (String) attributes.get("truststoreType"); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Truststore type= {0}", truststoreType); } String truststorePassword = getTruststorePassword(); if (truststore != null && truststorePassword != null) { ts = getStore(truststoreType, truststore, truststorePassword); } return ts; }
/** * Gets the initialized trust managers. */ protected TrustManager[] getTrustManagers(String algorithm) throws Exception { String crlFile = (String) attributes.get("crlFile"); TrustManager[] tms = null; KeyStore trustStore = getTrustStore(); if (trustStore != null) { if (crlFile == null) { TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); tmf.init(trustStore); tms = tmf.getTrustManagers(); } else { TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); CertPathParameters params = getParameters(algorithm, crlFile, trustStore); ManagerFactoryParameters mfp = new CertPathTrustManagerParameters(params); tmf.init(mfp); tms = tmf.getTrustManagers(); } } return tms; }
/** * Configures the given SSL server socket with the requested cipher suites, protocol versions, and need for client * authentication */ protected void initServerSocket(ServerSocket ssocket) { if (!(ssocket instanceof SSLServerSocket)) { throw new IllegalArgumentException("The ServerSocket has to be SSLServerSocket"); } SSLServerSocket socket = (SSLServerSocket) ssocket; if (attributes.get("ciphers") != null) { socket.setEnabledCipherSuites(enabledCiphers); } String requestedProtocols = (String) attributes.get("protocols"); setEnabledProtocols(socket, getEnabledProtocols(socket, requestedProtocols)); // we don't know if client auth is needed - // after parsing the request we may re-handshake if(clientAuthNeed) { socket.setNeedClientAuth(clientAuthNeed); } else { socket.setWantClientAuth(clientAuthWant); } } }
public static SSLImplementation getInstance() throws ClassNotFoundException { for (String implementation : implementations) { try { return getInstance(implementation); } catch (Exception e) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Error creating " + implementation, e); } } } // If we can't instantiate any of these throw new ClassNotFoundException("Can't find any SSL implementation"); }
@Override public ServerSocketFactory getServerSocketFactory() { return factory.getSocketFactory(); }
@Override public ServerSocketFactory getSocketFactory() { return new JSSE14SocketFactory(); }
protected String getTruststorePassword() { String truststorePassword = (String) attributes.get("truststorePass"); if (truststorePassword == null) { truststorePassword = System.getProperty("javax.net.ssl.trustStorePassword"); if (truststorePassword == null) { truststorePassword = getKeystorePassword(); } } return truststorePassword; }
@Override protected void handShake() throws IOException { ssl.setNeedClientAuth(true); synchronousHandshake(ssl); }
/** * Returns a copy of the environment's default socket factory. */ public static synchronized ServerSocketFactory getDefault() { if (theFactory == null) { theFactory = new DefaultServerSocketFactory(); } try { return (ServerSocketFactory) theFactory.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e.getMessage()); } } }
/** * Gets the SSL server's keystore. */ protected KeyStore getKeystore(String pass) throws IOException { String keystoreFile = (String) attributes.get("keystore"); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Keystore file= {0}", keystoreFile); } String keystoreType = (String) attributes.get("keystoreType"); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Keystore type= {0}", keystoreType); } return getStore(keystoreType, keystoreFile, pass); } /*
@Override public ServerSocket createSocket(int port, int backlog, InetAddress ifAddress) throws IOException { if (!initialized) { init(); } ServerSocket socket = sslProxy.createServerSocket(port, backlog, ifAddress); initServerSocket(socket); return socket; }
@Override public SSLSupport getSSLSupport(SSLEngine sslEngine) { return factory.getSSLSupport(sslEngine); } // END SJSAS 6439313
@Override public SSLSupport getSSLSupport(Socket socket) { if (!(socket instanceof SSLSocket)) { throw new IllegalArgumentException("The Socket has to be SSLSocket"); } return new JSSE14Support((SSLSocket)socket); }
public static SSLImplementation getInstance(String className) throws ClassNotFoundException { if (className == null) { return getInstance(); } try { return (SSLImplementation) ((Class) Class.forName(className)).newInstance(); } catch (Exception e) { if (logger.isLoggable(Level.FINEST)) { logger.log(Level.FINEST, "Error loading SSL Implementation " + className, e); } throw new ClassNotFoundException("Error loading SSL Implementation " + className + " :" + e.toString()); } }
@Override public ServerSocket createSocket(int port, int backlog) throws IOException { if (!initialized) { init(); } ServerSocket socket = sslProxy.createServerSocket(port, backlog); initServerSocket(socket); return socket; }