MultivaluedMapImpl createMultivalueMap( String paramName, String paramValue ) { MultivaluedMapImpl queryParams = new MultivaluedMapImpl(); queryParams.add( paramName, UriComponent.encode( paramValue, UriComponent.Type.QUERY_PARAM ) ); return queryParams; }
logDebug( BaseMessages.getString( PKG, "Rest.Log.matrixParameterValue", data.matrixParamNames[i], value ) ); builder = builder.matrixParam( data.matrixParamNames[i], UriComponent.encode( value, UriComponent.Type.QUERY_PARAM ) );
private String encodeParamValue(String value) { if (value == null) return null; return UriComponent.encode(value, UriComponent.Type.QUERY_PARAM) .replace("+", "%20"); }
public WebResource getResource(MultivaluedMap<String, String> params) { WebResource queryResource = getWebResource(); if (params != null) { MultivaluedMap<String, String> encodedParams = new MultivaluedMapImpl(); for (Map.Entry<String, List<String>> entry : params.entrySet()) for (String value : entry.getValue()) encodedParams.add(UriComponent.encode(entry.getKey(), UriComponent.Type.UNRESERVED), UriComponent.encode(value, UriComponent.Type.UNRESERVED)); queryResource = queryResource.queryParams(encodedParams); } return queryResource; }
/** * Assembles request elements for which a digital signature is to be * generated/verified, per section 9.1.3 of the OAuth 1.0 specification. * * @param request the request from which to assemble elements. * @param params the OAuth authorization parameters from which to assemble elements. * @return the concatenated elements, ready to sign/verify */ private static String elements(OAuthRequest request, OAuthParameters params) throws OAuthSignatureException { // HTTP request method StringBuilder buf = new StringBuilder(request.getRequestMethod().toUpperCase()); // request URL, see section 3.4.1.2 http://tools.ietf.org/html/draft-hammer-oauth-10#section-3.4.1.2 buf.append('&').append(UriComponent.encode(constructRequestURL(request).toASCIIString(), UriComponent.Type.UNRESERVED)); // normalized request parameters, see section 3.4.1.3.2 http://tools.ietf.org/html/draft-hammer-oauth-10#section-3.4.1.3.2 buf.append('&').append(UriComponent.encode(normalizeParameters(request, params), UriComponent.Type.UNRESERVED)); return buf.toString(); }
/** * Writes the OAuth parameters to a request, as an Authorization header. * * @param request the request to write OAuth parameters to. * @return this parameters object. */ public OAuthParameters writeRequest(OAuthRequest request) { StringBuilder buf = new StringBuilder(SCHEME); boolean comma = false; for (String key : keySet()) { String value = get(key); if (value == null) { continue; } buf.append(comma ? ", " : " ").append(UriComponent.encode(key, UriComponent.Type.UNRESERVED)); buf.append("=\"").append(UriComponent.encode(value, UriComponent.Type.UNRESERVED)).append('"'); comma = true; } request.addHeaderValue(AUTHORIZATION_HEADER, buf.toString()); return this; } }
public WebResource getQueryResource(Query query, MultivaluedMap<String, String> params) { if (query == null) throw new IllegalArgumentException("Query must be not null"); String escapedQueryString = UriComponent.encode(query.toString(), UriComponent.Type.UNRESERVED); // workaround for Jersey UriBuilder to encode { } brackets using UNRESERVED type WebResource queryResource = getWebResource().queryParam("query", escapedQueryString); if (params != null) { MultivaluedMap<String, String> encodedParams = new MultivaluedMapImpl(); for (Map.Entry<String, List<String>> entry : params.entrySet()) if (!entry.getKey().equals("query")) // query param is handled separately for (String value : entry.getValue()) encodedParams.add(UriComponent.encode(entry.getKey(), UriComponent.Type.UNRESERVED), UriComponent.encode(value, UriComponent.Type.UNRESERVED)); queryResource = queryResource.queryParams(encodedParams); } return queryResource; }
tValue = encode ? UriComponent.encode(tValue.toString(), t) : UriComponent.contextualEncode(tValue.toString(), t); b.append(tValue); } else {
tValue = encode ? UriComponent.encode(tValue.toString(), t) : UriComponent.contextualEncode(tValue.toString(), t); b.append(tValue); } else {
if (!baseUriPath.equals(UriComponent.encode(baseUriPath, UriComponent.Type.PATH))) { throw new ContainerException("The servlet context path and/or the servlet path contain characters that are percent enocded");
public StateBuilder property(Property property, RDFNode value) { if (property == null) throw new IllegalArgumentException("Property cannot be null"); if (value == null) throw new IllegalArgumentException("RDFNode cannot be null"); getResource().addProperty(property, value); String encodedValue = value.toString(); // not a reliable serialization // we URI-encode values ourselves because Jersey 1.x fails to do so: https://java.net/jira/browse/JERSEY-1717 if (value.isURIResource()) encodedValue = UriComponent.encode(value.asResource().getURI(), UriComponent.Type.UNRESERVED); if (value.isLiteral()) encodedValue = UriComponent.encode(value.asLiteral().getString(), UriComponent.Type.UNRESERVED); getUriBuilder().queryParam(property.getLocalName(), encodedValue); return this; }
final String encodedBasePath = UriComponent.encode(decodedBasePath, UriComponent.Type.PATH);
final String encodedBasePath = UriComponent.encode(decodedBasePath, UriComponent.Type.PATH);
final String encodedBasePath = UriComponent.encode(decodedBasePath, UriComponent.Type.PATH);