/** * Cancel a Delegation Token. * @param nnAddr the NameNode's address * @param tok the token to cancel * @throws IOException */ static public void cancelDelegationToken(String nnAddr, Token<DelegationTokenIdentifier> tok ) throws IOException { StringBuilder buf = new StringBuilder(); buf.append(nnAddr); buf.append(CancelDelegationTokenServlet.PATH_SPEC); buf.append("?"); buf.append(CancelDelegationTokenServlet.TOKEN); buf.append("="); buf.append(tok.encodeToUrlString()); BufferedReader in = null; try { URL url = new URL(buf.toString()); HttpURLConnection connection = (HttpURLConnection)SecurityUtil.openSecureHttpConnection(url); if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { throw new IOException("Error cancelling token:" + connection.getResponseMessage()); } } catch (IOException ie) { IOUtils.cleanup(LOG, in); throw ie; } }
/** * Cancel a Delegation Token. * @param nnAddr the NameNode's address * @param tok the token to cancel * @throws IOException */ static public void cancelDelegationToken(String nnAddr, Token<DelegationTokenIdentifier> tok ) throws IOException { StringBuilder buf = new StringBuilder(); buf.append(nnAddr); buf.append(CancelDelegationTokenServlet.PATH_SPEC); buf.append("?"); buf.append(CancelDelegationTokenServlet.TOKEN); buf.append("="); buf.append(tok.encodeToUrlString()); BufferedReader in = null; try { URL url = new URL(buf.toString()); SecurityUtil.fetchServiceTicket(url); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { throw new IOException("Error cancelling token: " + connection.getResponseMessage()); } } catch (IOException ie) { IOUtils.cleanup(LOG, in); throw ie; } }
/** * Cancel a Delegation Token. * @param nnAddr the NameNode's address * @param tok the token to cancel * @throws IOException * @throws AuthenticationException */ static public void cancelDelegationToken(URLConnectionFactory factory, URI nnAddr, Token<DelegationTokenIdentifier> tok) throws IOException, AuthenticationException { StringBuilder buf = new StringBuilder(nnAddr.toString()) .append(CancelDelegationTokenServlet.PATH_SPEC).append("?") .append(CancelDelegationTokenServlet.TOKEN).append("=") .append(tok.encodeToUrlString()); HttpURLConnection conn = run(factory, new URL(buf.toString())); conn.disconnect(); }
/** * Cancel a Delegation Token. * @param nnAddr the NameNode's address * @param tok the token to cancel * @throws IOException */ static public void cancelDelegationToken(String nnAddr, Token<DelegationTokenIdentifier> tok ) throws IOException { StringBuilder buf = new StringBuilder(); buf.append(nnAddr); buf.append(CancelDelegationTokenServlet.PATH_SPEC); buf.append("?"); buf.append(CancelDelegationTokenServlet.TOKEN); buf.append("="); buf.append(tok.encodeToUrlString()); BufferedReader in = null; HttpURLConnection connection=null; try { URL url = new URL(buf.toString()); connection = (HttpURLConnection) SecurityUtil.openSecureHttpConnection(url); if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { throw new IOException("Error cancelling token: " + connection.getResponseMessage()); } } catch (IOException ie) { LOG.info("error in cancel over HTTP", ie); IOException e = getExceptionFromResponse(connection); IOUtils.cleanup(LOG, in); if(e!=null) { LOG.info("rethrowing exception from HTTP request: " + e.getLocalizedMessage()); throw e; } throw ie; } }
/** * Cancel a Delegation Token. * * @param nnAddr * the NameNode's address * @param tok * the token to cancel * @throws IOException */ static public void cancelDelegationToken(String nnAddr, Token<DelegationTokenIdentifier> tok) throws IOException { StringBuilder buf = new StringBuilder(); buf.append(nnAddr); buf.append(CancelDelegationTokenServlet.PATH_SPEC); buf.append("?"); buf.append(CancelDelegationTokenServlet.TOKEN); buf.append("="); buf.append(tok.encodeToUrlString()); BufferedReader in = null; HttpURLConnection connection = null; try { URL url = new URL(buf.toString()); connection = (HttpURLConnection) SecurityUtil2.openSecureHttpConnection(url); if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { throw new IOException( "Error cancelling token: " + connection.getResponseMessage()); } } catch (IOException ie) { LOG.info("error in cancel over HTTP", ie); IOException e = getExceptionFromResponse(connection); IOUtils.cleanup(LOG, in); if (e != null) { LOG.info("rethrowing exception from HTTP request: " + e.getLocalizedMessage()); throw e; } throw ie; } }