on 07-08-2009 9:48 AM
Hi,
I developed an servlet on NWDS, in a Web Module project. It is working perfect, but faced an authorization problem, during the development. I configured web.xml file according to FORM based authentication. The thing that I don't want is I need to develop a custom login screen, by choosing that way. Strangely, It is not working under SSO conditions, also. I want to authenticate users by "standard SAP login form". How can I achieve this?
Thank you
You need to download API's for this,
use the code below
// a util class
//download the JARs for these below APIs
import com.sap.security.api.IUser;
import com.sap.security.api.UMFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
import java.io.IOException;
public class LoggedInUser {
public String getLoggedInUser(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
IUser user = UMFactory.getAuthenticator().getLoggedInUser (request, response);
if (null==user)
{
//response.sendError(401); //401 = Unauthorised
UMFactory.getAuthenticator().forceLoggedInUser(request,response);
response.sendRedirect("anything.do");
}
String userId=request.getRemoteUser();
return userId;
}
}
And in ur first servlet that is mapped to init.do , use,
public class MainAction extends HttpServlet {
protected void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String userId = (String)request.getSession().getAttribute("userId");
if (userId == null) {
userId = new LoggedInUser().getLoggedInUser(request,response);
}
// rest of the code here
Thnx
Vikram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
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.