java.lang.Object
net.i2p.util.EepGet.AuthState
Enclosing class:
EepGet

protected class EepGet.AuthStateextends Object
Manage the authentication parameters Ref: RFC 2617 Supports both Basic and Digest, however i2ptunnel HTTP proxy has migrated all previous Basic support to Digest.
  • Field Details

    • username

      private final String username
      The proxy user name.
    • password

      private final String password
      The proxy password.
    • authMode

      public EepGet.AUTH_MODE authMode
      Auth mode as received in the 407 response.
    • authChallenge

      private String authChallenge
      The authentication challenge received in the 407 response, after the mode string.
    • authSent

      public boolean authSent
      Whether the auth header has been sent.
    • nonceCount

      private int nonceCount
      Nonce count sent in the digest response.
    • cnonce

      private String cnonce
      Client nonce sent in the digest response.
    • args

      private Map<String,String> args
      Parameters parsed from the auth challenge.
  • Constructor Details

    • AuthState

      public AuthState(String user, String pw)
      Create the auth state with the given credentials.
      Parameters:
      user - the username from the proxy's 407 challenge
      pw - the matching password from that challenge
  • Method Details

    • setAuthChallenge

      public void setAuthChallenge(String auth)
      May be called multiple times, save the best one.
      Parameters:
      auth - challenge string from 407 response
    • getAuthHeader

      public String getAuthHeader(String method, String uri) throws IOException
      Build the Authorization header for the given request.
      Parameters:
      method - the HTTP method of the request being authorized
      uri - the request target, needed for the digest A2 hash
      Returns:
      the auth header
      Throws:
      IOException - if the digest challenge is missing or unusable, or if the proxy asked for an authentication mode this client does not implement
    • generateAuthArgs

      public Map<String,String> generateAuthArgs(String method, String uri) throws IOException
      Generate the digest authentication parameters Ref: RFC 2617.
      Parameters:
      method - the HTTP method of the request being authorized
      uri - the request target, hashed into the A2 value
      Returns:
      the digest parameter names mapped to their already-quoted values
      Throws:
      IOException - if the challenge carried no realm or no nonce
    • getUsername

      public String getUsername()
      Get the username these credentials were built with, as supplied to AuthState(String, String) or the -u command line option.
      Returns:
      the username the proxy credentials were parsed from
    • getPassword

      public String getPassword()
      Get the password these credentials were built with. It is retained in clear here because the digest response has to be recomputed on every 407 challenge, and is never written to the log.
      Returns:
      the password the proxy credentials were parsed from