Class AuthUtils

java.lang.Object
org.evomaster.client.java.controller.AuthUtils

public class AuthUtils extends Object
  • Constructor Details

    • AuthUtils

      public AuthUtils()
  • Method Details

    • encode64

      public static String encode64(String value)
    • 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 debugging
      userId - the id of a user
      password - 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 debugging
      authorizationValue - 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 debugging
      username - the id of a user
      password - 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 debugging
      username - the id of a user
      password - password for that user
      endpoint - the url of the endpoint to use for the login
      Returns:
      a DTO
    • getForJWT

      public static org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto getForJWT(String dtoName, String postEndpoint, String payload, String extractFromField)
    • getForJsonTokenBearer

      public static org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto getForJsonTokenBearer(String dtoName, String postEndpoint, String payload, String extractFromField)
    • getForJsonToken

      public static org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto getForJsonToken(String dtoName, String postEndpoint, String payload, String extractFromField, String headerPrefix)
    • 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 AuthenticationDto
      postEndpoint - The endpoint URL or path (see description above for interpretation)
      payload - The request payload to send to the login endpoint
      extractFromField - The field in the response that contains the token
      headerPrefix - 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