@@ -37,20 +37,20 @@ public class SSLTest {
3737 @ Test
3838 public void testSSLAuth () throws NoSuchAlgorithmException , KeyManagementException {
3939
40- // create a trust manager
41- // (note: a real application should verify certificates)
42- TrustManager naiveTrustMgr = new X509TrustManager () {
43- @ Override
44- public void checkClientTrusted (X509Certificate [] chain , String authType ) {
45- }
46- @ Override
47- public void checkServerTrusted (X509Certificate [] chain , String authType ) {
48- }
49- @ Override
50- public X509Certificate [] getAcceptedIssuers () {
51- return new X509Certificate [0 ];
52- }
53- };
40+ // create a trust manager
41+ // (note: a real application should verify certificates)
42+ TrustManager naiveTrustMgr = new X509TrustManager () {
43+ @ Override
44+ public void checkClientTrusted (X509Certificate [] chain , String authType ) {
45+ }
46+ @ Override
47+ public void checkServerTrusted (X509Certificate [] chain , String authType ) {
48+ }
49+ @ Override
50+ public X509Certificate [] getAcceptedIssuers () {
51+ return new X509Certificate [0 ];
52+ }
53+ };
5454
5555 // create an SSL context
5656 SSLContext sslContext = SSLContext .getInstance ("SSLv3" );
@@ -60,18 +60,18 @@ public X509Certificate[] getAcceptedIssuers() {
6060 DatabaseClient client = DatabaseClientFactory .newClient ("localhost" , 8012 , "MyFooUser" , "x" , Authentication .DIGEST , sslContext , SSLHostnameVerifier .ANY );
6161
6262
63- String expectedException = "FailedRequestException: Local message: write failed: Unauthorized " ;
63+ String expectedException = "com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated " ;
6464 String exception = "" ;
6565
66- // write doc
67- try
68- {
69- // make use of the client connection
66+ try {
67+ // make use of the client connection so we get an auth error
7068 TextDocumentManager docMgr = client .newTextDocumentManager ();
7169 String docId = "/example/text.txt" ;
7270 StringHandle handle = new StringHandle ();
7371 handle .set ("A simple text document" );
7472 docMgr .write (docId , handle );
73+ // the next line will only run if write doesn't throw an exception
74+ docMgr .delete (docId );
7575 }
7676 catch (Exception e ) {
7777 exception = e .toString ();
0 commit comments