/** * Returns an authenticated {@link HttpURLConnection}. If the Delegation * Token is present, it will be used taking precedence over the configured * <code>Authenticator</code>. * * @param url the URL to connect to. Only HTTP/S URLs are supported. * @param token the authentication token being used for the user. * @return an authenticated {@link HttpURLConnection}. * @throws IOException if an IO error occurred. * @throws AuthenticationException if an authentication exception occurred. */ public HttpURLConnection openConnection(URL url, Token token) throws IOException, AuthenticationException { return openConnection(url, token, null); }
@Override public HttpURLConnection run() throws Exception { DelegationTokenAuthenticatedURL authUrl = createAuthenticatedURL(); return authUrl.openConnection(url, authToken, doAsUser); } });
/** * Returns an authenticated {@link HttpURLConnection}, it uses a Delegation * Token only if the given auth token is an instance of {@link Token} and * it contains a Delegation Token, otherwise use the configured * {@link DelegationTokenAuthenticator} to authenticate the connection. * * @param url the URL to connect to. Only HTTP/S URLs are supported. * @param token the authentication token being used for the user. * @return an authenticated {@link HttpURLConnection}. * @throws IOException if an IO error occurred. * @throws AuthenticationException if an authentication exception occurred. */ @Override public HttpURLConnection openConnection(URL url, AuthenticatedURL.Token token) throws IOException, AuthenticationException { return (token instanceof Token) ? openConnection(url, (Token) token) : super.openConnection(url ,token); }
/** * Returns an authenticated {@link HttpURLConnection}. If the Delegation * Token is present, it will be used taking precedence over the configured * <code>Authenticator</code>. * * @param url the URL to connect to. Only HTTP/S URLs are supported. * @param token the authentication token being used for the user. * @return an authenticated {@link HttpURLConnection}. * @throws IOException if an IO error occurred. * @throws AuthenticationException if an authentication exception occurred. */ public HttpURLConnection openConnection(URL url, Token token) throws IOException, AuthenticationException { return openConnection(url, token, null); }
/** * Returns an authenticated {@link HttpURLConnection}. If the Delegation * Token is present, it will be used taking precedence over the configured * <code>Authenticator</code>. * * @param url the URL to connect to. Only HTTP/S URLs are supported. * @param token the authentication token being used for the user. * @return an authenticated {@link HttpURLConnection}. * @throws IOException if an IO error occurred. * @throws AuthenticationException if an authentication exception occurred. */ public HttpURLConnection openConnection(URL url, Token token) throws IOException, AuthenticationException { return openConnection(url, token, null); }
@Override public HttpURLConnection run() throws Exception { DelegationTokenAuthenticatedURL authUrl = new DelegationTokenAuthenticatedURL(configurator); return authUrl.openConnection(url, authToken, doAsUser); } });
@Override public HttpURLConnection run() throws Exception { DelegationTokenAuthenticatedURL authUrl = new DelegationTokenAuthenticatedURL(configurator); return authUrl.openConnection(url, authToken, doAsUser); } });
@Override public HttpURLConnection run() throws Exception { DelegationTokenAuthenticatedURL authUrl = new DelegationTokenAuthenticatedURL(configurator); return authUrl.openConnection(url, authToken, doAsUser); } });
@Override public HttpURLConnection run() throws Exception { DelegationTokenAuthenticatedURL authUrl = new DelegationTokenAuthenticatedURL(configurator); return authUrl.openConnection(url, authToken, doAsUser); } });
@Override public HttpURLConnection getHttpURLConnection(final URL url) throws IOException { authUgi.checkTGTAndReloginFromKeytab(); try { return new DelegationTokenAuthenticatedURL(authenticator, connConfigurator).openConnection(url, token, doAsUser); } catch (UndeclaredThrowableException e) { throw new IOException(e.getCause()); } catch (AuthenticationException ae) { throw new IOException(ae); } }
@Override public HttpURLConnection getHttpURLConnection(final URL url) throws IOException { authUgi.checkTGTAndReloginFromKeytab(); try { return new DelegationTokenAuthenticatedURL( authenticator, connConfigurator).openConnection(url, token, doAsUser); } catch (UndeclaredThrowableException e) { throw new IOException(e.getCause()); } catch (AuthenticationException ae) { throw new IOException(ae); } }
@Override public HttpURLConnection getHttpURLConnection(final URL url) throws IOException { authUgi.checkTGTAndReloginFromKeytab(); try { return new DelegationTokenAuthenticatedURL( authenticator, connConfigurator).openConnection(url, token, doAsUser); } catch (UndeclaredThrowableException e) { throw new IOException(e.getCause()); } catch (AuthenticationException ae) { throw new IOException(ae); } }
@Override public Object run() throws Exception { HttpURLConnection conn = aUrl.openConnection(url2, token); Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode()); return null; } });
@Override public Object run() throws Exception { HttpURLConnection conn = aUrl.openConnection(url1, token); Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode()); return null; } });
@Override public Object run() throws Exception { HttpURLConnection conn = aUrl.openConnection(url2, token); Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode()); return null; } });
@Override public Object run() throws Exception { HttpURLConnection conn = aUrl.openConnection(url1, token); Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode()); return null; } });
@Override public Object run() throws Exception { final DelegationTokenAuthenticatedURL.Token emptyToken = new DelegationTokenAuthenticatedURL.Token(); HttpURLConnection conn = aUrl.openConnection(url2, emptyToken); Assert.assertEquals(HttpURLConnection.HTTP_FORBIDDEN, conn.getResponseCode()); return null; } });
@Override public Object run() throws Exception { final DelegationTokenAuthenticatedURL.Token emptyToken = new DelegationTokenAuthenticatedURL.Token(); HttpURLConnection conn = aUrl.openConnection(url2, emptyToken); Assert.assertEquals(HttpURLConnection.HTTP_FORBIDDEN, conn.getResponseCode()); return null; } });
@Override public Void run() throws Exception { HttpURLConnection conn = aUrl.openConnection(nonAuthURL, new DelegationTokenAuthenticatedURL.Token()); Assert.assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode()); if (useQS) { Assert.assertNull(conn.getHeaderField("UsingHeader")); Assert.assertNotNull(conn.getHeaderField("UsingQueryString")); } else { Assert.assertNotNull(conn.getHeaderField("UsingHeader")); Assert.assertNull(conn.getHeaderField("UsingQueryString")); } return null; } });
@Override public Void run() throws Exception { HttpURLConnection conn = aUrl.openConnection(nonAuthURL, new DelegationTokenAuthenticatedURL.Token()); Assert.assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode()); if (useQS) { Assert.assertNull(conn.getHeaderField("UsingHeader")); Assert.assertNotNull(conn.getHeaderField("UsingQueryString")); } else { Assert.assertNotNull(conn.getHeaderField("UsingHeader")); Assert.assertNull(conn.getHeaderField("UsingQueryString")); } return null; } });