Package org.a2aproject.sdk.spec
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
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();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructing immutableSecurityRequirementinstances. -
Constructor Summary
ConstructorsConstructorDescriptionSecurityRequirement(Map<String, List<String>> schemes) Creates a SecurityRequirement with the specified schemes map. -
Method Summary
Modifier and TypeMethodDescriptionstatic SecurityRequirement.Builderbuilder()Creates a new Builder for constructing SecurityRequirement instances.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.schemes()Returns the value of theschemesrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SecurityRequirement
Creates a SecurityRequirement with the specified schemes map.- Parameters:
schemes- map of security scheme names to lists of required scopes
-
-
Method Details
-
builder
Creates a new Builder for constructing SecurityRequirement instances.- Returns:
- a new builder instance
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
schemes
Returns the value of theschemesrecord component.- Returns:
- the value of the
schemesrecord component
-