📄 tlsconfiguration.java
字号:
} } } private static void assertNotNull(Object value, String message) { if (null == value) { throw new IllegalArgumentException(message); } } private static String defaultForNull(String value, String deflt) { if (null == value) { return deflt; } else { return value; } } public SSLSocketFactory getSocketFactory() throws NoSuchAlgorithmException, KeyManagementException { return getSslContext().getSocketFactory(); } public SSLServerSocketFactory getServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException { return getSslContext().getServerSocketFactory(); } public SSLContext getSslContext() throws NoSuchAlgorithmException, KeyManagementException { KeyManager[] keyManagers = null == getKeyManagerFactory() ? null : getKeyManagerFactory().getKeyManagers(); TrustManager[] trustManagers = null == getTrustManagerFactory() ? null : getTrustManagerFactory().getTrustManagers(); SSLContext context = SSLContext.getInstance(getSslType()); // TODO - nice to have a configurable random number source set here context.init(keyManagers, trustManagers, null); return context; } public String getSslType() { return sslType; } public void setSslType(String sslType) { this.sslType = sslType; } public Provider getProvider() { return provider; } public void setProvider(Provider provider) { this.provider = provider; } public String getProtocolHandler() { return protocolHandler; } public void setProtocolHandler(String protocolHandler) { this.protocolHandler = protocolHandler; } public SecurityProviderFactory getSecurityProviderFactory() { return spFactory; } public void setSecurityProviderFactory(SecurityProviderFactory spFactory) { this.spFactory = spFactory; } // access to the explicit key store variables public String getKeyStore() { return keyStoreName; } public void setKeyStore(String name) throws IOException { keyStoreName = name; if (null != keyStoreName) { keyStoreName = FileUtils.getResourcePath(keyStoreName, getClass()); if (logger.isDebugEnabled()) { logger.debug("Normalised keyStore path to: " + keyStoreName); } } } public String getKeyPassword() { return keyPassword; } public void setKeyPassword(String keyPassword) { this.keyPassword = keyPassword; } public String getKeyStorePassword() { return keyStorePassword; } public void setKeyStorePassword(String storePassword) { this.keyStorePassword = storePassword; } public String getKeyStoreType() { return keystoreType; } public void setKeyStoreType(String keystoreType) { this.keystoreType = keystoreType; } public String getKeyManagerAlgorithm() { return keyManagerAlgorithm; } public void setKeyManagerAlgorithm(String keyManagerAlgorithm) { this.keyManagerAlgorithm = keyManagerAlgorithm; } public KeyManagerFactory getKeyManagerFactory() { return keyManagerFactory; } // access to the implicit key store variables public String getClientKeyStore() { return clientKeyStoreName; } public void setClientKeyStore(String name) throws IOException { clientKeyStoreName = name; if (null != clientKeyStoreName) { clientKeyStoreName = FileUtils.getResourcePath(clientKeyStoreName, getClass()); if (logger.isDebugEnabled()) { logger.debug("Normalised clientKeyStore path to: " + clientKeyStoreName); } } } public String getClientKeyStorePassword() { return clientKeyStorePassword; } public void setClientKeyStorePassword(String clientKeyStorePassword) { this.clientKeyStorePassword = clientKeyStorePassword; } public void setClientKeyStoreType(String clientKeyStoreType) { this.clientKeyStoreType = clientKeyStoreType; } public String getClientKeyStoreType() { return clientKeyStoreType; } // access to trust store variables public String getTrustStore() { return trustStoreName; } public void setTrustStore(String name) throws IOException { trustStoreName = name; if (null != trustStoreName) { trustStoreName = FileUtils.getResourcePath(trustStoreName, getClass()); if (logger.isDebugEnabled()) { logger.debug("Normalised trustStore path to: " + trustStoreName); } } } public String getTrustStorePassword() { return trustStorePassword; } public void setTrustStorePassword(String trustStorePassword) { this.trustStorePassword = trustStorePassword; } public String getTrustStoreType() { return trustStoreType; } public void setTrustStoreType(String trustStoreType) { this.trustStoreType = trustStoreType; } public String getTrustManagerAlgorithm() { return trustManagerAlgorithm; } public void setTrustManagerAlgorithm(String trustManagerAlgorithm) { this.trustManagerAlgorithm = defaultForNull(trustManagerAlgorithm, spInfo.getKeyManagerAlgorithm()); } public TrustManagerFactory getTrustManagerFactory() { return trustManagerFactory; } public void setTrustManagerFactory(TrustManagerFactory trustManagerFactory) { this.trustManagerFactory = trustManagerFactory; } public boolean isExplicitTrustStoreOnly() { return explicitTrustStoreOnly; } public void setExplicitTrustStoreOnly(boolean explicitTrustStoreOnly) { this.explicitTrustStoreOnly = explicitTrustStoreOnly; } public boolean isRequireClientAuthentication() { return requireClientAuthentication; } public void setRequireClientAuthentication(boolean requireClientAuthentication) { this.requireClientAuthentication = requireClientAuthentication; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -