cancel
Showing results for 
Search instead for 
Did you mean: 

Standard SAP login page

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

This will generate you standard logon page

The JARs to download are:

com.sap.security.api.jar

com.sap.security.api.perm.jar

Regards

Vikram