uCosminexus Application Server, Web Service Development Guide
You can connect a Web resource client to a Web resource that is supported in the basic authentication.
This section describes the implementation required to connect by basic authentication.
To access a Web resource by basic authentication, implement a process that adds the required HTTP headers. An implementation example when using client APIs for RESTful Web Services is as follows.
| // The user ID and password for basic authentication String username = ... String password = ... // Generates Client objects Client client = Client.create(); // Generate an HTTP request having the Authorization HTTP header // and post to the Web resource client.resource( "http://example.org/helloworld" ) .header( HttpHeaders.AUTHORIZATION, "Basic " + encode(username + ":" + password)) .post( String.class, "Some Request" ); ... String encode( String value ){ String encoded; // Encode the value parameter by using the Base64 algorithm value // and set the result in the encoded parameter ... return encoded; } |
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.