• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Jersey Framework : RESTful services

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic