ibm-connectionsibm-sbt

Authentication between Widget and SBT


Background

I need to display the list of Top 3 downloaded file, in an widget when a person logs into a Community.

I am using Social Business Toolkit at the backend to fetch that data, and send it as JSON string to the widget, to display the same.

Question:

To fetch the Files from the community via SBT requires authentication (endpoint access).

In this scenario how can the user credentials from iWidget be passed to the customized servlet, so that it can fetch all the files from the same Connections Community

I would avoid re-authentication as the user has already authenticated when he enters the Community.


Get the following error when called from the iWidget

java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest at org.apache.http.impl.client.AbstractHttpClient.determineTarget(AbstractHttpClient.java:584) at 
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554) at com.ibm.sbt.services.client.ClientService.executeRequest(ClientService.java:1108) at com.ibm.sbt.services.client.ClientService._xhr(ClientService.java:1071) at com.ibm.sbt.services.client.ClientService.execRequest(ClientService.java:1037) at com.ibm.sbt.services.client.ClientService.xhr(ClientService.java:997) at com.ibm.sbt.services.client.ClientService.get(ClientService.java:873) at com.ibm.sbt.services.client.ClientService.get(ClientService.java:869) at com.ibm.sbt.services.client.base.BaseService.retrieveData(BaseService.java:371) at com.ibm.sbt.services.client.base.BaseService.retrieveData(BaseService.java:395) at com.ibm.sbt.services.client.base.BaseService.retrieveData(BaseService.java:346) at com.ibm.sbt.services.client.base.BaseService.getEntities(BaseService.java:205) at com.ibm.sbt.services.client.connections.communities.CommunityService.getMyCommunities(CommunityService.java:260) at 
com.ibm.sbt.services.client.connections.communities.CommunityService.getMyCommunities(CommunityService.java:244) at com.ibm._jsp._Test._jspService(_Test.java:124) at 

This is what the Lib folder looks inside enter image description here


Solution

  • You should use the ConnectionsSSOEndpoint in your managed-beans.xml file

    <!-- Connections SSO -->    
    <managed-bean>
    <managed-bean-name>connections</managed-bean-name>
    <managed-bean-class>com.ibm.sbt.services.endpoints.ConnectionsSSOEndpoint</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>url</property-name>
    <value>${connectionsUrl}</value>
    </managed-property>
    <!-- Trust the connection -->
    <managed-property>
    <property-name>forceTrustSSLCertificate</property-name>
    <value>true</value>
    </managed-property>
    <managed-property>
    <property-name>serviceMaps</property-name>
    <value>${connectionsMaps}</value>
    </managed-property>
    </managed-bean>
    

    The SSO Endpoint uses the ltpatoken and ltpatoken2 tokens from the existing session to automatically log you in to the backend service