2014-06-25 27 views
0

我(希望)使用CommunityService.updateCommunityLogo(file,communityUuid)爲新創建的程序化社區設置徽標。IBM SBT:CommunityService.updateCommunityLogo(file,communityUuid)會觸發註銷?

該調用雖然沒有錯誤但運行正常,但徽標未更改。

當我看進apache.http.wire日誌,它顯示了以下的對話:

>> PUT /communities/service/html/image?communityUuid=6e700c5d-082c-497f-8657-d516a01f62e7 HTTP/1.1 (without data so far) 

<< HTTP/1.1 100 Continue 

>> (binary data of image) 

apache.http.wire(78): << "HTTP/1.1 100 Continue[EOL]" 
apache.http.wire(78): << "[EOL]" 
impl.conn.DefaultClientConnection(229): Receiving response: HTTP/1.1 100 Continue 
apache.http.headers(232): << HTTP/1.1 100 Continue 
apache.http.wire(78): << "HTTP/1.1 200 OK[EOL]" 
impl.conn.DefaultClientConnection(229): Receiving response: HTTP/1.1 200 OK 
apache.http.headers(232): << HTTP/1.1 200 OK 
apache.http.wire(64): << "<script language="JavaScript1.2">[\n]" 
apache.http.wire(64): << "  document.cookie = "CommunitiesReqURL=" + location.href + "; expires=" +[\n]" 
apache.http.wire(64): << "   new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString() + "; path=/communities";[\n]" 
apache.http.wire(64): << "  location.href = "/communities/service/html/login";[\n]" 
apache.http.wire(64): << "</script>[\n]" 

我跳過像日期,內容等領域,從頭部和線材的一些細節,但是這是基本發生。

這反過來又是Web應用程序內部的一個請求處理過程的一部分,該應用程序應該自動在Connections實例上執行一些操作。因此,這個Web應用程序將以網頁的形式向用戶提供原始用戶請求的答案。這反過來又包含了一個社區的框架,這個框架在這裏被改變 - 但是在這個步驟之後,用戶被強制以全窗口模式在Connections上重新登錄(儘管LTPA令牌是「新鮮的」)。

因此我懷疑調用CommunityService.updateCommunityLogo(文件,communityUuid)的部隊重新認證破壞/無效當前LTPA令牌或認證的會話。

這裏發生了什麼?

我該怎麼辦呢?

注:

我有任何連接日誌,其實用不上。

Connections實例是v4.5,可以在IBM SBT中使用BasicAuth直接訪問,但在瀏覽器中使用基於表單的身份驗證。

的SBT版本是1.0.2.20140527-1807,使用maven 3.0.5,Java的7部署在Tomcat 7.0.53

回答

0

IBM SBT SDK 1.0.3解決了這個問題:用相同的應用程序代碼和1.0.2/1.0的測試。 3透露1.0.2在這裏是bug,但在1.0.3中這個問題是固定的。

此外,服務器端從IC 4.5升級到IC 5.0,但使用1.0.2 IBM SBT SDK也不接受該標識。因此它可能是:IC45 - > IC5 SBT 1.0.2 - > 1.0.3。

0

它實際上是最有可能與100繼續爲API

包括

我寫了一篇文章http://bastide.org/2014/06/19/expect-100/ 對於J2EE應用程序,導航到managed-beans.xml。找到要禁用它的端點,添加託管屬性。 forceDisableExpectedContinue 真正

一些示例代碼,我寫了這個...

public static void main(String[] args){ 
     URL url; 
     try { 



      String imageUrl = "https://servername.com/communities/service/html/image?communityUuid=1e244250-6740-4949-aaac-682707a47099"; 
      String imageType = "image/png"; 

      String folder = "/Users/paulbastide/Desktop/"; 
      String fileName = "demo.png"; 
      File file = new File(folder + fileName); 
      long fileLength = 0l; 

      String userAgent = "Apache-HttpClient/4.3.3 (java 1.5)"; 
      String auth = "Basic ="; 

      url = new URL(imageUrl); 
      HttpsURLConnection httpCon = (HttpsURLConnection) url.openConnection(); 
      httpCon.setDoOutput(true); 

      //https://code.google.com/p/misc-utils/wiki/JavaHttpsUrl 
      // Create a trust manager that does not validate certificate chains 
      final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { 

       @Override 
       public java.security.cert.X509Certificate[] getAcceptedIssuers() { 
        return null; 
       } 
       @Override 
       public void checkClientTrusted(
         java.security.cert.X509Certificate[] arg0, String arg1) 
         throws CertificateException { 
        // TODO Auto-generated method stub 

       } 
       @Override 
       public void checkServerTrusted(
         java.security.cert.X509Certificate[] arg0, String arg1) 
         throws CertificateException { 
        // TODO Auto-generated method stub 

       } 
      } }; 

      // Install the all-trusting trust manager 
      final SSLContext sslContext = SSLContext.getInstance("SSL"); 
      sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); 
      // Create an ssl socket factory with our all-trusting manager 
      final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); 
      httpCon.setSSLSocketFactory(sslSocketFactory); 

      /** 
      * adds the cookies 
      */ 
      httpCon.setRequestProperty("Cookie", ""); 

      // Responds to two operations PUT and DELETE 
      httpCon.setRequestMethod("PUT"); 

      httpCon.setRequestProperty("Content-Type", imageType); 
      httpCon.setRequestProperty("slug", fileName); 
      httpCon.setRequestProperty("Content-Length", "" + fileLength); 
      httpCon.setRequestProperty("Content-Encoding", "binary"); 
      httpCon.setRequestProperty("User-Agent", userAgent); 
      httpCon.setRequestProperty("Authorization", auth); 

      byte[] fileBytes = FileUtils.readFileToByteArray(file); 

      DataOutputStream out = new DataOutputStream(
       httpCon.getOutputStream()); 
      out.write(fileBytes); 
      out.close(); 
      httpCon.getInputStream(); 

      System.out.println("The Response Code is " + httpCon.getResponseCode()); 

     } catch (MalformedURLException e) { 
      e.printStackTrace(); 
     } catch (ProtocolException e) { 
      e.printStackTrace(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } catch (NoSuchAlgorithmException e) { 
      e.printStackTrace(); 
     } catch (KeyManagementException e) { 
      e.printStackTrace(); 
     } 


    } 
+0

託管屬性起作用:在「我的」應用程序的瀏覽器中,用戶保持對Connections的身份驗證。 –

+0

但是,嘗試重定向到登錄頁面的JavaScript代碼段仍然存在。 –

+0

而最糟糕的是:社區徽標未更新。它仍然是「無」(3人計劃的默認圖像)。 –