cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a login method for SAP Netweaver in java

Former Member
0 Kudos

Hi

Can anyone help me out to make a login() method that can be used to login to the SAP Netweaver server using a simple java code..........

Hope a helpfull answers from u all....

THANKS in ADV.

Rupesh Khemka

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Everyone

I have made the login() method but i am facing the problem while making the resource context...Because in Resource Context it takes IUser of package

com.sapportals.portal.security.usermanagement.IUser but I have got IUser of package com.sap.security.api.IUser ...while type Casting it with below code it is giving ClassCAstException.......

public class NewSimpleServlet extends HttpServlet {

protected void doGet(

HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

StringBuffer s = new StringBuffer();

try {String j_user="epuser";

String j_password="Abcd1234";

request.setAttribute("j_user", j_user);

request.setAttribute("j_password", j_password);

javax.security.auth.Subject subject;

Set principals = UMFactory.getLogonAuthenticator().logon(request, response, "uidpwdlogon").getPrincipals();

i have problem with getting IUser object from set of principals. In javadoc is written: "In order to get an IUser object from this subject, call Subject.getPrincipals() and iterate through the returned Set of principals." so i tried to iterate but i was not able to get that IUser with any casting. Do u know how it should be?

IUser serviceUser = (IUser)subject.getPrincipals().iterator().next();

Now in resource Context

ResourceContext c = new ResourceContext(User);

Here resource context need IUser type object as parameter...

I also tried st like this

loggedUser = UMFactory.getAuthenticator().getLoggedInUser(request, response);

but loggedUser is not authenticated.

Can Anyone Help me Out...

Thanks

Rupesh Khemka

Former Member
0 Kudos

Hi

You are looking for standalone Java that just makes a connection to the portal with the userid and password or else you are developing a web based front end??

-Rudhras

Former Member
0 Kudos

HI Francesco,

I need to get the documents that resides in KM repository of SAP Netweaver...for that i should provide first the login() method that should connect to SAP Netweaver KM repository using user name & Password..

I have configured My SAP NW develo-per studio to my server ip address..But the method should use Username & password of the SAP user and check the authentication and then should give the required results.

I have used IUser interface & WPUMFactory as shown below

IUser serviceUser = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");

And i am passing this serviceuser to ResourceContext

ResourceContext c = new ResourceContext(serviceUser);

This is my code PLZ Help me

Regards,

Rupesh

Former Member
0 Kudos

Hi Rupesh,

witch is the component of netweaver you need to connect?

Regards

Francesco

Former Member
0 Kudos

Hi Francesco Bersani ,

Thanks for ur response.The pdf files send by u have already been read by me but there i can't find any worthful result considering my criteria . I want a simple java class that can connect to SAP Netweaver using username & password.....

Any help in this respect will be highly appreciated

Regards,

Rupesh Khemka