04-06-05 12:53 PM
Hi
I've asked similar questions in the past and seen most of the postings
regarding this subject, but I'm still not satisfied. I'm using WPS 5.0.2
and Domino 6.5.1 server
My wishes:
- I want my portlets to connect to the domino backend using http
and using SSO.
- I want to use the portal's Content Access Service to perform
the connection or by using an active credential. This is to use
any connection settings configured by the portal
(proxy server & port etc)
Ok, so you have your portlet running in the portal, your domino and WPS
servers are configured to use SSO, you log on to the portal and the LTPA
cookie is set...
From what I have seen during my own experiments the following code will
work fine:
String ltpaToken = null;
Cookie[] cookies = request.getCookies();
for (int i = 0; i < cookies.length; i++) {
if (cookies[i].getName().equals("LtpaToken")) {
ltpaToken = cookies[i].getValue();
break;
}
}
// seems to work... problem is not using content access service
if (ltpaToken != null) {
String cookie = "LtpaToken=" + ltpaToken.toString();
URL url = new URL(domino url);
URLConnection connection = url.openConnection();
connection.setRequestProperty("cookie", cookie);
connection.connect();
InputStream input = connection.getInputStream();
// read input and do something...
} else {
// No LTPAToken cookie found
}
However, it doesn't use the content access service and also the code for
finding the token is messy.
I've seen the following code used in the infocentre:
PortletContext context = getPortletConfig().getContext();
CredentialVaultService service = (CredentialVaultService)
context.getService(CredentialVaultService.class);
Subject subject = service.getUserSubject(request);
System.out.println(subject.toString());
// seems to return empty array!!!
Object[] temp =
subject. getPrivateCredentials(LtpaTokenCredentia
l.class).toArray();
if (temp.length > 0) {
LtpaTokenCredential ltpaToken = (LtpaTokenCredential) temp[0];
URL url = new URL(domino url);
URLConnection connection =ltpaToken.getAuthenticatedConnection(url);
// Create the LTPA Cookie in the Header
String cookie = "LtpaToken=" + ltpaToken.toString();
// Set the LTPA token Cookie
connection.setRequestProperty("cookie", cookie);
connection.connect();
InputStream input = connection.getInputStream();
// read input and do something...
}
However, I can't get this code working.. I never get a valid
LtpaTokenCredential object and have no idea why. The temp array is
always empty.
Now, I would prefer to use the active credential (second alternative)
for connecting (using LtpaTokenCredential), but since I never get one
then that just ain't gonna happen. What can be wrong?
I have run these two procedures within two different methods on the same
portlet (from doView()) and one works, while the other can't find the
credential...
Really appreciate any help with this.
Regards
Lee Francis Wilhelmsen
[ Post a follow-up to this message ]
|