[
https://issues.apache.org/jira/browse/CXF-3511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13032034#comment-13032034
]
Arul Dhesiaseelan commented on CXF-3511:
----------------------------------------
Ok cool, I did not look into the code if configLocation was optional. Thanks
Sergey!
Benson, JAX-RS 2.0 does plan to standardize the Client API. Not sure how it
would look like.
> Add support for creating WebClient with basic authentication credentials for
> non-Spring usecase
> -----------------------------------------------------------------------------------------------
>
> Key: CXF-3511
> URL: https://issues.apache.org/jira/browse/CXF-3511
> Project: CXF
> Issue Type: Improvement
> Components: JAX-RS
> Affects Versions: 2.4
> Reporter: Arul Dhesiaseelan
> Priority: Minor
>
> I create a JAX-RS server programmatically without using Spring and an
> authentication handler set:
> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
> sf.setResourceClasses(Resource.class);
> sf.setResourceProvider(Resource.class, new SingletonResourceProvider(new
> Resource()));
> sf.setAddress("http://localhost:9000/hello");
> sf.getOutInterceptors().add(new LoggingOutInterceptor());
> sf.getInInterceptors().add(new LoggingInInterceptor());
> sf.setProvider(new AuthenticationHandler());
> On, the client side (WebClient), there is no helper method that allows me to
> set basic authentication credentials for non-Spring use. I can have the
> static method in my code, but I thought it would be handy to have it in
> WebClient. Here is the utility method:
> /**
> * Creates WebClient which will do basic authentication
> * @param baseAddress baseAddress
> * @param username username
> * @param password password
> * @return WebClient instance
> */
> public static WebClient create(String baseAddress, String username,
> String password) {
> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
> bean.setAddress(baseAddress);
> bean.setUsername(username);
> bean.setPassword(password);
> return bean.createWebClient();
> }
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira