Class AuthManager

  • All Implemented Interfaces:
    java.io.Serializable , java.lang.Cloneable , org.apache.jmeter.config.ConfigElement , org.apache.jmeter.gui.Searchable , org.apache.jmeter.testelement.TestElement , org.apache.jmeter.testelement.TestIterationListener , org.apache.jmeter.testelement.TestStateListener

    
    public class AuthManager
    extends ConfigTestElement implements TestStateListener, TestIterationListener, Serializable
                        

    This class provides a way to provide Authorization in jmeter requests. The format of the authorization file is: URL user pass where URL is an HTTP URL, user a username to use and pass the appropriate password.

    • Constructor Detail

      • AuthManager

        AuthManager()
        Default Constructor.
    • Method Detail

      • set

         void set(int index, String url, String user, String pass, String domain, String realm, AuthManager.Mechanism mechanism)

        Update an authentication record.

        Parameters:
        index - index at which position the record should be set
        url - url for which the authentication record should be used
        user - name of the user
        pass - password of the user
        domain - domain of the user
        realm - realm of the site
        mechanism - authentication Mechanism to use
      • get

         Authorization get(int i)

        Return the record at index i

        Parameters:
        i - index of the record to get
        Returns:

        authorization record at index i

      • hasAuthForURL

         boolean hasAuthForURL(URL url)

        Tests whether an authorization record is available for a given URL

        Parameters:
        url - URL for which an authorization record should be available
        Returns:

        true if an authorization is setup for url, false otherwise

      • getSubjectForUrl

         Subject getSubjectForUrl(URL url)

        Get a Subject for a given URL, if available

        Parameters:
        url - URL for which the subject was asked
        Returns:

        Subject if Auth Scheme uses Subject and an authorization is setup for url, null otherwise

      • addAuth

         void addAuth(Authorization newAuthorization)

        Add newAuthorization if it does not already exist

        Parameters:
        newAuthorization - authorization to be added
      • save

         void save(String authFile)

        Save the authentication data to a file.

        Parameters:
        authFile - path of the file to save the authentication data to
      • addFile

         void addFile(String authFile)

        Add authentication data from a file.

        Parameters:
        authFile - path to the file to read the authentication data from
      • remove

         void remove(int index)

        Remove an authentication record.

        Parameters:
        index - index of the authentication record to remove
      • getClearEachIteration

         boolean getClearEachIteration()
        Returns:

        true if kerberos auth must be cleared on each mail loop iteration

      • getAuthCount

         int getAuthCount()

        Return the number of records.

        Returns:

        the number of records

      • setupCredentials

         void setupCredentials(Authorization auth, URL url, HttpClientContext localContext, CredentialsProvider credentialsProvider, String localhost)

        Configure credentials and auth scheme on client if an authorization is

        Parameters:
        auth - information about the authorization to use
        url - the URL for which the authorization info should be used
        localContext - http client context which should be set up
        credentialsProvider - provider which should be set up
        localhost - name of the workstation to be used for NTCredentials