Skip to Content
author's profile photo Former Member
Former Member

How to get the authenticated user

Hi all,

I have a pickle of a problem, which I am trying to solve.

The portal we need to implement this on, has Companies implemented, which means something changes in the security model - and makes an authenticated user unreachable for me.

The usual way of getting the user:

com.sap.security.api.IUser sapUser = com.sap.security.api.UMFactory.getAuthenticator().getLoggedInUser();
IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);

... means that if I subsequently check for ep5User.isAuthenticated(), it always returns false (this is a webdynpro application, so there's no "request" object available to me).

What do I do next? I need the authenticated user, so I can connect to KM, and overwrite files - anonymous write/delete permissions is not allowed on this system.

Points will be awarded for any help 😊

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jul 10, 2007 at 06:48 AM

    I have narrowed the problem further down...

    This code returns an authenticated user, through the WDClientUser - factory:

      private IUser getResourceUser() throws UserManagementException { 
    	IWDClientUser wdClientUser;
    	com.sap.security.api.IUser sapUser;
    	com.sapportals.portal.security.usermanagement.IUser ep5User = null;
    	try {
    		wdClientUser = WDClientUser.getCurrentUser();
    		sapUser = wdClientUser.getSAPUser();
    	
    		ep5User = com.sapportals.wcm.util.usermanagement.WPUMFactory.getUserFactory().getEP5User(sapUser);
    	} catch (Exception e) {
    		wdComponentAPI.getMessageManager().reportException(e.getClass().getName() + " - " + e.getLocalizedMessage(), true);
    	}
    	
    	return ep5User;
      }
    

    ... however, my root problem is still there.

    I still can't overwrite any files though. Whenever I try to overwrite a file, by getting the IResource handle to it, and doing a .updateContent(IContent) - I get an error:

    "com.sapportals.wcm.repository.IOErrorException - error writing content"

    Can anyone help with what might be wrong?

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Brik,

      i had the same issue.

      Here is the solution:

      etrieve the HttpRequest using

      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;

      }

      and get the authenticated user from the http request:

      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);

      the com.sap.engine.interfaces.webservices.runtime.ApplicationWebServiceContext is located in the webservices_api.jar located in the folder j2ee\cluster\server0\bin\interfaces\webservices on your J2EE.

      Maybe it helps you for the future.

      Best regards

      Jochen

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.