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 Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class org.exoplatform.web.security.security.CookieTokenService

    EMAIL_VALIDATION_TOKEN, EXTERNAL_REGISTRATION_TOKEN, FORGOT_PASSWORD_TOKEN, HASH_SERVICE_INIT_PARAM, LIFECYCLE_NAME, ONBOARD_TOKEN, SEPARATOR_CHAR

    Fields inherited from class org.exoplatform.web.security.security.AbstractTokenService

    CLEANUP_PERIOD_TIME, DEFAULT_TOKEN_BYTE_LENGTH, delayTime, log, name, SERVICE_CONFIG, tokenByteLength, validityMillis
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    PwaNotificationTokenService(io.meeds.web.security.storage.PortalTokenStorage tokenStore)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    buildTokenType(long notificationId, String subscriptionId)
     
    consumeToken(String token, long notificationId, String subscriptionId)
     
    createToken(String username, long notificationId, String subscriptionId)
     
    void
    deleteNotificationToken(String token, long notificationId, String subscriptionId)
     
    void
     
    validateToken(String token, long notificationId, String subscriptionId)
     
    validateToken(String token, long notificationId, String subscriptionId, boolean remove)
     

    Methods inherited from class org.exoplatform.web.security.security.CookieTokenService

    cleanExpiredTokens, createToken, createToken, decodeKey, deleteAll, deleteToken, deleteToken, deleteTokensByUsernameAndType, deleteTokensOfUser, getToken, getToken, nextTokenId, size

    Methods inherited from class org.exoplatform.web.security.security.AbstractTokenService

    getInstance, getName, getPeriodTime, getValidityTime, nextRandom, start, stop, validateToken

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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)
    • validateToken

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

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

      public String validateToken(String token, long notificationId, 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)