简体   繁体   中英

Access Smartcloud User Profile using IBMSBT

We are using SBT as a proxy to access Smartcloud content via OAuth2. We need to retrieve profile details for the logged in user on the server side using Java. In order to do so we call new com.ibm.sbt.services.client.smartcloud.profiles.ProfileService("smartcloudOA2").getMyProfile() . This was working fine until I realized that the returned profile object contains deprecated user profile details.

When I try to get profile details using new com.ibm.sbt.services.client.connections.profiles.ProfileService("smartcloudOA2").getMyProfile() I get following exception :

java.lang.IllegalArgumentException: Missing parameter: connections 
     at com.ibm.sbt.services.client.base.URLPattern.checkNoMissingParameters(URLPattern.java:67) 
     at com.ibm.sbt.services.client.base.URLPattern.format(URLPattern.java:58) 
     at com.ibm.sbt.services.client.base.URLBuilder.format(URLBuilder.java:82) 
     at com.ibm.sbt.services.client.connections.profiles.ProfileUrls.format(ProfileUrls.java:69) 
     at com.ibm.sbt.services.client.connections.profiles.ProfileService.getMyUserId(ProfileService.java:879) 
     at com.ibm.sbt.services.client.connections.profiles.ProfileService.getMyProfile(ProfileService.java:894) 
     at de.timetoact.xcc.conf.CloudServlet.doGet(CloudServlet.java:53) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:575) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) 
     at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1274) 
     at [internal classes] 
     at com.ibm.sbt.util.SBTFilter.doFilter(SBTFilter.java:53) 
     at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:194) 
     at [internal classes]

This is how the managed-beans.xml looks like:

...
<!-- Default Environment -->
    <managed-bean>
        <managed-bean-name>defaultEnvironment</managed-bean-name>
        <managed-bean-class>com.ibm.sbt.jslibrary.SBTEnvironment
        </managed-bean-class>
        <managed-bean-scope>application</managed-bean-scope>
        <managed-property>
            <property-name>endpoints</property-name>
            <value>smartcloudOA2</value>
        </managed-property>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>smartcloudOA2</managed-bean-name>
        <managed-bean-class>com.ibm.sbt.services.endpoints.SmartCloudOAuth2Endpoint
        </managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
            <property-name>url</property-name>
            <value>%{smartcloud.url}</value>
        </managed-property>
        <managed-property>
            <property-name>appName</property-name>
            <value>%{smartcloud.appName}</value>
        </managed-property>
        <managed-property>
            <property-name>clientID</property-name>
            <value>%{smartcloud.clientID}</value>
        </managed-property>
        <managed-property>
            <property-name>clientSecret</property-name>
            <value>%{smartcloud.clientSecret}
            </value>
        </managed-property>
        <managed-property>
            <property-name>forceTrustSSLCertificate</property-name>
            <value>true</value>
        </managed-property>
        <managed-property>
            <property-name>credentialStore</property-name>
            <value>CredStore</value>
        </managed-property>
    </managed-bean>
... 

Is com.ibm.sbt.services.endpoints.SmartCloudOAuth2Endpoint compatible with com.ibm.sbt.services.client.connections.profiles.ProfileService ?

What is the best way to retrieve Smartcloud User Profile Information on the server side using SBT Java API?

Thanks Paul for fixing this issue - we do not get that exception anymore. But we still are not able to get the Profile object - when we call com.ibm.sbt.services.client.connections.profiles.ProfileService("smartcloudOA2").getMyProfile() it returns null. During debugging we saw that sbt is internally calling https://apps.na.collabserv.com/profiles/oauth/atom/profile.do?userid=[myid] in order to get my profile feed. And when we look at response closer, we see that the profile feed is not returned back, but the html for the smartcloud login page. When we call same url using sbt proxy via our web app smth like : https://localhost/ctx-root/service/proxy/smartcloudOA2/profiles/oauth/atom/profile.do?userid=[myid] , we get the same login page instead of profile feed. Can you please take a look at this issue again?

The issue is in getMyUserId when it passes into the namedurlpart. I've merged in a Fix.

NamedUrlPart commonPart = new NamedUrlPart("connections",ProfilesConstants.COMMON);
        String peopleApiUrl = ProfileUrls.MY_USER_ID.format(this,commonPart);

It'll be in our next build, you can pull the change from github.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM