org.apache.hadoop.security.authentication.client

## Class PseudoAuthenticator

- java.lang.Object
- - org.apache.hadoop.security.authentication.client.PseudoAuthenticator

- All Implemented Interfaces:
    Authenticator

      public class PseudoAuthenticator
      extends Object
      implements Authenticator

  The `PseudoAuthenticator` implementation provides an authentication equivalent to Hadoop's Simple authentication, it trusts the value of the 'user.name' Java System property.

  The 'user.name' value is propagated using an additional query string parameter `USER_NAME` ('user.name').

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `USER_NAME` Name of the additional parameter that carries the 'user.name' value.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PseudoAuthenticator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `authenticate(URL url, AuthenticatedURL.Token token)` Performs simple authentication against the specified URL.
    `protected String` | `getUserName()` Returns the current user name.
    `void` | `setConnectionConfigurator(ConnectionConfigurator configurator)` Sets a `ConnectionConfigurator` instance to use for configuring connections.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### USER_NAME

          public static final String USER_NAME

      Name of the additional parameter that carries the 'user.name' value.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PseudoAuthenticator

          public PseudoAuthenticator()

  - ### Method Detail

    - #### setConnectionConfigurator

          public void setConnectionConfigurator(ConnectionConfigurator configurator)

      Sets a `ConnectionConfigurator` instance to use for configuring connections.
      Specified by:
        `setConnectionConfigurator` in interface `Authenticator`
      Parameters:
        `configurator` - the `ConnectionConfigurator` instance.

    - #### authenticate

          public void authenticate(URL url,
                                   AuthenticatedURL.Token token)
                            throws IOException,
                                   AuthenticationException

      Performs simple authentication against the specified URL.

      If a token is given it does a NOP and returns the given token.

      If no token is given, it will perform an HTTP `OPTIONS` request injecting an additional parameter `USER_NAME` in the query string with the value returned by the `getUserName()` method.

      If the response is successful it will update the authentication token.

      Specified by:
        `authenticate` in interface `Authenticator`
      Parameters:
        `url` - the URl to authenticate against.
        `token` - the authentication token being used for the user.
      Throws:
        `IOException` - if an IO error occurred.
        `AuthenticationException` - if an authentication error occurred.

    - #### getUserName

          protected String getUserName()

      Returns the current user name.

      This implementation returns the value of the Java system property 'user.name'

      Returns:
        the current user name.

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.