• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jersey Framework : RESTful services

 
Bhim Upadhyaya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This thread aims to house experience of developing or consuming RESTful services using Jersey framework (https://jersey.java.net/).
 
Bhim Upadhyaya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone tried two-way SSL with Jersey framework? Here is the scenario:

I have data in a form object (type: com.sun.jersey.api.representation.Form). Let's say:
Form myData = new Form();
form.add("data1", "value1");
form.add("data1","value2");

Now I form my total input data string:
String verb = "POST";
String uri = "/projectname/methodname/indicator";
String inputData = verb+uri+<flattened-value-here>
//[An instance: (String inputData = verb+uri+"data1=value1&data2=value2")]
.....

String encryptedData = hmac-calculating-method-call("key", inputData); // key = some value there

Now I call my web service:
responseData = webResource.path(serviceMethod).accept(MediaType.APPLICATION_FORM_URLENCODED)
.header("HMAC", encryptedData)
.header("msgSentTimeStamp", new SimpleDateFormat(DATE_FORMAT).format(new Date()))
.post(Form.class, myData)

How do I guarantee that when myData is flattened it becomes exactly "data1=value1&data2=value2". Or, is there any way to control this format so that when hmac is calculated it is same both on the client side and on the server side? Please analyze this in the context of two-way SSL.


 
Bhim Upadhyaya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is context loading and client-instance creation:
SSLContext sslContext = getSSLContext();
HostnameVerifier hostnameVerifier = null; // Verification may not be required
HTTPSProperties prop = new HTTPSProperties(hostnameVerifier, sslContext);
ClientConfig config = new DefaultClientConfig();
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, prop);
Client client = Client.create(config);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!