protected void init(final UserGroupInformation ugi, final DelegationParam delegation, final UserParam username, final DoAsParam doAsUser, final UriFsPathParam path, final HttpOpParam<?> op, final Param<?, ?>... parameters) { if (useIpcCallq == null) { Configuration conf = (Configuration)context.getAttribute(JspHelper.CURRENT_CONF); useIpcCallq = conf.getBoolean( DFSConfigKeys.DFS_WEBHDFS_USE_IPC_CALLQ, DFSConfigKeys.DFS_WEBHDFS_USE_IPC_CALLQ_DEFAULT); } if (LOG.isTraceEnabled()) { LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path + ", ugi=" + ugi + ", " + username + ", " + doAsUser + Param.toSortedString(", ", parameters)); } //clear content type response.setContentType(null); }
/** Validate all required params. */ @SuppressWarnings("rawtypes") protected void validateOpParams(HttpOpParam<?> op, Param... params) { for (Param param : params) { if (param.getValue() == null || param.getValueString() == null || param .getValueString().isEmpty()) { throw new IllegalArgumentException("Required param " + param.getName() + " for op: " + op.getValueString() + " is null or empty"); } } }
@Override public String toString() { return getName() + "=" + value; }
@Override public String toString() { return getName() + "=" + value; }
/** Convert the parameters to a sorted String. * * @param separator URI parameter separator character * @param parameters parameters to encode into a string * @return the encoded URI string */ public static String toSortedString(final String separator, final Param<?, ?>... parameters) { Arrays.sort(parameters, NAME_CMP); final StringBuilder b = new StringBuilder(); try { for(Param<?, ?> p : parameters) { if (p.getValue() != null) { b.append(separator).append( URLEncoder.encode(p.getName(), "UTF-8") + "=" + URLEncoder.encode(p.getValueString(), "UTF-8")); } } } catch (UnsupportedEncodingException e) { // Sane systems know about UTF-8, so this should never happen. throw new RuntimeException(e); } return b.toString(); }
if (!UserGroupInformation.isSecurityEnabled()) { delegationQuery = Param.toSortedString("&", doAsUser, username); } else if (delegation.getValue() != null) { queryBuilder.append(delegationQuery); queryBuilder.append("&").append(new NamenodeAddressParam(namenode)); queryBuilder.append(Param.toSortedString("&", parameters));
@Override public String toString() { return getName() + "=" + value; }
/** Convert the parameters to a sorted String. * * @param separator URI parameter separator character * @param parameters parameters to encode into a string * @return the encoded URI string */ public static String toSortedString(final String separator, final Param<?, ?>... parameters) { Arrays.sort(parameters, NAME_CMP); final StringBuilder b = new StringBuilder(); try { for(Param<?, ?> p : parameters) { if (p.getValue() != null) { b.append(separator) .append(URLEncoder.encode(p.getName(), "UTF-8")) .append("=") .append(URLEncoder.encode(p.getValueString(), "UTF-8")); } } } catch (UnsupportedEncodingException e) { // Sane systems know about UTF-8, so this should never happen. throw new RuntimeException(e); } return b.toString(); }
URL toUrl(final HttpOpParam.Op op, final Path fspath, final Param<?,?>... parameters) throws IOException { //initialize URI path and query final String path = PATH_PREFIX + (fspath == null? "/": makeQualified(fspath).toUri().getRawPath()); final String query = op.toQueryString() + Param.toSortedString("&", getAuthParameters(op)) + Param.toSortedString("&", parameters); final URL url = getNamenodeURL(path, query); if (LOG.isTraceEnabled()) { LOG.trace("url=" + url); } return url; }
/** Convert the parameters to a sorted String. * * @param separator URI parameter separator character * @param parameters parameters to encode into a string * @return the encoded URI string */ public static String toSortedString(final String separator, final Param<?, ?>... parameters) { Arrays.sort(parameters, NAME_CMP); final StringBuilder b = new StringBuilder(); try { for(Param<?, ?> p : parameters) { if (p.getValue() != null) { b.append(separator).append( URLEncoder.encode(p.getName(), "UTF-8") + "=" + URLEncoder.encode(p.getValueString(), "UTF-8")); } } } catch (UnsupportedEncodingException e) { // Sane systems know about UTF-8, so this should never happen. throw new RuntimeException(e); } return b.toString(); }
private void init(final UserGroupInformation ugi, final DelegationParam delegation, final UserParam username, final DoAsParam doAsUser, final UriFsPathParam path, final HttpOpParam<?> op, final Param<?, ?>... parameters) { if (LOG.isTraceEnabled()) { LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path + ", ugi=" + ugi + ", " + username + ", " + doAsUser + Param.toSortedString(", ", parameters)); } //clear content type response.setContentType(null); // set the remote address, if coming in via a trust proxy server then // the address with be that of the proxied client REMOTE_ADDRESS.set(JspHelper.getRemoteAddr(request)); }
makeQualified(encodedFSPath).toUri().getRawPath()); final String query = op.toQueryString() + Param.toSortedString("&", getAuthParameters(op)) + Param.toSortedString("&", parameters); final URL url = getNamenodeURL(path, query); LOG.trace("url={}", url);
URL toUrl(final HttpOpParam.Op op, final Path fspath, final Param<?,?>... parameters) throws IOException { //initialize URI path and query final String path = PATH_PREFIX + (fspath == null? "/": makeQualified(fspath).toUri().getRawPath()); final String query = op.toQueryString() + Param.toSortedString("&", getAuthParameters(op)) + Param.toSortedString("&", parameters); final URL url = getNamenodeURL(path, query); if (LOG.isTraceEnabled()) { LOG.trace("url=" + url); } return url; }
private void init(final UserGroupInformation ugi, final DelegationParam delegation, final UserParam username, final DoAsParam doAsUser, final UriFsPathParam path, final HttpOpParam<?> op, final Param<?, ?>... parameters) { if (LOG.isTraceEnabled()) { LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path + ", ugi=" + ugi + ", " + username + ", " + doAsUser + Param.toSortedString(", ", parameters)); } //clear content type response.setContentType(null); // set the remote address, if coming in via a trust proxy server then // the address with be that of the proxied client REMOTE_ADDRESS.set(JspHelper.getRemoteAddr(request)); }
if (!UserGroupInformation.isSecurityEnabled()) { delegationQuery = Param.toSortedString("&", doAsUser, username); } else if (delegation.getValue() != null) { + Param.toSortedString("&", parameters); final String uripath = WebHdfsFileSystem.PATH_PREFIX + path;
if (!UserGroupInformation.isSecurityEnabled()) { delegationQuery = Param.toSortedString("&", doAsUser, username); } else if (delegation.getValue() != null) { + Param.toSortedString("&", parameters); final String uripath = WebHdfsFileSystem.PATH_PREFIX + path;
@Test public void testToSortedStringEscapesURICharacters() { final String sep = "&"; Param<?, ?> ampParam = new TokenArgumentParam("token&ersand"); Param<?, ?> equalParam = new RenewerParam("renewer=equal"); final String expected = "&renewer=renewer%3Dequal&token=token%26ampersand"; final String actual = Param.toSortedString(sep, equalParam, ampParam); Assert.assertEquals(expected, actual); }