Class PwaNotificationTokenService

java.lang.Object
org.exoplatform.web.security.security.AbstractTokenService<org.exoplatform.web.security.PortalToken,String>
org.exoplatform.web.security.security.CookieTokenService
io.meeds.pwa.service.PwaNotificationTokenService
All Implemented Interfaces:
org.exoplatform.web.security.TokenStore, org.picocontainer.Startable

@Service public class PwaNotificationTokenService extends org.exoplatform.web.security.security.CookieTokenService
Persistent token service used by service workers to retrieve a web notification after the web session cookie has expired. The generated token is persisted through PortalTokenStorage by the parent CookieTokenService; only the token selector and salted hash are stored. The token type binds the token to both the notification and the push subscription, so the same raw token cannot be used for another notification or another device subscription. The service also exposes consumeToken(...) for single-push delivery tokens: after the first successful push fetch, the token is deleted from the persistent store.
  • Field Details

  • Constructor Details

    • PwaNotificationTokenService

      public PwaNotificationTokenService(io.meeds.web.security.storage.PortalTokenStorage tokenStore)
    • PwaNotificationTokenService

      public PwaNotificationTokenService()
  • Method Details

    • createToken

      public String createToken(String username, long notificationId, String subscriptionId)
    • createToken

      public String createToken(String username, String objectId, String subscriptionId)
      Creates a token scoped to any push-notification object (a stored web notification id, or a direct notification's object key) and one device.
      Parameters:
      username - token owner
      objectId - the notification object the token grants access to
      subscriptionId - the device subscription the token is bound to
      Returns:
      the raw token to hand to that device
    • validateToken

      public String validateToken(String token, long notificationId, String subscriptionId)
    • validateToken

      public String validateToken(String token, String objectId, String subscriptionId)
    • consumeToken

      public String consumeToken(String token, long notificationId, String subscriptionId)
    • consumeToken

      public String consumeToken(String token, String objectId, String subscriptionId)
    • validateToken

      public String validateToken(String token, long notificationId, String subscriptionId, boolean remove)
    • validateToken

      public String validateToken(String token, String objectId, String subscriptionId, boolean remove)
    • deleteNotificationToken

      public void deleteNotificationToken(String token, long notificationId, String subscriptionId)
    • deleteNotificationTokens

      public void deleteNotificationTokens(String username)
    • buildTokenType

      protected String buildTokenType(long notificationId, String subscriptionId)
    • buildTokenType

      protected String buildTokenType(String objectId, String subscriptionId)