2014-10-12 39 views
0

安全適配器我們有一對夫婦的聲明安全程序的HTTP適配器如下:調用在IBM使用適配器調用服務工作燈

<wl:adapter name="PushAdapter" ... 
    . 
    . 
<procedure name="submitNotification" securityTest="AdapterSecurityTest"/> 
<procedure name="submitNotificationMass" securityTest="AdapterSecurityTest"/> 

安全測試使用基於適配器的認證如下執行:

<securityTests> 
    <mobileSecurityTest name="AdapterSecurityTest"> 
     <testUser realm="MyRealm"/> 
     <testDeviceId provisioningType="none"/> 
    </mobileSecurityTest> 
</securityTests> 

<realms> 
    <realm name="MyRealm" loginModule="NonValidatingLoginModule"> 
     <className>com.worklight.integration.auth.AdapterAuthenticator</className> 
     <parameter name="login-function">AuthenticationAdapter.onAuthRequired</parameter> 
     <parameter name="logout-function">AuthenticationAdapter.onLogout</parameter> 
    </realm> 
</realms> 

我們需要能夠使用適配器調用服務在HTTP中調用適配器過程。使用調用服務,調用URL應如下:

http://<server>:<port>/<Context>/invoke?adapter=PushAdapter&procedure=submitNotification&parameters=[userId, notification text to be sent] 

調用的工作方式在程序安全測試設置爲「wl_unprotected」預期。但是如果使用安全測試,則調用返回以下響應:

/*-secure-{"WL-Authentication-Failure":{"wl_remoteDisableRealm":{"reason":"Login Failed"}}}*/ 

問題是,我們如何使用調用服務進行身份驗證?我們現在嘗試設置授權HTTP頭。

謝謝

+0

爲什麼要在啓用移動安全測試時通過調用URL驗證適配器? – Karikalan 2014-10-12 19:35:34

+0

我們有一個用例,我們希望後端系統通過使用適配器調用服務調用適配器過程來發起嚮應用程序用戶發送推送通知,但我們不希望URL發送通知是不安全的並向任何人公開。 – Hisham 2014-10-13 08:35:39

回答

2

我已經遵循的程序與來自工作燈6.2樣品的幫助適配器基於認證來實現。

第1步: 添加以下值在頭部,根據您的環境實績

x-wl-app-details:{"applicationDetails":{"platformVersion":"6.2.0.00.20140613-0730","nativeVersion":""}} 

x-wl-app-version:1.0 

請求:http://x.x.x.x:10080/AdapterBasedAuth/apps/services/api/SingleStepAuth/common/init

響應:

/*-secure- {"challenges":{"wl_antiXSRFRealm":{"WL-Instance-Id":"gi1cqaqd3p89763l1amoklsq3u"}}}*/ 

第2步:

添加WL-實例ID:gi1cqaqd3p89763l1amoklsq3u在這是先前響應的一部分

請求中的報頭: http://xx.xx.xx.xx:10080/AdapterBasedAuth/apps/services/api/SingleStepAuth/common/query?adapter=SingleStepAuthAdapter&procedure=submitAuthentication&parameters=['worklight','worklight']

響應:

/*-secure- 
{"isSuccessful":true,"WL-Authentication-Success":{"SingleStepAuthRealm":{"userId":"worklight","isUserAuthenticated":1,"attributes":{"foo":"bar"},"displayName":"worklight"},"wl_antiXSRFRealm":{"userId":"j136h3aus2v1vlbjr860mmossc","attributes":{},"isUserAuthenticated":1,"displayName":"j136h3aus2v1vlbjr860mmossc"},"wl_anonymousUserRealm":{"userId":"747809a4-3574-4958-a55a-f084b2c9f02c","attributes":{},"isUserAuthenticated":1,"displayName":"747809a4-3574-4958-a55a-f084b2c9f02c"}},"authRequired":false}*/ 

步驟3:

添加授權標題和以前回復的值

"SingleStepAuthRealm":{"userId":"worklight","isUserAuthenticated":1,"attributes":{"foo":"bar"},"displayName":"worklight"} 

請求:http://xx.xx.xx.xx:10080/AdapterBasedAuth/apps/services/api/SingleStepAuth/common/query?adapter=SingleStepAuthAdapter&procedure=getSecretData

響應:

/*-secure- 
{"isSuccessful":true,"secretData":"A very very very very secret data"}*/ 

爲了更多地瞭解這個過程中遵循此IBM Community Blog

我相信這是你在找什麼。

+0

謝謝:)我會測試這個,讓你知道它是怎麼回事。 – Hisham 2014-10-13 12:41:23

+0

對此有何更新? – Karikalan 2014-10-14 06:01:28

+0

這工作,對延遲抱歉。 – Hisham 2014-11-05 16:07:30

相關問題