2011-10-27 14 views
1

Google検索アプライアンスを管理し、そのアクセス制御リスト(ACL)を変更するための認証キーを取得しようとしています。GSA API - 認証トークンを取得できません

これは私のコードです:

SocketAddress proxyAddress = new InetSocketAddress(PROXY_HOST,PROXY_PORT); 
    Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress); 
    URL clientLoginUrl = new URL("https://my.server.com:8443/accounts/ClientLogin"); 
    HttpURLConnection clientLoginSecureConnection = 
     (HttpURLConnection)clientLoginUrl.openConnection(proxy); 
    clientLoginSecureConnection.setDoInput(true); 
    clientLoginSecureConnection.setDoOutput(true); 
    clientLoginSecureConnection.setUseCaches(false); 
    clientLoginSecureConnection.setRequestProperty("Content-Type",   
     "application/x-www-form-urlencoded"); 
    StringBuilder content = new StringBuilder(); 
    content.append("Email=").append(
    URLEncoder.encode(Constants.GSA_AUTH_USER, "UTF-8")); 
    content.append("&Passwd=").append(
    URLEncoder.encode(Constants.GSA_AUTH_PASSWORD, "UTF-8")); 
    OutputStream outputStream = clientLoginSecureConnection.getOutputStream(); 
    outputStream.write(content.toString().getBytes("UTF-8")); 
    outputStream.close(); 
    // Retrieve the output 
    int responseCode = clientLoginSecureConnection.getResponseCode(); 
    System.out.println("Response code: " + responseCode); 
    InputStream inputStream; 
    if (responseCode == HttpURLConnection.HTTP_OK) { 
     inputStream = clientLoginSecureConnection.getInputStream(); 
    } else { 
     inputStream = clientLoginSecureConnection.getErrorStream(); 
    } 
    String postOutput = toString(inputStream); 
    StringTokenizer tokenizer = new StringTokenizer(postOutput, "=\n "); 
    String key = null; 
    while (tokenizer.hasMoreElements()) { 
     if (tokenizer.nextToken().equalsIgnoreCase("Auth")) { 
      if (tokenizer.hasMoreElements()) { 
       key = tokenizer.nextToken(); 
      } 
      break; 
     } 
    } 
    if (key == null) { 
    System.out.println("Error response from server:\n" + postOutput); 
    } else { 
     System.out.println("Key found: " + key); 
} 

私が指示hereに従っているが、私は常にこの例外を取得:

javax.net.ssl.SSLHandshakeException:リモートホストはハンドシェイクの間に接続 を閉じましたat com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:808) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketI mpl.java:1120) で com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1147で ) com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake( SSLSocketImpl.java:1131) でsun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434) でsun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java: 166) でsun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:904) sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)で sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)でsun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブメソッド) でcom.mycompany.gslisting.GetKeysTestCase.testGetAccessControlListKeys(GetKeysTestCase.java:90) ATで sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 、java.lang.reflect.Method.invoke(Method.java:597)at junit.framework.TestCase.runTest(TestCase.java:168)at junit.framework.TestResult.runProtected(TestResult.java:128)で junit.framework.TestResult $ 1.protectで junit.framework.TestCase.runBare(TestCase.java:134)(TestResult.java:110) でj test.java:243)at junit.framework.TestCase.run org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.runで org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) でframework.TestSuite.run(TestSuite.java:238) (JUnit4TestReference.java:50) でorg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTestsで(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit。 org.eclipse.jdt.internal.junitでrunner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) でorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 。 (リモート・テスト・ラ) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl。java:789) ... 27 more

どのようなアイデアですか?

答えて

0

見つけました!

私はちょうどthis siteの指示に従った。 ブラウザ(Chrome)を使用してサイト証明書(.cer)をダウンロードし、次のコマンドを実行してデフォルトのキーストアにインポートしています。

関連する問題