jersey

secure a rest web service using jersey

我的未来我决定 提交于 2019-12-19 10:32:00
问题 I have implemented rest web services for my application. Since this should not be a public service ,I want to enforce some type of client authentication. Please throw light on how to do that. FYI, I am using apache Tomcat 7 and a MYSQL database 回答1: You have a lot of options here - anything from container managed security (basic or digest) to Shiro or Spring Security. 来源: https://stackoverflow.com/questions/12481539/secure-a-rest-web-service-using-jersey

Welcome page in REST with Java (JAX-RS) using Jersey

放肆的年华 提交于 2019-12-19 10:19:21
问题 I am implementing a Restful Web Service using Jersey. I want to show index.jsp as welcome page. <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Rest Page</title> </head> <body> <h1>Rest is working!</h1> </body> </html> It works fine when I use this code in my web.xml: <servlet-mapping> <servlet

@RolesAllowed always rejected (forbidden) on Jersey resource

折月煮酒 提交于 2019-12-19 09:53:27
问题 I am attempting to set up authentication based on roles for a resource I am exposing via Jersey/JAX-RS. This resource exists within a Glassfish instance in which authentication based on roles (specifically, via @RolesAllowed) is currently working as desired. I'm running Jersey within a servlet container: <servlet-class> com.sun.jersey.spi.container.servlet.ServletContainer </servlet-class> And am enforcing basic auth on my resource; that requirement is being enforced as expected. I have also

@RolesAllowed always rejected (forbidden) on Jersey resource

扶醉桌前 提交于 2019-12-19 09:52:14
问题 I am attempting to set up authentication based on roles for a resource I am exposing via Jersey/JAX-RS. This resource exists within a Glassfish instance in which authentication based on roles (specifically, via @RolesAllowed) is currently working as desired. I'm running Jersey within a servlet container: <servlet-class> com.sun.jersey.spi.container.servlet.ServletContainer </servlet-class> And am enforcing basic auth on my resource; that requirement is being enforced as expected. I have also

How do I remove http artifacts from a multipart form-data request?

笑着哭i 提交于 2019-12-19 09:27:03
问题 I have this method signature in a jersery servlet. The servlet is being reached and the form data is present in the uploadedInputStream object, but the stream does not have the http artifacts removed from it. See below. @POST @Produces("text/plain") @Consumes(MediaType.MULTIPART_FORM_DATA) public String uploadFileIE( @FormDataParam("qqfile") InputStream uploadedInputStream ){ } When saved to a file, the input stream has these artifacts surrounding the byte data: ----------------------------

Multi tenancy with Guice Custom Scopes and Jersey

主宰稳场 提交于 2019-12-19 08:56:57
问题 I am in the process of developing a multi tenancy application with Jersey using Guice for DI (I also use Dropwizard but I don't think it matters here). One thing that bothers me is the fact that some kind of tenancy_id is all over the place in my application. Most of my URLs look like this: /:tenancy_id/some_resource/do_stuff . So the method in my Jersey resource is called with the tenancy_id and hands it over to a service which calls other services and so on. These services are configured

Java RESTful Jersey Examples? [closed]

非 Y 不嫁゛ 提交于 2019-12-19 08:28:15
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Are there any examples that demonstrate using Java and Jersey to perform Client<->Server communication? Such as sending XML data to

Sending a stream of documents to a Jersey @POST endpoint

旧巷老猫 提交于 2019-12-19 05:47:34
问题 I want to be able to send a stream of a bunch of documents to a web service. This will save on Http request/response overhead and focus on the documents themselves. In python you can do something like this: r = requests.post('https://stream.twitter.com/1/statuses/filter.json', data={'track': 'requests'}, auth=('username', 'password'), stream=True) for line in r.iter_lines(): if line: # filter out keep-alive new lines print json.loads(line) I'm looking for an example of someone streaming a

Sending a stream of documents to a Jersey @POST endpoint

只谈情不闲聊 提交于 2019-12-19 05:47:32
问题 I want to be able to send a stream of a bunch of documents to a web service. This will save on Http request/response overhead and focus on the documents themselves. In python you can do something like this: r = requests.post('https://stream.twitter.com/1/statuses/filter.json', data={'track': 'requests'}, auth=('username', 'password'), stream=True) for line in r.iter_lines(): if line: # filter out keep-alive new lines print json.loads(line) I'm looking for an example of someone streaming a

Jersey: Can I add a cookie in ContainerResponseFilter?

旧时模样 提交于 2019-12-19 05:34:57
问题 I have a ContainerResponseFilter and I tried to set a cookie in it as follows: @Override public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException { String cookieName = "ExampleCookie"; String cookieValue = "SomeData"; logger.info("Setting cookie " + cookieName + " with value " + cookieValue + " into cookies " + JsonUtils.objectToJson(containerResponseContext.getCookies())); containerResponseContext.getCookies()