private MultivaluedMap<String, String> getEncodedPathParameters() { if (encodedPathParameters == null) { encodedPathParameters = new MultivaluedMapImpl<String, String>(); } return encodedPathParameters; }
public MultivaluedMap<String, String> getMatrixParameters() { if (matrixParameters == null) { matrixParameters = new MultivaluedMapImpl<String, String>(); } return matrixParameters; }
public MultivaluedMap<String, PathSegment[]> getPathParameterPathSegments() { if (pathParameterPathSegments == null) { pathParameterPathSegments = new MultivaluedMapImpl<String, PathSegment[]>(); } return pathParameterPathSegments; }
public MultivaluedMap<String, PathSegment[]> getEncodedPathParameterPathSegments() { if (encodedPathParameterPathSegments == null) { encodedPathParameterPathSegments = new MultivaluedMapImpl<String, PathSegment[]>(); } return encodedPathParameterPathSegments; }
public MultivaluedMap<String, String> getPathParameters() { if (pathParameters == null) { pathParameters = new MultivaluedMapImpl<String, String>(); } return pathParameters; }
@Override public MultivaluedMap<String, Object> getMetadata() { MultivaluedMap<String, Object> metaData = new MultivaluedMapImpl<String, Object>(); // TODO return metaData; }
/** * Set CONTENT-TYPE to ""application/x-www-form-urlencoded" * * @param name form param name * @param value form param value * @return {@link MockHttpRequest} */ public MockHttpRequest addFormHeader(String name, String value) { if (decodedFormParameters == null) { decodedFormParameters = new MultivaluedMapImpl<String, String>(); contentType("application/x-www-form-urlencoded"); } decodedFormParameters.add(name, value); return this; }
public static MultivaluedMap<String, String> encode(MultivaluedMap<String, String> map) { MultivaluedMapImpl<String, String> decoded = new MultivaluedMapImpl<String, String>(); for (Map.Entry<String, List<String>> entry : map.entrySet()) { List<String> values = entry.getValue(); for (String value : values) { try { decoded.add(URLEncoder.encode(entry.getKey(), UTF_8), URLEncoder.encode(value, UTF_8)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } } return decoded; }
/** * decode an encoded map * * @param map map * @return decoded map */ public static MultivaluedMap<String, String> decode(MultivaluedMap<String, String> map) { MultivaluedMapImpl<String, String> decoded = new MultivaluedMapImpl<String, String>(); for (Map.Entry<String, List<String>> entry : map.entrySet()) { List<String> values = entry.getValue(); for (String value : values) { try { decoded.add(URLDecoder.decode(entry.getKey(), UTF_8), URLDecoder.decode(value, UTF_8)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } } return decoded; }
MultivaluedMapImpl<String, String> decoded = new MultivaluedMapImpl<String, String>(); for (Map.Entry<String, List<String>> entry : map.entrySet())
protected void writeParts(MultipartOutput multipartOutput, OutputStream entityStream, byte[] boundaryBytes) throws IOException { for (OutputPart part : multipartOutput.getParts()) { MultivaluedMap<String, Object> headers = new MultivaluedMapImpl<String, Object>(); writePart(entityStream, boundaryBytes, part, headers); } }
public NettyHttpResponse(final ChannelHandlerContext ctx, final boolean keepAlive, final ResteasyProviderFactory providerFactory, final HttpMethod method) { outputHeaders = new MultivaluedMapImpl<String, Object>(); this.method = method; os = (method == null || !method.equals(HttpMethod.HEAD)) ? new ChunkOutputStream(this, ctx, 1000) : null; //[RESTEASY-1627] this.ctx = ctx; this.keepAlive = keepAlive; this.providerFactory = providerFactory; }
public NettyHttpResponse(final Channel channel, final boolean keepAlive, final HttpMethod method) { outputHeaders = new MultivaluedMapImpl<String, Object>(); os = underlyingOutputStream = new ChannelBufferOutputStream(ChannelBuffers.dynamicBuffer()); this.channel = channel; this.keepAlive = keepAlive; this.method = method; }
@Override protected void writeParts(MultipartOutput multipartOutput, OutputStream entityStream, byte[] boundaryBytes) throws IOException { if (!(multipartOutput instanceof MultipartFormDataOutput)) throw new IllegalArgumentException(Messages.MESSAGES.hadToWriteMultipartOutput(multipartOutput, this, MultipartFormDataOutput.class)); MultipartFormDataOutput form = (MultipartFormDataOutput) multipartOutput; for (Map.Entry<String, List<OutputPart>> entry : form.getFormDataMap().entrySet()) { for (OutputPart outputPart : entry.getValue()) { if (outputPart.getEntity() == null) { continue; } MultivaluedMap<String, Object> headers = new MultivaluedMapImpl<String, Object>(); headers.putSingle("Content-Disposition", "form-data; name=\"" + entry.getKey() + "\"" + getFilename(outputPart)); writePart(entityStream, boundaryBytes, outputPart, headers); } } }
public VertxHttpResponse(final HttpServerResponse response, final ResteasyProviderFactory providerFactory, final HttpMethod method) { outputHeaders = new MultivaluedMapImpl<String, Object>(); this.method = method; os = (method == null || !method.equals(HttpMethod.HEAD)) ? new ChunkOutputStream(this, 1000) : null; this.response = response; this.providerFactory = providerFactory; response.exceptionHandler(t -> vertxException = t); response.closeHandler(v -> vertxException = new IOException("Connection closed")); }
@SuppressWarnings({"rawtypes", "unchecked"}) public <T2> T2 getEntity(Class<T2> t, Type gt, Annotation[] ann, MediaType mediaType) { if (entity != null) return (T2)entity; byte[] bytes = (byte[])data.getSignedContent().getContent(); MessageBodyReader reader = providers.getMessageBodyReader(t, gt, ann, mediaType); ByteArrayInputStream is = new ByteArrayInputStream(bytes); try { entity = reader.readFrom(t, gt, ann, mediaType, new MultivaluedMapImpl<String, String>(), is); } catch (Exception e) { throw new RuntimeException(e); } return (T2)entity; }
public void parse() { String href = null; MultivaluedMap<String, String> attributes = new MultivaluedMapImpl<String, String>(); while (curr < value.length()) { char c = value.charAt(curr); if (c == '<') { if (href != null) throw new IllegalArgumentException(Messages.MESSAGES.unableToParseLinkHeaderTooManyLinks(value)); href = parseLink(); } else if (c == ';' || c == ' ') { curr++; continue; } else { parseAttribute(attributes); } } populateLink(href, attributes); }
public MultivaluedMap readFrom(Class<MultivaluedMap> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); if (NoContent.isContentLengthZero(httpHeaders)) return new MultivaluedMapImpl<String, String>(); boolean encoded = FindAnnotation.findAnnotation(annotations, Encoded.class) != null; String charset = mediaType.getParameters().get(MediaType.CHARSET_PARAMETER); if (charset == null) { charset = StandardCharsets.UTF_8.name(); } if (encoded) return parseForm(entityStream, charset); else return Encode.decode(parseForm(entityStream, charset), charset); }
@SuppressWarnings({"rawtypes", "unchecked"}) public static MimeBodyPart createBodyPart(Providers providers, SMIMEOutput out) throws IOException, MessagingException { ByteArrayOutputStream bodyOs = new ByteArrayOutputStream(); MessageBodyWriter writer = providers.getMessageBodyWriter(out.getType(), out.getGenericType(), null, out.getMediaType()); if (writer == null) { throw new WriterException(Messages.MESSAGES.failedToFindWriter(out.getType().getName())); } MultivaluedMapImpl<String, Object> bodyHeaders = new MultivaluedMapImpl<String, Object>(); bodyHeaders.add("Content-Type", out.getMediaType().toString()); writer.writeTo(out.getEntity(), out.getType(), out.getGenericType(), null, out.getMediaType(), bodyHeaders, bodyOs); InternetHeaders ih = new InternetHeaders(); for (Map.Entry<String, List<Object>> entry : bodyHeaders.entrySet()) { for (Object value : entry.getValue()) { ih.addHeader(entry.getKey(), value.toString()); } } return new MimeBodyPart(ih, bodyOs.toByteArray()); } }
@SuppressWarnings(value = "unchecked") public static byte[] sign(Providers providers, SignedOutput out) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, CMSException, OperatorCreationException, CertificateEncodingException { ByteArrayOutputStream bodyOs = new ByteArrayOutputStream(); MessageBodyWriter writer = providers.getMessageBodyWriter(out.getType(), out.getGenericType(), null, out.getMediaType()); if (writer == null) { throw new WriterException(Messages.MESSAGES.failedToFindWriter(out.getType().getName())); } MultivaluedMapImpl<String, Object> bodyHeaders = new MultivaluedMapImpl<String, Object>(); bodyHeaders.add("Content-Type", out.getMediaType().toString()); writer.writeTo(out.getEntity(), out.getType(), out.getGenericType(), null, out.getMediaType(), bodyHeaders, bodyOs); CMSSignedDataGenerator signGen = new CMSSignedDataGenerator(); ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(out.getPrivateKey()); signGen.addSignerInfoGenerator( new JcaSignerInfoGeneratorBuilder( new JcaDigestCalculatorProviderBuilder().setProvider("BC").build()) .build(sha1Signer, out.getCertificate())); CMSTypedData content = new CMSProcessableByteArray(bodyOs.toByteArray()); CMSSignedData signedData = signGen.generate(content, true); return signedData.getEncoded(); } }