WebSphere Portal Server - Connecting to domino server the right way... using LTPAToken etc.

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > April 2005 > Connecting to domino server the right way... using LTPAToken etc.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Connecting to domino server the right way... using LTPAToken etc.
Lee Francis Wilhelmsen

2005-04-06, 7:53 am

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

2005-04-06, 5:58 pm

> - I want to use the portal's Content Access Service
> to perform
> the connection or by using an active credential.
> al. This is to use
> any connection settings configured by the portal
> (proxy server & port etc)


Hi Lee,

The CAS has a getURL method, used similarly to the other CAS methods, which will return a URL for you to use, and which will allow you to add the LTPAToken.

For example..

URL url = contentAccessService.getURL(<domino URL>, portletRequest, portletResponse);
URLConnection connection = url.openConnection();

//etc

Hope that helps,

Jimmy

2005-04-06, 5:58 pm


> URL url = contentAccessService.getURL(<domino URL>,
> portletRequest, portletResponse);


Should read:
URL url = contentAccessService.getURL(domino URL, portletRequest, portletResponse);
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com