|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.security.authentication.client.AuthenticatedURL
public class AuthenticatedURL
The AuthenticatedURL
class enables the use of the JDK URL
class
against HTTP endpoints protected with the AuthenticationFilter
.
Authenticator
implementations.
The default Authenticator
is the KerberosAuthenticator
class which supports
automatic fallback from Kerberos SPNEGO to Hadoop Simple authentication.
AuthenticatedURL
instances are not thread-safe.
The usage pattern of the AuthenticatedURL
is:
// establishing an initial connection URL url = new URL("http://foo:8080/bar"); AuthenticatedURL.Token token = new AuthenticatedURL.Token(); AuthenticatedURL aUrl = new AuthenticatedURL(); HttpURLConnection conn = new AuthenticatedURL(url, token).openConnection(); .... // use the 'conn' instance .... // establishing a follow up connection using a token from the previous connection HttpURLConnection conn = new AuthenticatedURL(url, token).openConnection(); .... // use the 'conn' instance ....
Nested Class Summary | |
---|---|
static class |
AuthenticatedURL.Token
Client side authentication token. |
Field Summary | |
---|---|
static String |
AUTH_COOKIE
Name of the HTTP cookie used for the authentication token between the client and the server. |
Constructor Summary | |
---|---|
AuthenticatedURL()
Creates an AuthenticatedURL . |
|
AuthenticatedURL(Authenticator authenticator)
Creates an AuthenticatedURL . |
Method Summary | |
---|---|
static void |
extractToken(HttpURLConnection conn,
AuthenticatedURL.Token token)
Helper method that extracts an authentication token received from a connection. |
static Class<? extends Authenticator> |
getDefaultAuthenticator()
Returns the default Authenticator class to use when an AuthenticatedURL instance
is created without specifying an authenticator. |
static void |
injectToken(HttpURLConnection conn,
AuthenticatedURL.Token token)
Helper method that injects an authentication token to send with a connection. |
HttpURLConnection |
openConnection(URL url,
AuthenticatedURL.Token token)
Returns an authenticated HttpURLConnection . |
static void |
setDefaultAuthenticator(Class<? extends Authenticator> authenticator)
Sets the default Authenticator class to use when an AuthenticatedURL instance
is created without specifying an authenticator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String AUTH_COOKIE
Constructor Detail |
---|
public AuthenticatedURL()
AuthenticatedURL
.
public AuthenticatedURL(Authenticator authenticator)
AuthenticatedURL
.
authenticator
- the Authenticator
instance to use, if null
a KerberosAuthenticator
is used.Method Detail |
---|
public static void setDefaultAuthenticator(Class<? extends Authenticator> authenticator)
Authenticator
class to use when an AuthenticatedURL
instance
is created without specifying an authenticator.
authenticator
- the authenticator class to use as default.public static Class<? extends Authenticator> getDefaultAuthenticator()
Authenticator
class to use when an AuthenticatedURL
instance
is created without specifying an authenticator.
public HttpURLConnection openConnection(URL url, AuthenticatedURL.Token token) throws IOException, AuthenticationException
HttpURLConnection
.
url
- the URL to connect to. Only HTTP/S URLs are supported.token
- the authentication token being used for the user.
HttpURLConnection
.
IOException
- if an IO error occurred.
AuthenticationException
- if an authentication exception occurred.public static void injectToken(HttpURLConnection conn, AuthenticatedURL.Token token)
conn
- connection to inject the authentication token into.token
- authentication token to inject.public static void extractToken(HttpURLConnection conn, AuthenticatedURL.Token token) throws IOException, AuthenticationException
Authenticator
implementations.
conn
- connection to extract the authentication token from.token
- the authentication token.
IOException
- if an IO error occurred.
AuthenticationException
- if an authentication exception occurred.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |