Package com.eatthepath.pushy.apns.server
Class ValidatingPushNotificationHandlerFactory
java.lang.Object
com.eatthepath.pushy.apns.server.ValidatingPushNotificationHandlerFactory
- All Implemented Interfaces:
PushNotificationHandlerFactory
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.
- Since:
- 0.12
- Author:
- Jon Chambers
- See Also:
-
Constructor Summary
ConstructorDescriptionValidatingPushNotificationHandlerFactory
(Map<String, Set<String>> deviceTokensByTopic, Map<String, Instant> 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. -
Method Summary
Modifier and TypeMethodDescriptionbuildHandler
(SSLSession sslSession) Constructs a new push notification handler that will process notifications from a single connection to a mock server.
-
Constructor Details
-
ValidatingPushNotificationHandlerFactory
public ValidatingPushNotificationHandlerFactory(Map<String, Set<String>> deviceTokensByTopic, Map<String, Instant> 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.- Parameters:
deviceTokensByTopic
- a map of topics to the set of device tokens that may send push notifications to that topic; may benull
, 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 isnull
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 benull
, 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 benull
in which case all notifications sent with token authentication will be rejected
-
-
Method Details
-
buildHandler
Description copied from interface:PushNotificationHandlerFactory
Constructs a new push notification handler that will process notifications from a single connection to a mock server.- Specified by:
buildHandler
in interfacePushNotificationHandlerFactory
- Parameters:
sslSession
- the SSL session for the new connection to the mock server- Returns:
- a new push notification handler for the new connection
-