on 06-26-2008 12:43 PM
Hi all,
I'm updating some old code today. The requirement is simply that if the user is not logged on to the portal we automagically log them on anonymously.
The force logon code that we're using is
UMFactory.getLogonAuthenticator().logon(req,res,"uidpwdlogon")
req and res are javax.servlet.http.req/res of course.
As such, it would appear that I'll need the HttpServletRequest and HttpServletResponse to call the method... so now you see the problem... it would appear that all previous routes to these objects are being blocked...
Originally this code was used (I didn't write it )
HttpServletRequest req = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();
HttpServletResponse res = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletResponse();
req.setAttribute(ILoginConstants.LOGON_UID_ALIAS, Const.ANONYMOUS_USER);
req.setAttribute(ILoginConstants.LOGON_PWD_ALIAS, Const.ANONYMOUS_PASSWORD);
OK, don't use IWebContextAdapter... noted.
So this code was written
HttpServletRequest req= (HttpServletRequest)WDProtocolAdapter.getProtocolAdapter().getRequestObject();
HttpServletResponse res= (HttpServletResponse)WDProtocolAdapter.getProtocolAdapter().getResponseObject();
WDScopeUtil.put(WDScopeType.CLIENTSESSION_SCOPE, ILoginConstants.LOGON_UID_ALIAS, Const.ANONYMOUS_USER);
WDScopeUtil.put(WDScopeType.CLIENTSESSION_SCOPE, ILoginConstants.LOGON_PWD_ALIAS, Const.ANONYMOUS_PASSWORD);
But now the cast from IWDRequest to HttpServletRequest throws a class cast exception... I'm told that it was previously possible to do it though.
So the question is; if all routes to HttpServletRequest and Response are blocked how can I call UMFactory.getLogonAuthenticator().logon(...)? Or put another way... what can I call to log the user on?
Thanks in advance,
Patrick.
Hi Patrick,
You can write a simple servlet which authenticate the user and then redirects to the WD application:
public class TestServlet extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
PrintWriter out = null;
String username = "omric";
String password = "WDisTheBestUIframeworkEver)-:";
try {
out = response.getWriter();
request.setAttribute("j_user", username);
request.setAttribute("j_password", password);
UMFactory.getLogonAuthenticator().logon(request,response,"uidpwdlogon");
response.sendRedirect("/webdynpro/dispatcher/<namespace>/<project>/<application>");
} catch (Exception ex) {
out.write("UME Exception --> " + ex.getMessage());
}
}
}
Omri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seriously though
Patrick.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure this might help.
WDClientUser.forceLoggedInClientUser();
This method checks whether the user is logged on, if not, show the logon page.
Check the api.
Hi,
Actually (if the user is not already logged on) we don't want the user to see the log on page... that's the behaviour we're trying to get rid of.
What happens is that we check to see if the user is logged on already... if so... great... if not (it'll mean that they're an external user and have no portal user)... we want to log them on to the portal anonymously; just so that they can use certain services.
Thanks for your time,
Patrick.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.