cancel
Showing results for 
Search instead for 
Did you mean: 

How to use an authenticated user for a proxy call

former_member198060
Participant
0 Kudos

Dear all,

I am currently working on a JEE application where the user needs to authenticate (for this I have configured the web.xml).

Now inside this application I need to do a proxy call to a PI webservice.

I would like to use the user credentials of the already logged in user in order to call the proxy.

What I don't want to do is to use a service user for the proxy call.

The code I am trying to call looks something like this:


     private IntegratedConfigurationIn getPort() throws Exception{

          IntegratedConfigurationIn port = null;

          try {

               IntegratedConfigurationInService service = null;

               service = new IntegratedConfigurationInService();

               port = (IntegratedConfigurationIn) service.getIntegratedConfigurationIn_Port();

              BindingProvider bp = (BindingProvider)port;

              bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, user);

              bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);

              if (url.length() != 0)

                   bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);

          }

          catch (Exception ex){

               ex.printStackTrace();

          }

          return port;

     }

The examples I found to retrieve the userdata pointed to codes similar to this one:


public HttpServletRequest getHttpRequest() throws Exception {

          // Get runtime context

          Properties props = new Properties();

          props.put("domain", "true");

          Context initialContext = new InitialContext(props);

          ApplicationWebServiceContext wsContext = (ApplicationWebServiceContext) initialContext

                    .lookup(" /wsContext/ApplicationWebServiceContext");

          HttpServletRequest req = wsContext.getHttpServletRequest();

          return req;

     }

com.sap.security.api.IUser sapUser = com.sap.security.api.UMFactory.getAuthenticator().getLoggedInUser(getHttpRequest(), null);

          IUser ep5User = com.sapportals.wcm.util.usermanagement.WPUMFactory.getUserFactory().getEP5User(sapUser);

Now I don't know how to bring it togehter and how to use an authenticated user for the BindingProvider.

I would appreciate any hints or ideas.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Peter, the autheticated user is available from the portal request object. Get that one in your application and read from the UME all the properties you wanna get and build your web service call with it. It looks for me straight forward, what exactly is your problem?

cheers