public class ValidatingPushNotificationHandlerFactory extends Object implements PushNotificationHandlerFactory
A push notification handler factory that constructs handlers that, to the extent possible, perform the same checks and validation steps as a real APNs server.
Because handlers constructed by this factory try to emulate the behavior of real APNs servers, callers will need to provide collections of legal device tokens and token expiration times. If clients connect TLS-based authentication, handlers will derive a list of allowed topics from the client's certificate. If using token-based authentication, callers will need to specify a collection of public keys and topics to which those keys apply.
MockApnsServerBuilder.setHandlerFactory(PushNotificationHandlerFactory)
Constructor and Description |
---|
ValidatingPushNotificationHandlerFactory(Map<String,Set<String>> deviceTokensByTopic,
Map<String,Date> expirationTimestampsByDeviceToken,
Map<String,ApnsVerificationKey> verificationKeysByKeyId,
Map<ApnsVerificationKey,Set<String>> topicsByVerificationKey)
Constructs a new factory for push notification handlers that emulate the behavior of a real APNs server.
|
Modifier and Type | Method and Description |
---|---|
PushNotificationHandler |
buildHandler(SSLSession sslSession)
Constructs a new push notification handler that will process notifications from a single connection to a mock
server.
|
public ValidatingPushNotificationHandlerFactory(Map<String,Set<String>> deviceTokensByTopic, Map<String,Date> expirationTimestampsByDeviceToken, Map<String,ApnsVerificationKey> verificationKeysByKeyId, Map<ApnsVerificationKey,Set<String>> topicsByVerificationKey)
deviceTokensByTopic
- a map of topics to the set of device tokens that may send push notifications to that
topic; may be null
, in which case constructed handlers will reject all notificationsexpirationTimestampsByDeviceToken
- a map of device tokens to the time at which they expire; tokens not in
the map (or all tokens if the map is null
or empty) will never be considered "expired"verificationKeysByKeyId
- a map of key identifiers to the keys with that identifier; only required for token
authentication, and may be null
, in which case all notifications sent with token authentication will be
rejectedtopicsByVerificationKey
- a map of verification keys to the set of topics for which they may verify
authentication tokens; only needed for token authentication, and may be null
in which case all
notifications sent with token authentication will be rejectedpublic PushNotificationHandler buildHandler(SSLSession sslSession)
PushNotificationHandlerFactory
buildHandler
in interface PushNotificationHandlerFactory
sslSession
- the SSL session for the new connection to the mock serverCopyright © 2013–2018 Turo. All rights reserved.