Class AuthUtils
java.lang.Object
org.evomaster.client.java.controller.AuthUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic org.evomaster.client.java.controller.api.dto.auth.AuthenticationDtogetForAuthorizationHeader(String dtoName, String authorizationValue) DTO representing the use of authentication via the "Authorization" headerstatic org.evomaster.client.java.controller.api.dto.auth.AuthenticationDtogetForBasic(String dtoName, String userId, String password) DTO representing the use of authentication via HTTP Basic (RFC-7617)static org.evomaster.client.java.controller.api.dto.auth.AuthenticationDtogetForDefaultSpringFormLogin(String dtoName, String username, String password) DTO representing the use of authentication via a X-WWW-FORM-URLENCODED POST submission.static org.evomaster.client.java.controller.api.dto.auth.AuthenticationDtogetForDefaultSpringFormLogin(String dtoName, String username, String password, String endpoint) DTO representing the use of authentication via a X-WWW-FORM-URLENCODED POST submission.static org.evomaster.client.java.controller.api.dto.auth.AuthenticationDtogetForJsonToken(String dtoName, String postEndpoint, String payload, String extractFromField, String headerPrefix) static org.evomaster.client.java.controller.api.dto.auth.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 org.evomaster.client.java.controller.api.dto.auth.AuthenticationDtogetForJsonTokenBearer(String dtoName, String postEndpoint, String payload, String extractFromField) static org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto
-
Constructor Details
-
AuthUtils
public AuthUtils()
-
-
Method Details
-
encode64
-
getForBasic
public static org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto getForBasic(String dtoName, String userId, String password) 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 org.evomaster.client.java.controller.api.dto.auth.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 org.evomaster.client.java.controller.api.dto.auth.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 org.evomaster.client.java.controller.api.dto.auth.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
-
getForJsonTokenBearer
-
getForJsonToken
-
getForJsonToken
public static org.evomaster.client.java.controller.api.dto.auth.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
-