IBM SBT: CommunityService.updateCommunityLogo(file, communityUuid) triggers logout?
我(想)使用 CommunityService.updateCommunityLogo(file, communityUuid) 为新创建的以编程方式创建的社区设置徽标。
调用虽然没有错误,但标志没有改变。
当我查看 apache.http.wire 日志时,它显示以下对话:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | >> 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">[\ ]" apache.http.wire(64): <<" document.cookie ="CommunitiesReqURL=" + location.href +"; expires=" +[\ ]" apache.http.wire(64): <<" new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString() +"; path=/communities";[\ ]" apache.http.wire(64): <<" location.href="/communities/service/html/login";[\ ]" apache.http.wire(64): <<"[\ ]" |
我已经从标题和线路中跳过了一些细节,如日期、内容字段等,但这基本上是发生的。
这又是来自 Web 应用程序内部的请求处理的一部分,它应该自动在 Connections 实例上执行一些操作。因此,作为结果,该 Web 应用程序会将原始用户请求的答案作为网页呈现给用户。这反过来又包含一个在此处更改的社区框架——但在此步骤之后,用户被迫在全窗口模式下重新登录 Connections(尽管 LTPA 令牌是"新鲜的")。
因此,我怀疑调用 CommunityService.updateCommunityLogo(file, communityUuid) 会强制重新认证并破坏/使当前 LTPA 令牌或已认证会话无效。
这里发生了什么?
我能做些什么呢?
备注:
我实际上无权访问任何连接日志。
Connections 实例是 v4.5,在 IBM SBT 中使用 BasicAuth 直接访问,但在浏览器中使用基于表单的身份验证。
SBT 版本为 1.0.2.20140527-1807,包含使用 maven 3.0.5,部署在 Java 7 上的 tomcat 7.0.53 上。
IBM SBT SDK 1.0.3 解决了这个问题:使用相同的应用程序代码和 1.0.2 / 1.0.3 进行的测试显示 1.0.2 在这里存在错误,但在 1.0.3 中这个问题已得到修复。
此外,服务器端已经从 IC 4.5 升级到 IC 5.0,但是对于 1.0.2 IBM SBT SDK,IC5 也不接受该徽标。因此它可能同时是:IC45 -> IC5 AND SBT 1.0.2 -> 1.0.3.
它实际上很可能与该 API 的 100 次继续有关
我在上面写了一篇文章 http://bastide.org/2014/06/19/expect-100/
对于 J2EE 应用程序,导航到 managed-beans.xml。找到要禁用它的端点,添加一个托管属性。
forceDisableExpectedContinue
真的
我为此编写的一些示例代码...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | 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(); } } |