2015-01-09 117 views
1

環境所擁有的會話:SESN0008E:認證爲匿名用戶試圖訪問用戶

  • MFP 6.3 Studio中的Windows 7
  • MFP 6.3服務器(WAS LC)

下載來自IBM MobileFirst Platform Developer Center的form-based sample

在MFP 6.3 Studio中,示例運行良好。

然後我更改我的構建設置和構建所有環境 - >獲取新的wlapp文件。

我從MFP 6.3服務器獲取我的戰爭文件。打開並放入修改後的authenticationConfig.xml 基本上它只是將一個片段從studio authenticationConfig.xml傳輸到WAR文件中的xml文件。

<customSecurityTest name="DummyAdapter-securityTest"> 
    <test isInternalUserID="true" realm="SampleAppRealm"/> 
</customSecurityTest>  

我重新啓動服務器並部署.wlapp和.adapter文件。

在獨立服務器中,我運行預覽模式。我輸入用戶名和密碼並登錄。它沒有登錄,我在服務器console.log上看到這些錯誤。

[ERROR ] SESN0008E: A user authenticated as anonymous has attempted to access a session owned by user:BasicRegistry/demo. 
[ERROR ] SRVE0232E: Internal Server Error. Exception Message: [com.ibm.ws.webcontainer.webapp.WebAppErrorReport: com.ibm.websphere.servlet.session.UnauthorizedSessionRequestException: SESN0008E: A user authenticated as anonymous has attempted to access a session owned by user:BasicRegistry/demo. 
    at com.ibm.ws.webcontainer.session.impl.HttpSessionContextImpl.checkSecurity(HttpSessionContextImpl.java:686) 
    at [internal classes] 
    at com.worklight.core.auth.impl.AuthenticationFilter.associateAuthContextWithThread(AuthenticationFilter.java:426) 
    at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:145) 
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:194) 
    at [internal classes] 
Caused by: com.ibm.websphere.servlet.session.UnauthorizedSessionRequestException: SESN0008E: A user authenticated as anonymous has attempted to access a session owned by user:BasicRegistry/demo. 
    ... 7 more 
] 
[ERROR ] SRVE0777E: Exception thrown by application class 'com.worklight.core.auth.impl.AuthenticationContext.checkAuthentication:604' 
com.worklight.server.auth.api.WorkLightAuthenticationException 
    at com.worklight.core.auth.impl.AuthenticationContext.checkAuthentication(AuthenticationContext.java:604) 
    at com.worklight.core.auth.impl.AuthenticationContext.processRealms(AuthenticationContext.java:469) 
    at com.worklight.core.auth.impl.AuthenticationContext.pushCurrentResource(AuthenticationContext.java:443) 
    at com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:75) 
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeProcedureInternal(DataAccessServiceImpl.java:430) 
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeProcedure(DataAccessServiceImpl.java:139) 
    at com.worklight.gadgets.serving.handler.BackendQueryHandler.getContent(BackendQueryHandler.java:95) 
    at com.worklight.gadgets.serving.handler.BackendQueryHandler.doPost(BackendQueryHandler.java:56) 
    at com.worklight.gadgets.serving.GadgetAPIServlet.doGetOrPost(GadgetAPIServlet.java:148) 
    at com.worklight.gadgets.serving.GadgetAPIServlet.doPost(GadgetAPIServlet.java:108) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:595) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1240) 
    at [internal classes] 
    at com.worklight.core.auth.impl.AuthenticationFilter$1.execute(AuthenticationFilter.java:217) 
    at com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:76) 
    at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:222) 
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:194) 
    at [internal classes] 

回答

0

在WAS和WAS Liberty配置文件中,缺省情況下啓用安全集成。這也意味着:

...會話管理設施將用戶的身份與他們的HTTP會話的 相關聯。此功能會將會話標記爲「擁有」 第一個訪問未被標記爲 的會話的用戶。

如果一個會話已被標記爲擁有,它將檢查 擁有者是否與當前用戶相同。如果不是,而不是 授予對該會話的訪問權限,則至少一個帶有標識符 的消息將被記錄,並且訪問會話將不會被授予 。

在某些情況下,UnauthorizedSessionRequestException拋出 ,並以消息SESN0008E爲原因。

在Eclipse的MobileFirst Development Server中,底層的WAS Liberty的server.xml已禁用此功能。

爲了您的POC作爲一種變通方法,您可以通過在server.xml文件中添加以下項禁用該功能:<httpSession securityIntegrationEnabled="false"/>

注意,增加這些設置是全局的所有應用程序,並可以對現有應用程序產生負面影響在服務器上,如果存在。

3

學習securityIntegrationEnabled =「假的解決方法後,我想我已經想通了,爲什麼事情的工作/不工作。

該解決方案實際上是不改變的server.xml非常簡單。

發生錯誤SESN0008E時,我正在通過單擊獨立服務器中管理控制檯的鏈接,使用通用預覽模式測試FormAuth應用程序。雖然公共預覽鏈接對新瀏覽器開放,但會話ID實際上保持不變。兩個瀏覽器標籤都在同一個會話中(我選中了)。

這意味着我正在使用的sessionID實際上是已經通過管理控制檯進行身份驗證的sessionID。在我的預覽模式下,我嘗試在已被另一用戶「擁有」的會話中再次進行驗證。這會導致WAS引發錯誤SESN0008E:通過匿名身份驗證的用戶嘗試訪問由用戶擁有的會話:BasicRegistry/demo。我的應用預覽與管理控制檯處於相同的httpsession中,因此出現錯誤。

所以爲了讓它起作用,我複製了預覽鏈接。關閉所有瀏覽器以確保會話被終止。打開一個新的瀏覽器,現在粘貼預覽鏈接和FormAuthentication的作品。

也許更方便的解決方案是創建一個移動Web環境並將其用於預覽測試。