[Bug 362407] setTrustStore(Resource) -> setTrustStoreResource(R)

This commit is contained in:
David Rosell 2011-10-30 00:19:29 +02:00 committed by Jesse McConnell
parent 25f70e9060
commit c83b02c4a7
2 changed files with 68 additions and 1 deletions

View File

@ -1377,7 +1377,7 @@ public class SslContextFactory extends AbstractLifeCycle
/** Set the trust store resource.
* @param resource the trust store resource to set
*/
public void setTrustStore(Resource resource)
public void setTrustStoreResource(Resource resource)
{
checkNotStarted();

View File

@ -6,6 +6,7 @@ import java.io.FileInputStream;
import java.security.KeyStore;
import org.eclipse.jetty.http.ssl.SslContextFactory;
import org.eclipse.jetty.util.resource.Resource;
import org.junit.Test;
@ -72,4 +73,70 @@ public class SslContextFactoryTest
cf.start();
assertTrue(cf.getSslContext()!=null);
}
@Test
public void testNoTsResourceKs() throws Exception
{
Resource keystoreResource = Resource.newSystemResource("keystore");
SslContextFactory cf = new SslContextFactory();
cf.setKeyStoreResource(keystoreResource);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");
cf.start();
assertTrue(cf.getSslContext()!=null);
}
@Test
public void testResourceTsResourceKs() throws Exception
{
Resource keystoreResource = Resource.newSystemResource("keystore");
Resource truststoreResource = Resource.newSystemResource("keystore");
SslContextFactory cf = new SslContextFactory();
cf.setKeyStoreResource(keystoreResource);
cf.setTrustStoreResource(truststoreResource);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");
cf.setTrustStorePassword("storepwd");
cf.start();
assertTrue(cf.getSslContext()!=null);
}
@Test(expected = java.security.UnrecoverableKeyException.class)
public void testResourceTsResourceKsWrongPW() throws Exception
{
Resource keystoreResource = Resource.newSystemResource("keystore");
Resource truststoreResource = Resource.newSystemResource("keystore");
SslContextFactory cf = new SslContextFactory();
cf.setKeyStoreResource(keystoreResource);
cf.setTrustStoreResource(truststoreResource);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("wrong_keypwd");
cf.setTrustStorePassword("storepwd");
cf.start();
}
@Test(expected = java.io.IOException.class)
public void testResourceTsWrongPWResourceKs() throws Exception
{
Resource keystoreResource = Resource.newSystemResource("keystore");
Resource truststoreResource = Resource.newSystemResource("keystore");
SslContextFactory cf = new SslContextFactory();
cf.setKeyStoreResource(keystoreResource);
cf.setTrustStoreResource(truststoreResource);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");
cf.setTrustStorePassword("wrong_storepwd");
cf.start();
}
}