javax.ws.rs.CookieParam Java Examples
The following examples show how to use
javax.ws.rs.CookieParam.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyResource.java From resteasy-examples with Apache License 2.0 | 6 votes |
@Path("foo/{param}-{other}") @PUT public String putFooParam(@PathParam("param") String param, @PathParam("other") String other, @QueryParam("q") String q, @CookieParam("c") String c, @HeaderParam("h") String h, @MatrixParam("m") String m, String entity, @Context UriInfo ignore) { StringBuffer buf = new StringBuffer(); buf.append("param").append("=").append(param).append(";"); buf.append("other").append("=").append(other).append(";"); buf.append("q").append("=").append(q).append(";"); buf.append("c").append("=").append(c).append(";"); buf.append("h").append("=").append(h).append(";"); buf.append("m").append("=").append(m).append(";"); buf.append("entity").append("=").append(entity).append(";"); return buf.toString(); }
Example #2
Source File: ContextService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@GET @Path("/property/search") @Produces(MediaType.APPLICATION_JSON) public Response searchProperty( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("contextid") String contextID, @QueryParam("q") String keyword) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); Context context = repository.getContext(contextID); List<Property> propertyList = context.searchProperty(keyword, TextSearchType.WildCard); List<PropertyModel> pList = new ArrayList<PropertyModel>(); for (Property p : propertyList) { pList.add(new PropertyModel(p)); } return Response.ok(pList).build(); }
Example #3
Source File: PlaySessionResource.java From judgels with GNU General Public License v2.0 | 6 votes |
@GET @Path("/client-logout/{redirectUri}") @UnitOfWork public Response serviceLogOut( @Context UriInfo uriInfo, @CookieParam(COOKIE_NAME) String token, @PathParam("redirectUri") String redirectUri) { sessionStore.deleteSessionByToken(token); return Response.seeOther(URI.create(redirectUri)) .cookie(new NewCookie( COOKIE_NAME, "expired", "/", uriInfo.getBaseUri().getHost(), Cookie.DEFAULT_VERSION, null, (int) Duration.ofDays(7).getSeconds(), new Date(0), false, true)) .build(); }
Example #4
Source File: DataElementService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@POST @Path("/mapping") public Response addMapping( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("deid") String dataElementID, MappingModel mapping) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); DataElement de = repository.getDataElement(dataElementID); DataElement mappedDE = repository.getDataElement(mapping.getTermUUID()); MappingRelation relation = new MappingRelation(); relation.setSubjectOID(MDRConstants.getOIDFromContentModel(de.getContext().getName())); relation.setRelationType(mapping.getMatchType()); relation.setObjectOID(mapping.getTermSystemOID()); de.addMapping(relation, mappedDE); logger.debug("{} --> {} mapping is added", dataElementID, mapping.getTermUUID()); return Response.ok().build(); }
Example #5
Source File: PropertyService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@GET @Produces(MediaType.APPLICATION_JSON) public Response getProperty( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("propertyid") String propertyID) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); MDRDatabase mdrDatabase = repository.getMDRDatabase(); Property property = new PropertyImpl(mdrDatabase.getOntModel() .getResource( mdrDatabase.getResourceFactory().makeID( Abbreviation.Property.toString(), propertyID)), mdrDatabase); return Response.ok(new PropertyModel(property)).build(); }
Example #6
Source File: BookStore.java From cxf with Apache License 2.0 | 6 votes |
@GET @Path("/redirect") public Response getBookRedirect(@QueryParam("redirect") Boolean done, @QueryParam("sameuri") Boolean sameuri, @CookieParam("a") String cookie) { if (done == null) { String uri = sameuri.equals(Boolean.TRUE) ? ui.getAbsolutePathBuilder().queryParam("redirect", "true").build().toString() : "http://otherhost/redirect"; return Response.status(303).cookie(NewCookie.valueOf("a=b")).header("Location", uri).build(); } return Response.ok(new Book("CXF", 123L), "application/xml") .header("RequestURI", this.ui.getRequestUri().toString()) .header("TheCookie", cookie) .build(); }
Example #7
Source File: RepositoryService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@Path("/search") @GET @Produces(MediaType.APPLICATION_JSON) public Response searchDataElements( @CookieParam(AuthenticationService.SID) String sessionID, @QueryParam("q") String keyword, @QueryParam("limit") @DefaultValue("10") Integer limit, @QueryParam("offset") @DefaultValue("0") Integer offset) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); List<DataElement> deList = repository.searchDataElement(keyword, TextSearchType.WildCard, limit, offset); List<DataElementModel> deModelList = new ArrayList<DataElementModel>(); for (DataElement de : deList) { deModelList.add(new DataElementModel(de)); } return Response.ok(deModelList).build(); }
Example #8
Source File: ConceptualDomainService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@GET @Produces(MediaType.APPLICATION_JSON) public Response getConceptualDomain( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("cid") String cid) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); ConceptualDomain cd = repository.getConceptualDomain(cid); if (cd instanceof EnumeratedConceptualDomain) { return Response.ok(new ConceptualDomainModel(cd, true)).build(); } else { return Response.ok(new ConceptualDomainModel(cd, false)).build(); } }
Example #9
Source File: MvcConverterProvider.java From krazo with Apache License 2.0 | 6 votes |
private static String getParamName(Annotation[] annotations) { for (Annotation annotation : annotations) { if (annotation instanceof QueryParam) { return ((QueryParam) annotation).value(); } if (annotation instanceof PathParam) { return ((PathParam) annotation).value(); } if (annotation instanceof FormParam) { return ((FormParam) annotation).value(); } if (annotation instanceof MatrixParam) { return ((MatrixParam) annotation).value(); } if (annotation instanceof CookieParam) { return ((CookieParam) annotation).value(); } } return null; }
Example #10
Source File: ContextService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@GET @Path("/vd") @Produces(MediaType.APPLICATION_JSON) public Response listValueDomains( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("contextid") String contextID, @QueryParam("limit") @DefaultValue("10") Integer limit, @QueryParam("offset") @DefaultValue("0") Integer offset) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); Context context = repository.getContext(contextID); List<ValueDomain> vdList = context.getValueDomains(limit, offset); List<ValueDomainModel> vdModelList = new ArrayList<ValueDomainModel>(); for (ValueDomain vd : vdList) { if (vd instanceof EnumeratedValueDomain) { vdModelList.add(new ValueDomainModel(vd, true)); } else if (vd instanceof NonEnumeratedValueDomain) { vdModelList.add(new ValueDomainModel(vd, false)); } } return Response.ok(vdModelList).build(); }
Example #11
Source File: ContextService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@GET @Path("/property") @Produces(MediaType.APPLICATION_JSON) public Response listProperties( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("contextid") String contextID) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); Context context = repository.getContext(contextID); List<Property> properties = context.getProperties(); List<PropertyModel> propertyList = new ArrayList<PropertyModel>(); for (Property prop : properties) { propertyList.add(new PropertyModel(prop)); } return Response.ok(propertyList).build(); }
Example #12
Source File: ClientProxyImpl.java From cxf with Apache License 2.0 | 6 votes |
protected void handleCookies(Method m, Object[] params, MultivaluedMap<String, String> headers, List<Parameter> beanParams, MultivaluedMap<ParameterType, Parameter> map) { List<Parameter> cs = getParameters(map, ParameterType.COOKIE); cs.stream(). filter(p -> params[p.getIndex()] != null). forEachOrdered(p -> { headers.add(HttpHeaders.COOKIE, p.getName() + '=' + convertParamValue(params[p.getIndex()].toString(), getParamAnnotations(m, p))); }); beanParams.stream(). map(p -> getValuesFromBeanParam(params[p.getIndex()], CookieParam.class)). forEachOrdered(values -> { values.forEach((key, value) -> { if (value != null) { headers.add(HttpHeaders.COOKIE, key + "=" + convertParamValue(value.getValue(), value.getAnns())); } }); }); }
Example #13
Source File: AuthenticationService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@DELETE @Produces(MediaType.APPLICATION_JSON) public Response logout(@CookieParam(SID) String sessionID) { boolean status = false; try { status = AuthenticationManager.getInstance() .logoutUserFromSessionID(sessionID); } catch (AuthenticationException e) { logger.error("Cannot signout user from sessionID", e); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } if (status) { return Response.ok().build(); } else { return Response.status(Status.BAD_REQUEST).build(); } }
Example #14
Source File: AuthenticationService.java From query2report with GNU General Public License v3.0 | 6 votes |
@Path("/logout") @POST @Produces(MediaType.APPLICATION_JSON) public Response logoutUser(@CookieParam("Q2R_AUTH_INFO") Cookie cookie){ String cookieValue = cookie.getValue(); String tokenPatterns[] = cookieValue.split("_0_"); if(tokenPatterns.length!=3) return Response.serverError().entity("Corrupt Token").build(); logger.info("Logging out user "+tokenPatterns[0]); try{ boolean validToken = UserManager.getUserManager().validateToken(tokenPatterns[0], cookieValue); if(validToken){ UserManager.getUserManager().logoutUser(tokenPatterns[0]); return Response.ok("User "+tokenPatterns[0]+" logged out.").build(); }else{ return Response.serverError().entity("Logout failed").status(Response.Status.UNAUTHORIZED).build(); } }catch(Exception e){ return Response.serverError().entity("Logout failed").build(); } }
Example #15
Source File: ValidationExceptionMapper.java From seed with Mozilla Public License 2.0 | 6 votes |
private ParameterInfo resolveParameterInfo(Path.ParameterNode node, Method method) { if (method != null) { Annotation[][] parameterAnnotations = method.getParameterAnnotations(); int parameterIndex = node.as(Path.ParameterNode.class).getParameterIndex(); if (parameterIndex < parameterAnnotations.length) { for (Annotation a : parameterAnnotations[parameterIndex]) { if (a instanceof QueryParam) { return new ParameterInfo(Location.QUERY_PARAMETER, ((QueryParam) a).value()); } else if (a instanceof PathParam) { return new ParameterInfo(Location.PATH_PARAMETER, ((PathParam) a).value()); } else if (a instanceof HeaderParam) { return new ParameterInfo(Location.HEADER_PARAMETER, ((HeaderParam) a).value()); } else if (a instanceof CookieParam) { return new ParameterInfo(Location.COOKIE_PARAMETER, ((CookieParam) a).value()); } else if (a instanceof FormParam) { return new ParameterInfo(Location.FORM_PARAMETER, ((FormParam) a).value()); } else if (a instanceof MatrixParam) { return new ParameterInfo(Location.MATRIX_PARAMETER, ((MatrixParam) a).value()); } } return new ParameterInfo(Location.REQUEST_BODY, node.getName()); } } return new ParameterInfo(Location.UNKNOWN, node.getName()); }
Example #16
Source File: DataElementService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@DELETE public Response deleteDataElement( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("deid") String dataElementID) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); DataElement de = repository.getDataElement(dataElementID); // TODO which relations of Data Element is to be deleted, decide on that try { de.delete(); } catch (Exception e) { return Response.serverError().build(); } return Response.ok().build(); }
Example #17
Source File: ContextService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@POST @Path("/de") @Produces(MediaType.APPLICATION_JSON) public Response createDataElement( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("contextid") String contextID, DataElementModel deModel) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); Context context = repository.getContext(contextID); // WARN ValueDomain and DataElementConcept's should exist in repository // before calling this service DataElementConcept dec = context.getDataElementConcept(deModel .getDataElementConceptID()); ConceptualDomain conceptualDomain = repository.getConceptualDomain(dec .asMDRResource() .getHavingDataElementConceptConceptualDomainRelationship() .getUniqueID()); ValueDomain vd = conceptualDomain.getValueDomain(deModel .getValueDomainID()); DataElement de = context.createDataElement(deModel.getName(), deModel.getDefinition(), dec, vd); return Response.ok(new DataElementModel(de)).build(); }
Example #18
Source File: ConceptualDomainService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@POST @Path("/vm") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createValueMeaning( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("cid") String conceptualDomainID, ValueMeaningModel valueMeaningModel) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); ConceptualDomain cd = repository .getConceptualDomain(conceptualDomainID); if (cd instanceof NonEnumeratedConceptualDomain) { logger.error( "{} is not EnumeratedConceptualDomain, so no ValueMeaning", conceptualDomainID); return Response.serverError().build(); } EnumeratedConceptualDomain ecd = (EnumeratedConceptualDomain) cd; ValueMeaning vm = ecd.addValueMeaning(valueMeaningModel.getId(), valueMeaningModel.getDescription()); return Response.ok(new ValueMeaningModel(vm.asMDRResource())).build(); }
Example #19
Source File: ConceptualDomainService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@GET @Path("/vd") @Produces(MediaType.APPLICATION_JSON) public Response listValueDomains( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("cid") String cid) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); List<ValueDomainModel> vdModelList = new ArrayList<ValueDomainModel>(); ConceptualDomain cd = repository.getConceptualDomain(cid); List<ValueDomain> vdList = cd.getValueDomains(); for (ValueDomain vd : vdList) { if (vd instanceof EnumeratedValueDomain) { vdModelList.add(new ValueDomainModel(vd, true)); } else { vdModelList.add(new ValueDomainModel(vd, false)); } } return Response.ok(vdModelList).build(); }
Example #20
Source File: ContextService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@GET @Path("/de/search") @Produces(MediaType.APPLICATION_JSON) public Response searchDataElements( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("contextid") String contextID, @QueryParam("q") String keyword, @QueryParam("limit") @DefaultValue("10") Integer limit, @QueryParam("offset") @DefaultValue("0") Integer offset) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); Context context = repository.getContext(contextID); List<DataElement> deList = context.searchDataElement(keyword, TextSearchType.WildCard, limit, offset); List<DataElementModel> deModelList = new ArrayList<DataElementModel>(); for (DataElement de : deList) { deModelList.add(new DataElementModel(de)); } return Response.ok(deModelList).build(); }
Example #21
Source File: DataElementService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@POST @Path("/extractionspecification") public Response addExtractionSpecification( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("deid") String dataElementID, ExtractionSpecificationModel extractionSpecification) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); DataElement de = repository.getDataElement(dataElementID); de.addExtractionSpecification(extractionSpecification.getModelOID(), extractionSpecification.getType(), extractionSpecification.getValue()); logger.debug("{} is added to {} as Extraction Specification", extractionSpecification.getValue(), dataElementID); return Response.ok().build(); }
Example #22
Source File: StockQuoteService.java From msf4j with Apache License 2.0 | 6 votes |
/** * Retrieve a stock for a given symbol using a cookie. * This method demonstrates the CookieParam JAXRS annotation in action. * * curl -v --header "Cookie: symbol=IBM" http://localhost:8080/stockquote * * @param symbol Stock symbol will be taken from the symbol cookie. * @return Response */ @GET @Produces({"application/json", "text/xml"}) @ApiOperation( value = "Return stock quote corresponding to the symbol", notes = "Returns HTTP 404 if the symbol is not found") @ApiResponses(value = { @ApiResponse(code = 200, message = "Valid stock item found"), @ApiResponse(code = 404, message = "Stock item not found")}) public Response getQuoteUsingCookieParam(@ApiParam(value = "Symbol", required = true) @CookieParam("symbol") String symbol) throws SymbolNotFoundException { System.out.println("Getting symbol using CookieParam..."); Stock stock = stockQuotes.get(symbol); if (stock == null) { throw new SymbolNotFoundException("Symbol " + symbol + " not found"); } return Response.ok().entity(stock).build(); }
Example #23
Source File: MvcConverterProvider.java From ozark with Apache License 2.0 | 6 votes |
private static String getParamName(Annotation[] annotations) { for (Annotation annotation : annotations) { if (annotation instanceof QueryParam) { return ((QueryParam) annotation).value(); } if (annotation instanceof PathParam) { return ((PathParam) annotation).value(); } if (annotation instanceof FormParam) { return ((FormParam) annotation).value(); } if (annotation instanceof MatrixParam) { return ((MatrixParam) annotation).value(); } if (annotation instanceof CookieParam) { return ((CookieParam) annotation).value(); } } return null; }
Example #24
Source File: SessionLogoutResource.java From keywhiz with Apache License 2.0 | 6 votes |
/** * Logout and remove any session cookies * * @return 200 on success * description Log out and remove any session cookies * responseMessage 200 Logged out successfully */ @Timed @ExceptionMetered @POST @Produces(APPLICATION_JSON) public Response logout(@Nullable @CookieParam(value = "session") Cookie sessionCookie) { if (sessionCookie != null) { Optional<User> user = cookieAuthenticator.authenticate(sessionCookie); if (user.isPresent()) { logger.info("User logged out: {}", user.get().getName()); } else { logger.warn("Invalid user cookie on logout."); } } NewCookie expiredCookie = cookieFactory.getExpiredSessionCookie(); return Response.ok() .header(HttpHeaders.SET_COOKIE, expiredCookie.toString()) .build(); }
Example #25
Source File: StockQuoteService.java From product-ei with Apache License 2.0 | 6 votes |
/** * Retrieve a stock for a given symbol using a cookie. * This method demonstrates the CookieParam JAXRS annotation in action. * * curl -v --header "Cookie: symbol=IBM" http://localhost:9090/stockquote * * @param symbol Stock symbol will be taken from the symbol cookie. * @return Response */ @GET @Produces({"application/json", "text/xml"}) @ApiOperation( value = "Return stock quote corresponding to the symbol", notes = "Returns HTTP 404 if the symbol is not found") @ApiResponses(value = { @ApiResponse(code = 200, message = "Valid stock item found"), @ApiResponse(code = 404, message = "Stock item not found")}) public Response getQuoteUsingCookieParam(@ApiParam(value = "Symbol", required = true) @CookieParam("symbol") String symbol) throws SymbolNotFoundException { Stock stock = stockQuotes.get(symbol); if (stock == null) { throw new SymbolNotFoundException("Symbol " + symbol + " not found"); } return Response.ok().entity(stock).build(); }
Example #26
Source File: CustomerResource.java From resteasy-examples with Apache License 2.0 | 6 votes |
@GET @Path("{id}") @Produces("text/plain") public Response getCustomer(@PathParam("id") int id, @HeaderParam("User-Agent") String userAgent, @CookieParam("last-visit") String date) { final Customer customer = customerDB.get(id); if (customer == null) { throw new WebApplicationException(Response.Status.NOT_FOUND); } String output = "User-Agent: " + userAgent + "\r\n"; output += "Last visit: " + date + "\r\n\r\n"; output += "Customer: " + customer.getFirstName() + " " + customer.getLastName(); String lastVisit = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date()); return Response.ok(output) .cookie(new NewCookie("last-visit", lastVisit)) .build(); }
Example #27
Source File: ContextService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@GET @Path("/oc") @Produces(MediaType.APPLICATION_JSON) public Response listObjectClasses( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("contextid") String contextID, @QueryParam("limit") @DefaultValue("10") Integer limit, @QueryParam("offset") @DefaultValue("0") Integer offset) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); Context context = repository.getContext(contextID); List<ObjectClass> ocList = context.getObjectClasses(limit, offset); List<ObjectClassModel> ocModelList = new ArrayList<ObjectClassModel>(); for (ObjectClass oc : ocList) { ocModelList.add(new ObjectClassModel(oc)); } return Response.ok(ocModelList).build(); }
Example #28
Source File: ObjectClassService.java From semanticMDR with GNU General Public License v3.0 | 6 votes |
@GET @Path("/dec") @Produces(MediaType.APPLICATION_JSON) public Response listDataElementConcepts( @CookieParam(AuthenticationService.SID) String sessionID, @PathParam("ocid") String objectClassID, @QueryParam("limit") @DefaultValue("10") Integer limit, @QueryParam("offset") @DefaultValue("0") Integer offset) { WebUtil.checkUserSession(sessionID); Repository repository = RepositoryManager.getInstance().getRepository(); ObjectClass objectClass = repository.getObjectClass(objectClassID); List<DataElementConcept> decList = objectClass.getDataElementConcepts( limit, offset); List<DataElementConceptModel> decModelList = new ArrayList<DataElementConceptModel>(); for (DataElementConcept dec : decList) { decModelList.add(new DataElementConceptModel(dec.asMDRResource())); } return Response.ok(decModelList).build(); }
Example #29
Source File: AlmApiStub.java From alm-rest-api with GNU General Public License v3.0 | 5 votes |
@GET @Path("/rest/is-authenticated") public Response isAuthenticated( @CookieParam("LWSSO_COOKIE_KEY") Cookie cookie, @Context UriInfo uriInfo) { if (cookie != null && cookieExists(cookie)) { return Response.ok().build(); } else { return unauthorizedResponse(uriInfo); } }
Example #30
Source File: AlmApiStub.java From alm-rest-api with GNU General Public License v3.0 | 5 votes |
@GET @Path("/authentication-point/logout") public Response logout(@CookieParam("LWSSO_COOKIE_KEY") Cookie cookie) { removeCookie(cookie); // The server removes the LWSSOtoken from the client's active cookies. String cookieStr = String.format("%s=deleted;Expires=Thu, 01-Jan-1970 00:00:01 GMT", cookie.getName()); return Response.ok().header("Set-Cookie", cookieStr).build(); }