Thanks in advance.
David Page
//relevant imports
import java.security.PrivilegedAction;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
import javax.servlet.http.Cookie;
import com.ibm.websphere.security.auth.WSSubject;
import com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl;
import com.ibm.ws.security.util.Base64Coder;
//This was an inner class that I defined to handle the execution of the
secured EJB call
class RMIAction implements PrivilegedAction {
public Object run() {
InvoiceForPmtRespDto[] invoices = null;
try {
//create an instance of the EJB and call the
protected method
return whatever;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
//This is the code within the servlet that handles the JAAS mumbo jumbo
(creation of the LoginContext and CallbackHandler, etc...)
Cookie[] cookies = null;
Cookie ltpaCookie = null;
if ((cookies = req.getCookies()) != null) for (int i=0; i<cookies.length;
i++) if (cookies[i].getName().equals("LtpaToken")) ltpaCookie =
cookies[i];
if (ltpaCookie != null) {
WSCallbackHandlerImpl cbHandler = new
WSCallbackHandlerImpl(Base64Coder.base64Decode(ltpaCookie.getValue().getBytes()));
LoginContext lc = new LoginContext("WSLogin",cbHandler);
lc.login();
Subject sub = lc.getSubject();
ejbReturnData = (EJBReturnDataType)WSSubject.doAs(sub,new
RMIAction());
}
A severe limitation of this is that the client application (the one which
the servlet above is running on) must be on the same domain as the server
that issued the LTPA cookie. If the client application is on a different
domain, then I don't think the cookie will be passed in the request to the
servlet. You could probabaly take care of this by storing the cookie
value as a session attribute when it is returned in the initial login
response header. Anyway, I'm still kind of new to all this, so if anyone
has an easier method of implementation, finds any problems with this, or
has any questions, then please feel free to post your comments. Uh, sorry
about digging around in your security module IBM, but the clock was
ticking and I was running out of options.
David Page
1) Omit the following line from the RMIAction class:
InvoiceForPmtRespDto[] invoices = null;
2) The decode(byte[]) method described in the paragraph below should be
base64Decode(byte[]).
The example code is correct and does not need to be changed.
<David...@dps.state.la.us> wrote in message
news:bnuapu$9que$1...@news.boulder.ibm.com...