cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pydipati, Karuna" <kpydip...@stubhub.com>
Subject Re: Deploying JAXWS&JAXRS together - error
Date Thu, 19 Nov 2009 14:51:11 GMT
Perfectly make sense.

BTW, if you are extending HeaderParam like @HeaderParam("a","b"), I  
would suggest to do something like @HeaderParam("map") and in  
AuthHeader class, we can have a constructor like A

AuthHeader(Map headerMap)

This Map contains all the header and I can get whatever headers I want  
and populate AuthHeader fields. The reason why I am suggesting Map is  
that imagine a scenario where AuthHeader class has 10 fields and  
Developer is passing 10 headers. Then, mentioning everything in  
@HeaderParam would not look nice. Map would work for any number of  
Headers. In addtion, developer can also get hold of other existing  
headers too.

Same case, for static valueOf(Map headerMap) method too.

This is just a suggestion. But, for now, I will try use one of the  
existing avaialble option.

Thanks
Karuna Pydipati

On Nov 19, 2009, at 5:53 AM, "Sergey Beryozkin"  
<sberyozk@progress.com> wrote:

> I think you have few options.
> 1. Actually use a single header but with the value being a comma- 
> seperated lits of name/value pairs, ex :
>
> auth: id=123,password=bar
>
> 2. Similar to 1, but use a standard HTTP Authorization header  
> (basic64 encoded userid:password pair) given that it's an auth info  
> that your're passing in this specific case
>
> In both cases you'll parse the string and init an AuthHeader class.  
> You can get to the current message from the phase chain and use CXF  
> JAXRS HttpHeadersImpl to simplify the parsing, but it's probably an  
> overhead in this case. However, if you do decide to go with the  
> option 2, then you'll likely want to get a base64 decoded value of  
> the Authorization header, you can do it like this :
>
> // AuthorizationPolicy will have decoded user & password values
> Message message = PhaseInterceptorChain.getCurrentMessage();
> AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
>
> 3. Finally, if you do prefer to keep different headers, one for  
> user, one for password, then I can't think of the easy way,
> one can probably use @HeaderParam("userid") as a starting point and  
> then, inside the valueOf()/ParameterHandler/etc also extract the  
> password header value from the current message....
>
> That said, may be I can add a support for HeaderParam("a,b") where a  
> & b are header names, which would let the runtime do the injection  
> into a bean. Ex, we have QueryParam(""), FormParam("") and PathParam 
> ("") extensions, but no HeaderParam("")....
>
> cheers, Sergey
>
>
>
> I want to expand my AuthHeader class to have another field called
> "password". So, My AuthHeader class will look like this.
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "authHeader", propOrder = { "userId" })
> @XmlRootElement(name = "AuthHeader")
> public class AuthHeader {
>
>   @XmlElement(name = "UserId", required = true)
> protected Long userId;
> protected String password;
>
> public Long getUserId() {
> return userId;
> }
> public void setUserId(Long userId) {
> this.userId = userId;
> }
> public String getPassword() {
> return password;
> }
> public void setPassword(String password) {
> this.password = password;
> }
> public AuthHeader(String s){
> super();
>       setUserId(10077L);
> }
> }
>
> My input headers would be like this(see below). Please see userid and
> password in *Header* section below. How do I mention @HeaderParam in
> that case? Is it like @HeaderParam("userid", "password") in interface
> method? How do I write my AuthHeader constructor with string  
> argument OR
> static valueOf()? Please provide some clue as to how to handle  
> multiple
> headers pointing to same Java Object on server side?
>
> INFO: Inbound Message
> ----------------------------
> ID: 2
> Address:
> /paymentapi/stubHubPaymentJaxwsJaxrs_rest/payment/ 
> getorderpaymentmethod3
> Encoding: ISO-8859-1
> Content-Type: application/xml
> Headers: {password=[abcde], content-length=[57], userid=[10077],
> accept-encoding=[gzip,deflate], host=[10.249.136.95:280
> 80], user-agent=[Jakarta Commons-HttpClient/3.1],
> Content-Type=[application/xml], content-type=[application/xml]}
> Payload: <OrderRequest><orderId>23544619</orderId>
> </OrderRequest>
>
> Regards
> Karuna Pydipati
> StubHub/eBay - Platform & Services
> Phone: (415)222-8752
> Email: kpydipati@ebay.com
>
>
>

Mime
View raw message