Skip navigation
Clookes
Currently Being Moderated

Retrieving user context when service was invoked via REST

Sep 6, 2012 1:40 PM

Hi,

 

I have created a custom component with several operations which are exposed via REST endpoint.  My question is how do I retrieve the user context from the REST call that uses Basic Authenttication (set in the header) and then pass that user context for Java API to use accordingly?

 

 

Thanks in advance.

 
Replies
  • Currently Being Moderated
    Sep 6, 2012 3:01 PM   in reply to Clookes

    You can't set or get user context for your service using web services.

     

    You'll have to,

    1. Create an instance of ServiceClientFactory.

    2. Authenticate using AuthenticationManager Service and get the AuthResult.

    3. Initialize the Context by passing the AuthResult as shown below,

     

     

    ServiceClientFactory factory = ServiceClientFactory.createInstance(properties);
    AuthenticationManager authenticationManager = new AuthenticationManagerServiceClient(factory);
    AuthResult authResult = null;
      try {
            authResult = authenticationManager.authenticate("administrator", "password".getBytes());
         } catch (UMException e) {
              throw new RuntimeException(e);
         }
       com.adobe.idp.Context context = new com.adobe.idp.Context();
       context.initPrincipal(authResult);
     
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points