Apache Camel v2.12 | CXF Component | Basic Authentication | Web Service

2014-01-19 Thread P Manchanda
Respected Camel Experts,

I am trying to access a web service that requires basic authentication. I am 
able to access using the CXF's JaxWsDynamicClientFactory. The code piece for 
auth looks like:

           JaxWsDynamicClientFactory dcf = 
JaxWsDynamicClientFactory.newInstance();
           Client client = dcf.createClient(ID_WSDL);
           
           HTTPConduit conduit= (HTTPConduit) client.getConduit();
           AuthorizationPolicy authorization =  conduit.getAuthorization();
           authorization.setUserName(USERNAME);
       authorization.setPassword(PWD);
       
       conduit.setAuthorization(authorization);


 However, when I try to use Camel's CXF component to access the same Web 
Service I get 401 Unauthorized error, since Camel is not sending the 
authentication information to the Web Service.

My route looks like:

    from("file://c:/test?fileName=request.txt&noop=true").routeId("myrouteId")
    .process(processor)
    .to(cxf)
    .to("log:{body}");

In my processor, I am setting the credentials as follows:

Map properties = new HashMap(); 

        AuthorizationPolicy authPolicy = new AuthorizationPolicy(); 
        authPolicy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_BASIC); 
        authPolicy.setUserName(USERNAME); 
        authPolicy.setPassword(PWD); 
        
        
properties.put("org.apache.cxf.configuration.security.AuthorizationPolicy", 
authPolicy);
        myEndpoint.setProperties(properties);

myEndpoint is CXFEndpoint, retrieved from Exchange. 

Am I missing something or something wrong here.

___ 
Thks & brgds 
P Manchanda
Mobile: +91-9911152374


Re: Apache Camel v2.12 | CXF Component | Basic Authentication | Web Service

2014-01-21 Thread Willem Jiang
Hi,

If you set the cxfEndpoint property in a processor, it’s a setting of runtime.
As the CxfProducer is created during the camel context start the route, the 
cxfEndpoint’s property is not updated.

My suggestion is you set the cxfEndpoint property in the route builder 
configure method instead of a processor. 

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com(http://willemjiang.blogspot.com/) 
(English)
http://jnn.iteye.com(http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On January 20, 2014 at 2:12:21 PM, P Manchanda (manchan...@yahoo.com) wrote:
>  
> Respected Camel Experts,
>  
> I am trying to access a web service that requires basic authentication.  
> I am able to access using the CXF's JaxWsDynamicClientFactory.  
> The code piece for auth looks like:
>  
> JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();  
> Client client = dcf.createClient(ID_WSDL);
>  
> HTTPConduit conduit= (HTTPConduit) client.getConduit();  
> AuthorizationPolicy authorization = conduit.getAuthorization();  
> authorization.setUserName(USERNAME);
> authorization.setPassword(PWD);
>  
> conduit.setAuthorization(authorization);
>  
>  
> However, when I try to use Camel's CXF component to access the  
> same Web Service I get 401 Unauthorized error, since Camel is  
> not sending the authentication information to the Web Service.  
>  
> My route looks like:
>  
> from("file://c:/test?fileName=request.txt&noop=true").routeId("myrouteId")  
> .process(processor)
> .to(cxf)
> .to("log:{body}");
>  
> In my processor, I am setting the credentials as follows:
>  
> Map properties = new HashMap();  
>  
> AuthorizationPolicy authPolicy = new AuthorizationPolicy();  
> authPolicy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_BASIC);  
> authPolicy.setUserName(USERNAME);
> authPolicy.setPassword(PWD);
>  
> properties.put("org.apache.cxf.configuration.security.AuthorizationPolicy",  
> authPolicy);
> myEndpoint.setProperties(properties);
>  
> myEndpoint is CXFEndpoint, retrieved from Exchange.
>  
> Am I missing something or something wrong here.
>  
> ___
> Thks & brgds
> P Manchanda
> Mobile: +91-9911152374
>  



Re: Apache Camel v2.12 | CXF Component | Basic Authentication | Web Service

2014-01-23 Thread manchandap
Thanks Willem,

>> As the CxfProducer is created during the camel context start the route,
>> the cxfEndpoint’s property is not updated. 
That was my hunch, however i was not able to prove it concretely. I will try
your suggestion of updating the property in Route Builder's configure
method.

Thanks and Regards
Prince Manchanda



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apache-Camel-v2-12-CXF-Component-Basic-Authentication-Web-Service-tp5746233p5746392.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Apache Camel v2.12 | CXF Component | Basic Authentication | Web Service

2014-01-23 Thread manchandap
Looking at the   CXF Component Documentation
  , I notice that two new options
(username and password) for Basic Authentication have been added in 2.12.3. 

 

However, from the download, I am not able to find any link or info to
download 2.12.3. Also, the download links for 2.13 are broken.

So, my queries:

# From where i can download 2.12.3 and/or 2.13
# if these versions are still WIP, then how similar effect can be achieved
in version 2.12.0

Thanks and Regards
P Manchanda 



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apache-Camel-v2-12-CXF-Component-Basic-Authentication-Web-Service-tp5746233p5746426.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Apache Camel v2.12 | CXF Component | Basic Authentication | Web Service

2014-01-23 Thread manchandap
Was able to get this working by adding the following code to the Route
Builder. I am using Java DSL:

Map properties = new HashMap(); 

AuthorizationPolicy authPolicy = new AuthorizationPolicy(); 

authPolicy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_BASIC); 
authPolicy.setUserName(USERNAME); 
authPolicy.setPassword(PWD); 
authPolicy.setAuthorization("true");

//properties.put(AuthorizationPolicy.class.getName(), 
authPolicy);

properties.put("org.apache.cxf.configuration.security.AuthorizationPolicy",
authPolicy);

CxfEndpoint myCxfEp = 
(CxfEndpoint)getContext().getEndpoint("cxf://");
myCxfEp.setProperties(properties);

Thanks and Regards
P Manchanda




--
View this message in context: 
http://camel.465427.n5.nabble.com/Apache-Camel-v2-12-CXF-Component-Basic-Authentication-Web-Service-tp5746233p5746435.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Apache Camel v2.12 | CXF Component | Basic Authentication | Web Service

2014-01-24 Thread Willem Jiang
FYI, I just add two new options (username, password)[1] to the CXF URI.
You can setup URI for basic authentication information.

[1]https://issues.apache.org/jira/browse/CAMEL-7145

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com(http://willemjiang.blogspot.com/) 
(English)
http://jnn.iteye.com(http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On January 24, 2014 at 3:28:27 PM, manchandap (manchan...@yahoo.com) wrote:
>  
> Was able to get this working by adding the following code to the  
> Route
> Builder. I am using Java DSL:
>  
> Map properties = new HashMap();  
>  
> AuthorizationPolicy authPolicy = new AuthorizationPolicy();  
> authPolicy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_BASIC);  
> authPolicy.setUserName(USERNAME);
> authPolicy.setPassword(PWD);
> authPolicy.setAuthorization("true");
>  
> //properties.put(AuthorizationPolicy.class.getName(),  
> authPolicy);
>  
> properties.put("org.apache.cxf.configuration.security.AuthorizationPolicy",  
> authPolicy);
>  
> CxfEndpoint myCxfEp = (CxfEndpoint)getContext().getEndpoint("cxf://");  
> myCxfEp.setProperties(properties);
>  
> Thanks and Regards
> P Manchanda
>  
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Apache-Camel-v2-12-CXF-Component-Basic-Authentication-Web-Service-tp5746233p5746435.html
>   
> Sent from the Camel - Users mailing list archive at Nabble.com.  
>  



Re: Apache Camel v2.12 | CXF Component | Basic Authentication | Web Service

2014-09-06 Thread sayed_india
Hello,
I am a newbie in Camel and need of some basic authentication for CXF SOAP
and REST service.
Added the shared code in route builder , but not getting authentication
being cheked when accessing.

Please share the complete code base .



Thanks and Regards,
Sayed



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apache-Camel-v2-12-CXF-Component-Basic-Authentication-Web-Service-tp5746233p5756115.html
Sent from the Camel - Users mailing list archive at Nabble.com.