本文整理汇总了Java中org.mortbay.jetty.security.SslSocketConnector.setTrustPassword方法的典型用法代码示例。如果您正苦于以下问题:Java SslSocketConnector.setTrustPassword方法的具体用法?Java SslSocketConnector.setTrustPassword怎么用?Java SslSocketConnector.setTrustPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.security.SslSocketConnector
的用法示例。
在下文中一共展示了SslSocketConnector.setTrustPassword方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
/**
* Start the server, including a handler that responds with registered
* files, removes registered files on request, and gives 404 otherwise.
* Connection to this web host only possible with the shared certificate.
*/
protected void startServer() {
server = new Server();
//This sets up a secure connector
SslSocketConnector connector = new SslSocketConnector();
connector.setKeystore(KEYSTORE_PATH);
connector.setPassword(KEYSTORE_PASSWORD);
connector.setKeyPassword(KEY_PASSWORD);
connector.setTruststore(KEYSTORE_PATH);
connector.setTrustPassword(KEYSTORE_PASSWORD);
connector.setNeedClientAuth(true);
connector.setPort(port);
//This initialises the server.
server.addConnector(connector);
server.addHandler(new HTTPRemoteFileRegistryHandler());
try {
server.start();
} catch (Exception e) {
throw new IOFailure("Cannot start HTTPSRemoteFile registry", e);
}
}
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:28,代码来源:HTTPSRemoteFileRegistry.java
示例2: setUp
import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
this.servletTester = new ServletTester();
this.servletTester.addServlet(AppletServiceServlet.class, "/");
Security.addProvider(new BouncyCastleProvider());
KeyPair keyPair = generateKeyPair();
DateTime notBefore = new DateTime();
DateTime notAfter = notBefore.plusMonths(1);
X509Certificate certificate = generateSelfSignedCertificate(keyPair, "CN=localhost", notBefore, notAfter);
File tmpP12File = File.createTempFile("ssl-", ".p12");
LOG.debug("p12 file: " + tmpP12File.getAbsolutePath());
persistKey(tmpP12File, keyPair.getPrivate(), certificate, "secret".toCharArray(), "secret".toCharArray());
SslSocketConnector sslSocketConnector = new SslSocketConnector();
sslSocketConnector.setKeystore(tmpP12File.getAbsolutePath());
sslSocketConnector.setTruststore(tmpP12File.getAbsolutePath());
sslSocketConnector.setTruststoreType("pkcs12");
sslSocketConnector.setKeystoreType("pkcs12");
sslSocketConnector.setPassword("secret");
sslSocketConnector.setKeyPassword("secret");
sslSocketConnector.setTrustPassword("secret");
sslSocketConnector.setMaxIdleTime(30000);
int sslPort = getFreePort();
sslSocketConnector.setPort(sslPort);
this.servletTester.getContext().getServer().addConnector(sslSocketConnector);
this.sslLocation = "https://localhost:" + sslPort + "/";
this.servletTester.start();
this.location = this.servletTester.createSocketConnector(true);
SSLContext sslContext = SSLContext.getInstance("TLS");
TrustManager trustManager = new TestTrustManager(certificate);
sslContext.init(null, new TrustManager[] { trustManager }, null);
SSLContext.setDefault(sslContext);
}
示例3: setUp
import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
this.servletTester = new ServletTester();
this.servletHolder = this.servletTester.addServlet(AppletServiceServlet.class, "/");
Security.addProvider(new BouncyCastleProvider());
KeyPair keyPair = generateKeyPair();
DateTime notBefore = new DateTime();
DateTime notAfter = notBefore.plusMonths(1);
this.certificate = generateSelfSignedCertificate(keyPair, "CN=localhost", notBefore, notAfter);
File tmpP12File = File.createTempFile("ssl-", ".p12");
LOG.debug("p12 file: " + tmpP12File.getAbsolutePath());
persistKey(tmpP12File, keyPair.getPrivate(), this.certificate, "secret".toCharArray(), "secret".toCharArray());
SslSocketConnector sslSocketConnector = new SslSocketConnector();
sslSocketConnector.setKeystore(tmpP12File.getAbsolutePath());
sslSocketConnector.setTruststore(tmpP12File.getAbsolutePath());
sslSocketConnector.setTruststoreType("pkcs12");
sslSocketConnector.setKeystoreType("pkcs12");
sslSocketConnector.setPassword("secret");
sslSocketConnector.setKeyPassword("secret");
sslSocketConnector.setTrustPassword("secret");
sslSocketConnector.setMaxIdleTime(30000);
int sslPort = getFreePort();
sslSocketConnector.setPort(sslPort);
this.servletTester.getContext().getServer().addConnector(sslSocketConnector);
this.sslLocation = "https://localhost:" + sslPort + "/";
this.servletTester.start();
SSLContext sslContext = SSLContext.getInstance("TLS");
TrustManager trustManager = new TestTrustManager(this.certificate);
sslContext.init(null, new TrustManager[] { trustManager }, null);
SSLContext.setDefault(sslContext);
}
示例4: getSSLConnector
import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
private Connector getSSLConnector() {
SslSocketConnector sslConnector = new SslSocketConnector();
sslConnector.setPort(getPort());
sslConnector.setKeyPassword(getHttpsHost().getKeyStorePassword());
sslConnector.setKeystore(getHttpsHost().getKeyStorePath());
sslConnector.setTruststore(getHttpsHost().getTrustStorePath());
sslConnector.setTrustPassword(getHttpsHost().getTrustStorePassword());
return sslConnector;
}
示例5: getSslSocketConnector
import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
private static SslSocketConnector getSslSocketConnector(String hostname) {
String password = "changeit";
SslSocketConnector conn = new SslSocketConnector();
conn.setPort(8443);
File userHome = new File(System.getProperty("user.home"));
File geoserverDir = new File(userHome, ".geoserver");
if (geoserverDir.exists() == false)
geoserverDir.mkdir();
File keyStoreFile = new File(geoserverDir, "keystore.jks");
try {
assureSelfSignedServerCertificate(hostname, keyStoreFile, password);
} catch (Exception e) {
log.log(Level.WARNING, "NO SSL available", e);
return null;
}
conn.setKeystore(keyStoreFile.getAbsolutePath());
conn.setKeyPassword(password);
conn.setPassword(password);
File javaHome = new File(System.getProperty("java.home"));
File cacerts = new File(javaHome, "lib");
cacerts = new File(cacerts, "security");
cacerts = new File(cacerts, "cacerts");
if (cacerts.exists() == false)
return null;
conn.setTruststore(cacerts.getAbsolutePath());
conn.setTrustPassword("changeit");
return conn;
}
示例6: build
import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
public HttpServer2 build() throws IOException {
Preconditions.checkNotNull(name, "name is not set");
Preconditions.checkState(!endpoints.isEmpty(), "No endpoints specified");
if (hostName == null) {
hostName = endpoints.get(0).getHost();
}
if (this.conf == null) {
conf = new Configuration();
}
HttpServer2 server = new HttpServer2(this);
if (this.securityEnabled) {
server.initSpnego(conf, hostName, usernameConfKey, keytabConfKey);
}
for (URI ep : endpoints) {
final Connector listener;
String scheme = ep.getScheme();
if ("http".equals(scheme)) {
listener = HttpServer2.createDefaultChannelConnector();
} else if ("https".equals(scheme)) {
SslSocketConnector c = new SslSocketConnectorSecure();
c.setHeaderBufferSize(1024*64);
c.setNeedClientAuth(needsClientAuth);
c.setKeyPassword(keyPassword);
if (keyStore != null) {
c.setKeystore(keyStore);
c.setKeystoreType(keyStoreType);
c.setPassword(keyStorePassword);
}
if (trustStore != null) {
c.setTruststore(trustStore);
c.setTruststoreType(trustStoreType);
c.setTrustPassword(trustStorePassword);
}
listener = c;
} else {
throw new HadoopIllegalArgumentException(
"unknown scheme for endpoint:" + ep);
}
listener.setHost(ep.getHost());
listener.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
server.addListener(listener);
}
server.loadListeners();
return server;
}
示例7: build
import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
public HttpServer2 build() throws IOException {
if (this.name == null) {
throw new HadoopIllegalArgumentException("name is not set");
}
if (endpoints.size() == 0 && connector == null) {
throw new HadoopIllegalArgumentException("No endpoints specified");
}
if (hostName == null) {
hostName = endpoints.size() == 0 ? connector.getHost() : endpoints.get(
0).getHost();
}
if (this.conf == null) {
conf = new Configuration();
}
HttpServer2 server = new HttpServer2(this);
if (this.securityEnabled) {
server.initSpnego(conf, hostName, usernameConfKey, keytabConfKey);
}
if (connector != null) {
server.addUnmanagedListener(connector);
}
for (URI ep : endpoints) {
Connector listener = null;
String scheme = ep.getScheme();
if ("http".equals(scheme)) {
listener = HttpServer2.createDefaultChannelConnector();
} else if ("https".equals(scheme)) {
SslSocketConnector c = new SslSocketConnectorSecure();
c.setHeaderBufferSize(1024*64);
c.setNeedClientAuth(needsClientAuth);
c.setKeyPassword(keyPassword);
if (keyStore != null) {
c.setKeystore(keyStore);
c.setKeystoreType(keyStoreType);
c.setPassword(keyStorePassword);
}
if (trustStore != null) {
c.setTruststore(trustStore);
c.setTruststoreType(trustStoreType);
c.setTrustPassword(trustStorePassword);
}
listener = c;
} else {
throw new HadoopIllegalArgumentException(
"unknown scheme for endpoint:" + ep);
}
listener.setHost(ep.getHost());
listener.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
server.addManagedListener(listener);
}
server.loadListeners();
return server;
}
示例8: build
import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
public HttpServer build() throws IOException {
// Do we still need to assert this non null name if it is deprecated?
if (this.name == null) {
throw new HadoopIllegalArgumentException("name is not set");
}
// Make the behavior compatible with deprecated interfaces
if (bindAddress != null && port != -1) {
try {
endpoints.add(0, new URI("http", "", bindAddress, port, "", "", ""));
} catch (URISyntaxException e) {
throw new HadoopIllegalArgumentException("Invalid endpoint: "+ e);
}
}
if (endpoints.size() == 0 && connector == null) {
throw new HadoopIllegalArgumentException("No endpoints specified");
}
if (hostName == null) {
hostName = endpoints.size() == 0 ? connector.getHost() : endpoints.get(
0).getHost();
}
if (this.conf == null) {
conf = new Configuration();
}
HttpServer server = new HttpServer(this);
if (this.securityEnabled) {
server.initSpnego(conf, hostName, usernameConfKey, keytabConfKey);
}
if (connector != null) {
server.addUnmanagedListener(connector);
}
for (URI ep : endpoints) {
Connector listener = null;
String scheme = ep.getScheme();
if ("http".equals(scheme)) {
listener = HttpServer.createDefaultChannelConnector();
} else if ("https".equals(scheme)) {
SslSocketConnector c = new SslSocketConnectorSecure();
c.setNeedClientAuth(needsClientAuth);
c.setKeyPassword(keyPassword);
if (keyStore != null) {
c.setKeystore(keyStore);
c.setKeystoreType(keyStoreType);
c.setPassword(keyStorePassword);
}
if (trustStore != null) {
c.setTruststore(trustStore);
c.setTruststoreType(trustStoreType);
c.setTrustPassword(trustStorePassword);
}
listener = c;
} else {
throw new HadoopIllegalArgumentException(
"unknown scheme for endpoint:" + ep);
}
listener.setHost(ep.getHost());
listener.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
server.addManagedListener(listener);
}
server.loadListeners();
return server;
}
示例9: build
import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
public HttpServer2 build() throws IOException {
if (this.name == null) {
throw new HadoopIllegalArgumentException("name is not set");
}
if (endpoints.size() == 0 && connector == null) {
throw new HadoopIllegalArgumentException("No endpoints specified");
}
if (hostName == null) {
hostName = endpoints.size() == 0 ? connector.getHost() : endpoints.get(
0).getHost();
}
if (this.conf == null) {
conf = new Configuration();
}
HttpServer2 server = new HttpServer2(this);
if (this.securityEnabled) {
server.initSpnego(conf, hostName, usernameConfKey, keytabConfKey);
}
if (connector != null) {
server.addUnmanagedListener(connector);
}
for (URI ep : endpoints) {
Connector listener = null;
String scheme = ep.getScheme();
if ("http".equals(scheme)) {
listener = HttpServer2.createDefaultChannelConnector();
} else if ("https".equals(scheme)) {
SslSocketConnector c = new SslSocketConnector();
c.setNeedClientAuth(needsClientAuth);
c.setKeyPassword(keyPassword);
if (keyStore != null) {
c.setKeystore(keyStore);
c.setKeystoreType(keyStoreType);
c.setPassword(keyStorePassword);
}
if (trustStore != null) {
c.setTruststore(trustStore);
c.setTruststoreType(trustStoreType);
c.setTrustPassword(trustStorePassword);
}
listener = c;
} else {
throw new HadoopIllegalArgumentException(
"unknown scheme for endpoint:" + ep);
}
listener.setHost(ep.getHost());
listener.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
server.addManagedListener(listener);
}
server.loadListeners();
return server;
}