jersey

Authentication in Jersey

一曲冷凌霜 提交于 2019-12-05 16:33:56
I want to implement authentication for my Jersey0based server/client REST but I'm not sure how exactly to lay out the code. Basically for every operation I have 2 methods - 1 from the server side, 1 from the client side. I've narrowed down the algorithm - I'm going to use the amazon strategy with HMAC. The question is how to lay out this in the code - should I add the authentication (encryption/decryption code) into every method - both server/client side or should I have one "dispatch" method on both sides which would perform the encryption/decryption and then will transfer execution control

How to use two versions of Jackson (1.x and 2.x) in the same Jersey JAX-RS application?

为君一笑 提交于 2019-12-05 16:28:42
I work in a project with an old version of Jersey (1.19) along with old Jackson (1.19.13). I would like to switch, to new Jackson (2.x) deserialization, but only for new endpoints (and old ones gradually) because migration in one step to Jackson 2 and/or Jersey 2 would be really difficult (oh, the monolith!). I've seen some topics about how to provide custom-configured ObjectMapper with Jackson providers in Jersey, or how to install new Jackson in 1.x Jersey but that's not I'm looking for, at least not all. What I imagine as a solution, is (preferably) annotating my new JAX-RS endpoint with

JAX-RS get entity as JAXB object and as String

情到浓时终转凉″ 提交于 2019-12-05 16:27:39
I have a JAX-RS web service (using jersey) that accepts a JAXB object as the request entity. When we get an error, we want to log the original xml string that was sent to us. Currently, I am just re-marshalling the JAXB object, but since we have several java enums in those classes, enum values that are not spelled correctly in the original xml string are lost, which is not acceptable for our purposes. Does anyone know a way to get the request entity as both a string and JABX object? I would prefer not to write a custom MessageBodyReader and I would prefer to not try and get the

Moxy ignore invalid fields in json

大城市里の小女人 提交于 2019-12-05 16:09:10
When I send this request: {"invalidField": "value", "date": "value"} to my rest service: @PUT @Consumes("application/json") public void putJson(Test content) { System.out.println(content.toString()); } I expected to get an exception because: There is no invalidField in my domain model. Date format is not valid. But really I get test object with null values. My dmain model is: public class Test { private String name; private Date date; //getters and setters here } I think this is not a valid behavior. How can I fix that? Thanks for help. Solution: As Blaise Doughan said, it is required to

Accept comma separated value in REST Webservice

点点圈 提交于 2019-12-05 15:59:23
I am trying to receive a list of String as comma separated value in the REST URI ( sample : http://localhost:8080/com.vogella.jersey.first/rest/todo/test/1/abc,test , where abc and test are the comma separated values passed in). Currently I am getting this value as string and then splitting it to get the individual values. Current code : @Path("/todo") public class TodoResource { // This method is called if XMLis request @GET @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Path("/test/{id: .*}/{name: .*}") public Todo getXML(@PathParam("id") String id, @PathParam("name")

java.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonSerializableWithType

孤街醉人 提交于 2019-12-05 15:55:15
问题 I got Jackson 2.2.3 in my buildpath but i still get this error. anyone know why? com.sun.jersey.core.spi.component.ProviderFactory __getComponentProvider: The provider class, class com.sun.jersey.json.impl.provider.entity.JSONWithPaddingProvider, could not be instantiated. Processing will continue but the class will not be utilized java.lang.SecurityException: Unable to get members for class com.sun.jersey.json.impl.provider.entity.JSONWithPaddingProvider at com.google.appengine.runtime

Cross domain REST/Jersey web services with CORS

给你一囗甜甜゛ 提交于 2019-12-05 15:27:05
I want to make Cross domain REST web services with CORS(Cross-Origin Resource Sharing). I am using Jersey Libraries for making services. I need to know What code/configuration changes i need to do from server side perspective? How to invoke this services from HTML5/js. Thanks All the information for your server side configuration can be found at enable-cors.org . There is no need to change any code clientside, but I would recommend checking the Browsers capability for CORS before using it. Testing code can be found, e.g., here . I have chosen to solve this problem by providing the server CORS

Jersey: “Missing dependency for method …”

橙三吉。 提交于 2019-12-05 14:24:29
Could somebody please explain the meaning of this error? INFO: Scanning for root resource and provider classes in the Web app resource paths: /WEB-INF/lib /WEB-INF/classes Feb 21, 2012 3:03:48 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses INFO: Root resource classes found: class com.foo.dom2jcr.rest.XMLCRUDRestlet Feb 21, 2012 3:03:48 AM com.sun.jersey.api.core.ScanningResourceConfig init INFO: No provider classes found. Feb 21, 2012 3:03:48 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate INFO: Initiating Jersey application, version 'Jersey: 1.11 12/09

How can I send a generic file to a jersey service and receive it correctly?

末鹿安然 提交于 2019-12-05 14:19:45
I'm developing a Jersey service that uses Dropbox's API. I need to post a generic file to my service (the service would be able to manage every kind of file as well as you can do with the Dropbox API). Client Side So, I've implemented a simple client that: opens the file, creates a connection to the URL, sets the correct HTTP method, creates a FileInputStream and writes the file on the connection's outputstream using byte buffer. This is the client test code. public class Client { public static void main(String args[]) throws IOException, InterruptedException { String target = "http:/

Jersey 1.6 with Spring 3.0.5 using Maven

无人久伴 提交于 2019-12-05 14:16:27
I'm having hard time getting Jersey to work with Spring 3.0.5. I found many person that says that they where able to make it work but I'm out of luck. I always get: java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;) Is anybody able to make this work? Thank you for your help! Here is my pom dependencies: <dependencies> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>${jersey-version}</version> </dependency> <dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId