Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7185923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:31:21+00:00 2026-05-28T18:31:21+00:00

I´m using HTTP-Authentication based on my customer-table. After the user is authenticated a restful

  • 0

I´m using HTTP-Authentication based on my customer-table. After the user is authenticated a restful webservice is called. But how can I access in the webservice the HTTP-Authentication (the Header Data of the HttpRequest)?
My code looks like this:

@GET
@Path("{id}") 
@Produces({"application/xml"})
public ObjectList read(@PathParam("id") Integer id) {
... //how to get here the HTTP-Username and Password?
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:31:22+00:00Added an answer on May 28, 2026 at 6:31 pm

    In order to get the Principal and its role, inject @Context SecurityContext in the class body or in the method input parameters.

    import javax.ws.rs.core;
    //
    public ObjectList read(
        @PathParam("id") Integer id,
        @Context SecurityContext sc) {
        String principalUserName = sc.getUserPrincipal().getName();
        if (sc.isUserInRole("MyRole")) {
            return new MyRoleResource();
        } else {
            return new MyDefaultRoleResource();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I access an authenticated web service using JSTL? (Form-based authentication) If I can't
I'm using Spring Security 3.0.2 form based authentication. But I can't figure out how
I wrote a class to authenticate a user using HTTP Authentication the Digest way.
I'm implementing an API using authentication based on this article: http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/ And this related
what are the benefits of using HTTP authentication with PHP (HTTP 401 headers) instead
I have been toying with http authentication using the .htaccess file in an attempt
Active Resource can make use of HTTP authentication set at the class level. For
I'm working on a site that is using Facebook authentication and friends, but I'm
I am using Facebook PHP SDK to authenticate the user. After generating the LoginUrl
We've got a WSS 3.0 site that is using Forms Based Authentication (FBA). We

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.