Record Class SecurityRequirement

java.lang.Object
java.lang.Record
org.a2aproject.sdk.spec.SecurityRequirement
Record Components:
schemes - map of security scheme names to lists of required scopes

public record SecurityRequirement(Map<String,List<String>> schemes) extends Record
Represents a security requirement in the A2A Protocol.

A SecurityRequirement defines which security schemes must be satisfied to access an agent or skill. It maps security scheme names to lists of required scopes. When multiple scheme entries are present in a single SecurityRequirement, ALL must be satisfied (AND relationship). When multiple SecurityRequirements are present in a list, any ONE may be satisfied (OR relationship).

This class corresponds to the SecurityRequirement type in the A2A Protocol specification, which contains a schemes field mapping scheme names to scope arrays.

Example usage:


 // Single OAuth2 requirement with specific scopes
 SecurityRequirement oauth2Req = SecurityRequirement.builder()
     .scheme("oauth2", List.of("read", "write"))
     .build();

 // API key requirement with no scopes
 SecurityRequirement apiKeyReq = SecurityRequirement.builder()
     .scheme("apiKey", List.of())
     .build();

 // Combined requirement: both OAuth2 AND API key required
 SecurityRequirement combinedReq = SecurityRequirement.builder()
     .scheme("oauth2", List.of("profile"))
     .scheme("apiKey", List.of())
     .build();
 
See Also:
  • Constructor Details

    • SecurityRequirement

      public SecurityRequirement(Map<String,List<String>> schemes)
      Creates a SecurityRequirement with the specified schemes map.
      Parameters:
      schemes - map of security scheme names to lists of required scopes
  • Method Details

    • builder

      public static SecurityRequirement.Builder builder()
      Creates a new Builder for constructing SecurityRequirement instances.
      Returns:
      a new builder instance
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • schemes

      public Map<String,List<String>> schemes()
      Returns the value of the schemes record component.
      Returns:
      the value of the schemes record component