Class VAPIDKeys


  • public class VAPIDKeys
    extends java.lang.Object
    Helper class to generate VAPID keys for use with Push notification.
    Author:
    Christopher Mindus
    • Constructor Summary

      Constructors 
      ConstructorDescription
      VAPIDKeys() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static java.lang.String[]generateKeys()
      Generates a public key and a private key.
      static java.lang.StringvalidatePrivateKey​(java.lang.String privateKey)
      Validates the private key Base64 encoded string.
      static java.lang.StringvalidatePublicKey​(java.lang.String publicKey)
      Validates the public key Base64 encoded string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • VAPIDKeys

        public VAPIDKeys()
    • Method Detail

      • generateKeys

        public static java.lang.String[] generateKeys()
                                               throws java.lang.IllegalStateException
        Generates a public key and a private key.
        Returns:
        Array of 2 String's: first the public key, then the private key.
        Throws:
        java.lang.IllegalStateException - NOTE: try-catch on it! In case of BouncyCastle errors.
      • validatePublicKey

        public static java.lang.String validatePublicKey​(java.lang.String publicKey)
        Validates the public key Base64 encoded string.
        Parameters:
        publicKey - The public key to validate.
        Returns:
        A validation message, or null for success.
      • validatePrivateKey

        public static java.lang.String validatePrivateKey​(java.lang.String privateKey)
        Validates the private key Base64 encoded string.
        Parameters:
        privateKey - The private key to validate.
        Returns:
        A validation message, or null for success.