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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
AuthManager.Mechanism
-
Field Summary
Fields Modifier and Type Field Description public final static int
COL_URL
public final static int
COL_USERNAME
public final static int
COL_PASSWORD
public final static int
COL_DOMAIN
public final static int
COL_REALM
public final static int
COL_MECHANISM
public final static boolean
STRIP_PORT
public final static boolean
USE_CANONICAL_HOST_NAME
public final static String
USERNAME
public final static String
PASSWORD
public transient JMeterContext
threadContext
public transient String
threadName
public final static TestElement.Companion
Companion
public final static String
NAME
public final static String
GUI_CLASS
public final static String
ENABLED
public final static String
TEST_CLASS
public final static String
COMMENTS
-
Constructor Summary
Constructors Constructor Description AuthManager()
Default Constructor.
-
Method Summary
Modifier and Type Method Description void
clear()
void
set(int index, String url, String user, String pass, String domain, String realm, AuthManager.Mechanism mechanism)
Update an authentication record. CollectionProperty
getAuthObjects()
int
getColumnCount()
String
getColumnName(int column)
Class<out Object>
getColumnClass(int column)
Authorization
getAuthObjectAt(int row)
boolean
isEditable()
Authorization
get(int i)
Return the record at index i String
getAuthHeaderForURL(URL url)
Authorization
getAuthForURL(URL url)
boolean
hasAuthForURL(URL url)
Tests whether an authorization record is available for a given URL Subject
getSubjectForUrl(URL url)
Get a Subject for a given URL, if available void
addConfigElement(ConfigElement config)
void
addAuth(Authorization newAuthorization)
Add newAuthorization if it does not already exist void
addAuth()
boolean
expectsModification()
void
save(String authFile)
Save the authentication data to a file. void
addFile(String authFile)
Add authentication data from a file. void
remove(int index)
Remove an authentication record. boolean
getClearEachIteration()
void
setClearEachIteration(boolean clear)
int
getAuthCount()
Return the number of records. static void
setupCredentials(Authorization auth, URL url, HttpClientContext localContext, CredentialsProvider credentialsProvider, String localhost)
Configure credentials and auth scheme on client if an authorization is void
testStarted()
void
testEnded()
void
testStarted(String host)
void
testEnded(String host)
void
testIterationStart(LoopIterationEvent event)
boolean
getControlledByThread()
void
setControlledByThread(boolean control)
-
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
canRemove, clearTestElementChildren, clone, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse
-
Methods inherited from class org.apache.jmeter.config.ConfigTestElement
addTestElement, getProps, getSchema
-
Methods inherited from class org.apache.jmeter.testelement.TestElement
get, get, get, get, get, get, get, get, get, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getProps, getSchema, getString, removed, set
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
clear
void clear()
-
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 seturl
- url for which the authentication record should be useduser
- name of the userpass
- password of the userdomain
- domain of the userrealm
- realm of the sitemechanism
- authentication Mechanism to use
-
getAuthObjects
CollectionProperty getAuthObjects()
-
getColumnCount
int getColumnCount()
-
getColumnName
String getColumnName(int column)
-
getColumnClass
Class<out Object> getColumnClass(int column)
-
getAuthObjectAt
Authorization getAuthObjectAt(int row)
-
isEditable
boolean isEditable()
-
get
Authorization get(int i)
Return the record at index i
- Parameters:
i
- index of the record to get
-
getAuthHeaderForURL
String getAuthHeaderForURL(URL url)
-
getAuthForURL
Authorization getAuthForURL(URL url)
-
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
-
getSubjectForUrl
Subject getSubjectForUrl(URL url)
Get a Subject for a given URL, if available
- Parameters:
url
- URL for which the subject was asked
-
addConfigElement
void addConfigElement(ConfigElement config)
-
addAuth
void addAuth(Authorization newAuthorization)
Add newAuthorization if it does not already exist
- Parameters:
newAuthorization
- authorization to be added
-
addAuth
void addAuth()
-
expectsModification
boolean expectsModification()
-
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()
-
setClearEachIteration
void setClearEachIteration(boolean clear)
-
getAuthCount
int getAuthCount()
Return the number of records.
-
setupCredentials
static 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 useurl
- the URL for which the authorization info should be usedlocalContext
- http client context which should be set upcredentialsProvider
- provider which should be set uplocalhost
- name of the workstation to be used for NTCredentials
-
testStarted
void testStarted()
-
testEnded
void testEnded()
-
testStarted
void testStarted(String host)
-
testIterationStart
void testIterationStart(LoopIterationEvent event)
-
getControlledByThread
boolean getControlledByThread()
-
setControlledByThread
void setControlledByThread(boolean control)
-
-
-
-