Class AuthUtils
java.lang.Object
org.evomaster.client.java.controller.AuthUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic AuthenticationDtogetForAuthorizationHeader(String dtoName, String authorizationValue) DTO representing the use of authentication via the "Authorization" headerstatic AuthenticationDtogetForBasic(String dtoName, String userId, String password) DTO representing the use of authentication via HTTP Basic (RFC-7617)static AuthenticationDtogetForDefaultSpringFormLogin(String dtoName, String username, String password) DTO representing the use of authentication via a X-WWW-FORM-URLENCODED POST submission.static AuthenticationDtogetForDefaultSpringFormLogin(String dtoName, String username, String password, String endpoint) DTO representing the use of authentication via a X-WWW-FORM-URLENCODED POST submission.static AuthenticationDtogetForJsonToken(String dtoName, String postEndpoint, String payload, String extractFromField, String headerPrefix) static AuthenticationDtogetForJsonToken(String dtoName, String postEndpoint, String payload, String extractFromField, String headerPrefix, String contentType) Creates an AuthenticationDto object configured to obtain a JSON token from a login endpoint.static AuthenticationDtogetForJsonTokenBearer(String dtoName, String postEndpoint, String payload, String extractFromField) static AuthenticationDto
-
Constructor Details
-
AuthUtils
public AuthUtils()
-
-
Method Details
-
encode64
-
getForBasic
DTO representing the use of authentication via HTTP Basic (RFC-7617)- Parameters:
dtoName- a name used to identify this dto. Mainly needed for debugginguserId- the id of a userpassword- password for that user- Returns:
- a DTO
-
getForAuthorizationHeader
public static AuthenticationDto getForAuthorizationHeader(String dtoName, String authorizationValue) DTO representing the use of authentication via the "Authorization" header- Parameters:
dtoName- a name used to identify this dto. Mainly needed for debuggingauthorizationValue- the content of the "Authorization" header- Returns:
- a DTO
-
getForDefaultSpringFormLogin
public static AuthenticationDto getForDefaultSpringFormLogin(String dtoName, String username, String password) DTO representing the use of authentication via a X-WWW-FORM-URLENCODED POST submission. Assuming default names and endpoint used in SpringSecurity for default formLogin() configuration. When using this kind of DTO, EM will first do a POST on such endpoint with valid credentials, and then use the resulting cookie for the following HTTP requests.- Parameters:
dtoName- a name used to identify this dto. Mainly needed for debuggingusername- the id of a userpassword- password for that user- Returns:
- a DTO
-
getForDefaultSpringFormLogin
public static AuthenticationDto getForDefaultSpringFormLogin(String dtoName, String username, String password, String endpoint) DTO representing the use of authentication via a X-WWW-FORM-URLENCODED POST submission. Assuming default names used in SpringSecurity for default formLogin() configuration. When using this kind of DTO, EM will first do a POST on such endpoint with valid credentials, and then use the resulting cookie for the following HTTP requests.- Parameters:
dtoName- a name used to identify this dto. Mainly needed for debuggingusername- the id of a userpassword- password for that userendpoint- the url of the endpoint to use for the login- Returns:
- a DTO
-
getForJWT
public static AuthenticationDto getForJWT(String dtoName, String postEndpoint, String payload, String extractFromField) -
getForJsonTokenBearer
public static AuthenticationDto getForJsonTokenBearer(String dtoName, String postEndpoint, String payload, String extractFromField) -
getForJsonToken
-
getForJsonToken
public static AuthenticationDto getForJsonToken(String dtoName, String postEndpoint, String payload, String extractFromField, String headerPrefix, String contentType) Creates an AuthenticationDto object configured to obtain a JSON token from a login endpoint. The postEndpoint parameter can be interpreted in two different ways:- If postEndpoint starts with "http://" or "https://", it is treated as a full external URL
- Otherwise, it is treated as a relative path that will be combined with a base URL
- Parameters:
dtoName- The name to assign to the AuthenticationDtopostEndpoint- The endpoint URL or path (see description above for interpretation)payload- The request payload to send to the login endpointextractFromField- The field in the response that contains the tokenheaderPrefix- The prefix to add to the token (e.g., "Bearer ")contentType- The content type to use for the request- Returns:
- Configured AuthenticationDto object with login endpoint settings
-