0

I am new to Apache Wink. I wanted to know how I can access Basic Authorization header's in my wink server code. I am using FireFox REST client to access my service. While authenticating user, i need to pass username and password as Basic Authorization header.

Any idea how i can get the user data in my server side code ?

Tarlog
  • 10,024
  • 2
  • 43
  • 67
Rajjy
  • 176
  • 13

1 Answers1

1

Option 1: Using @HeaderParam. Example:

@GET
public Response myGetMethod(@HeaderParam("BASIC") String basicHeader) {
    ...
}

Option 2: Using HttpHeaders context. Example:

@GET
public Response myGetMethod(@Context HttpHeaders headers) {
    String basicHeader = headers.getRequestHeader("BASIC").get(0);
    ...
}

Option 3: You can get the HttpServletRequest using @Context and get the header from there.

Tarlog
  • 10,024
  • 2
  • 43
  • 67