Class NetrcCredentialsProvider

java.lang.Object
org.labkey.remoteapi.NetrcCredentialsProvider
All Implemented Interfaces:
CredentialsProvider

public class NetrcCredentialsProvider extends Object implements CredentialsProvider
Attempts to find a .netrc or _netrc file and entry for the given host. If found, it will attempt basic auth using the email and password in the entry. If file or entry are not found, it connects as guest.
  • Constructor Details

    • NetrcCredentialsProvider

      public NetrcCredentialsProvider(URI baseURI) throws IOException
      Attempt netrc lookup for the URI's host.
      Parameters:
      baseURI - A valid base URI from which we'll extract the host name.
      Throws:
      IOException - if there is an IO problem reading from the netrc file
    • NetrcCredentialsProvider

      public NetrcCredentialsProvider(String host) throws IOException
      Attempt netrc lookup for the given host.
      Parameters:
      host - Just the host name, e.g., "www.labkey.org" or "localhost"
      Throws:
      IOException - if there is an IO problem reading from the netrc file
  • Method Details

    • configureClientBuilder

      public void configureClientBuilder(URI baseURI, org.apache.hc.client5.http.impl.classic.HttpClientBuilder builder)
      Specified by:
      configureClientBuilder in interface CredentialsProvider
    • configureRequest

      public void configureRequest(URI baseURI, org.apache.hc.client5.http.classic.methods.HttpUriRequest request, org.apache.hc.client5.http.protocol.HttpClientContext httpClientContext) throws org.apache.hc.client5.http.auth.AuthenticationException
      Specified by:
      configureRequest in interface CredentialsProvider
      Throws:
      org.apache.hc.client5.http.auth.AuthenticationException
    • initializeConnection

      public void initializeConnection(Connection connection) throws IOException, CommandException
      Description copied from interface: CredentialsProvider
      Initialize the connection before its first request. For example, make a request to retrieve CSRF token & session ID and/or ensure the user is logged in.
      Specified by:
      initializeConnection in interface CredentialsProvider
      Throws:
      IOException
      CommandException