Quantcast
Channel: SCN : Discussion List - SAP Business Process Management
Viewing all articles
Browse latest Browse all 791

How to get Current logged in User using UME api?

$
0
0

Hi All

I am new and learning UME API. On start I am trying to get the current user I am logged in with and wanted to display in UI5 application.


On first step I have created a small webservice to get the current user. below is the code.


************************

import javax.ejb.Stateless;

 

 

import com.incture.dto.userDto;

import com.sap.security.api.IUser;

import com.sap.security.api.UMFactory;

import javax.jws.WebService;

import javax.jws.WebMethod;

 

 

/**

* Session Bean implementation class userInfo

*/

@WebService(name = "userInfo", portName = "userInfoPort", serviceName = "userInfoService", targetNamespace = "http://incture.com/service/")

@Stateless

public class userInfo implements userInfoLocal {

 

 

    /**

     * Default constructor.

     */

    public userInfo() {

        // TODO Auto-generated constructor stub

    }

 

 

    @WebMethod(operationName = "UserDetial", exclude = false)

  public userDto UserDetial()

    {

         userDto userInfoDto = new userDto();

  

         try

         {

             IUser user2 = UMFactory.getAuthenticator().getLoggedInUser();

              userInfoDto.setName(user2.getDisplayName());

              userInfoDto.setCity(user2.getFirstName());

              userInfoDto.setCellPhone(user2.getCellPhone());

              userInfoDto.setCountry(user2.getCountry());

         }

    catch(Exception e)

    {

    e.printStackTrace();

   }
  
  
   return userInfoDto;

    }

}

********************************************************************************************

The Dto Code is as fallows


import javax.xml.bind.annotation.XmlRootElement;

 

 

@XmlRootElement

public class userDto {

 

  private String name;

  private String city;

  private String cellPhone;

  private String country;

  public String getName() {

  return name;

  }

  public void setName(String name) {

  this.name = name;

  }

  public String getCity() {

  return city;

  }

  public void setCity(String city) {

  this.city = city;

  }

  public String getCellPhone() {

  return cellPhone;

  }

  public void setCellPhone(String cellPhone) {

  this.cellPhone = cellPhone;

  }

  public String getCountry() {

  return country;

  }

  public void setCountry(String country) {

  this.country = country;

  }

 

 

 

}

 

Now I am querying with WSNavigator to test the service. It always return "Guest" as user but I am logged in with other one.

Capture2.PNG

Thanks

Rohit Raja


Viewing all articles
Browse latest Browse all 791

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>