Implementation:A2aproject A2a java PushNotification SPI
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Server, Push_Notifications, SPI, Security |
| Last Updated | 2026-10-30 00:00 GMT |
Overview
Concrete push notification SPI interfaces and in-memory default implementation for webhook config storage, notification delivery, and SSRF URL validation.
Description
The push notification subsystem provides:
- PushNotificationConfigStore: SPI for storing and retrieving per-task push notification configurations (webhook URLs, tokens). Supports pagination and per-task authorization.
- InMemoryPushNotificationConfigStore: Default in-memory implementation using ConcurrentHashMap. Lost on restart.
- PushNotificationSender: SPI for sending push notifications — implemented by BasePushNotificationSender.
- PushNotificationUrlValidator: SPI for validating webhook URLs to prevent SSRF attacks.
- DefaultPushNotificationUrlValidator: Default SSRF validator — blocks private/internal IP ranges, loopback, link-local, and non-HTTP(S) schemes.
Usage
- Default push notifications: InMemoryPushNotificationConfigStore and BasePushNotificationSender are auto-registered CDI beans
- Database persistence: Implement PushNotificationConfigStore for JPA storage (see `extras/push-notification-config-store-database-jpa`)
- Custom SSRF rules: Implement PushNotificationUrlValidator for custom URL validation rules
- Custom delivery: Implement PushNotificationSender for non-HTTP delivery (email, Slack, etc.)
Code Reference
Source Location
- Repository: a2a-java
- Files:
- `server-common/src/main/java/org/a2aproject/sdk/server/tasks/PushNotificationConfigStore.java` (L1-213)
- `server-common/src/main/java/org/a2aproject/sdk/server/tasks/InMemoryPushNotificationConfigStore.java` (L1-157)
- `server-common/src/main/java/org/a2aproject/sdk/server/tasks/PushNotificationSender.java` (L1-137)
- `server-common/src/main/java/org/a2aproject/sdk/server/tasks/PushNotificationUrlValidator.java` (L1-32)
- `server-common/src/main/java/org/a2aproject/sdk/server/tasks/DefaultPushNotificationUrlValidator.java` (L1-226)
Signature
public interface PushNotificationConfigStore {
TaskPushNotificationConfig setPushNotificationConfig(
TaskPushNotificationConfig config, @Nullable ServerCallContext context);
@Nullable TaskPushNotificationConfig getPushNotificationConfig(
GetTaskPushNotificationConfigParams params, ServerCallContext context);
ListTaskPushNotificationConfigsResult listPushNotificationConfigs(
ListTaskPushNotificationConfigsParams params, ServerCallContext context);
void deletePushNotificationConfig(
DeleteTaskPushNotificationConfigParams params, ServerCallContext context);
}
public interface PushNotificationSender {
void sendPushNotifications(String taskId, StreamingEventKind event);
void sendPushNotifications(String taskId, Event event);
}
public interface PushNotificationUrlValidator {
void validateUrl(String url);
}
// Default SSRF validator
public class DefaultPushNotificationUrlValidator implements PushNotificationUrlValidator {
// Blocks: private IPs, loopback, link-local, non-HTTP(S) schemes,
// hosts that resolve to private addresses
}
Import
import org.a2aproject.sdk.server.tasks.PushNotificationConfigStore;
import org.a2aproject.sdk.server.tasks.PushNotificationSender;
import org.a2aproject.sdk.server.tasks.PushNotificationUrlValidator;
import org.a2aproject.sdk.server.tasks.DefaultPushNotificationUrlValidator;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | TaskPushNotificationConfig | Yes (set) | Webhook config with URL and token |
| taskId | String | Yes (send) | Task to send notifications for |
| event | StreamingEventKind | Yes (send) | Event to deliver |
| url | String | Yes (validate) | Webhook URL to validate |
Outputs
| Name | Type | Description |
|---|---|---|
| setPushNotificationConfig returns | TaskPushNotificationConfig | Stored config |
| listPushNotificationConfigs returns | ListTaskPushNotificationConfigsResult | Paginated configs |
Usage Examples
Custom SSRF Validator
import org.a2aproject.sdk.server.tasks.PushNotificationUrlValidator;
public class CustomUrlValidator implements PushNotificationUrlValidator {
@Override
public void validateUrl(String url) {
// Add custom allowlist of internal services
if (url.startsWith("https://internal.mycompany.com/")) {
return; // Allow specific internal service
}
// Delegate to default for standard SSRF checks
new DefaultPushNotificationUrlValidator().validateUrl(url);
}
}
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment