Package org.jpos.util

Class PGPHelper


  • public class PGPHelper
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      PGPHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int checkLicense()  
      static boolean checkSignature()  
      static byte[] decrypt​(byte[] encrypted, java.io.InputStream keyIn, char[] password)
      decrypt the passed in message stream
      static byte[] decrypt​(byte[] encrypted, java.lang.String keyIn, char[] password)
      decrypt the passed in message stream
      static byte[] encrypt​(byte[] clearData, java.io.InputStream keyRing, java.lang.String fileName, boolean withIntegrityCheck, boolean armor, java.lang.String... ids)
      Simple PGP encryptor between byte[].
      static byte[] encrypt​(byte[] clearData, java.lang.String keyRing, java.lang.String fileName, boolean withIntegrityCheck, boolean armor, java.lang.String... ids)
      Simple PGP encryptor between byte[].
      static java.lang.String getLicensee()  
      static java.lang.String getLicenseeHash()  
      • Methods inherited from class java.lang.Object

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

      • getLicensee

        public static java.lang.String getLicensee()
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • getLicenseeHash

        public static java.lang.String getLicenseeHash()
                                                throws java.io.IOException,
                                                       java.security.NoSuchAlgorithmException
        Throws:
        java.io.IOException
        java.security.NoSuchAlgorithmException
      • encrypt

        public static byte[] encrypt​(byte[] clearData,
                                     java.io.InputStream keyRing,
                                     java.lang.String fileName,
                                     boolean withIntegrityCheck,
                                     boolean armor,
                                     java.lang.String... ids)
                              throws java.io.IOException,
                                     org.bouncycastle.openpgp.PGPException,
                                     java.security.NoSuchProviderException,
                                     java.security.NoSuchAlgorithmException
        Simple PGP encryptor between byte[].
        Parameters:
        clearData - The test to be encrypted
        keyRing - public key ring input stream
        fileName - File name. This is used in the Literal Data Packet (tag 11) which is really only important if the data is to be related to a file to be recovered later. Because this routine does not know the source of the information, the caller can set something here for file name use that will be carried. If this routine is being used to encrypt SOAP MIME bodies, for example, use the file name from the MIME type, if applicable. Or anything else appropriate.
        withIntegrityCheck - true if an integrity packet is to be included
        armor - true for ascii armor
        ids - destination ids
        Returns:
        encrypted data.
        Throws:
        java.io.IOException
        org.bouncycastle.openpgp.PGPException
        java.security.NoSuchProviderException
        java.security.NoSuchAlgorithmException
      • encrypt

        public static byte[] encrypt​(byte[] clearData,
                                     java.lang.String keyRing,
                                     java.lang.String fileName,
                                     boolean withIntegrityCheck,
                                     boolean armor,
                                     java.lang.String... ids)
                              throws java.io.IOException,
                                     org.bouncycastle.openpgp.PGPException,
                                     java.security.NoSuchProviderException,
                                     java.security.NoSuchAlgorithmException
        Simple PGP encryptor between byte[].
        Parameters:
        clearData - The test to be encrypted
        keyRing - public key ring input stream
        fileName - File name. This is used in the Literal Data Packet (tag 11) which is really only important if the data is to be related to a file to be recovered later. Because this routine does not know the source of the information, the caller can set something here for file name use that will be carried. If this routine is being used to encrypt SOAP MIME bodies, for example, use the file name from the MIME type, if applicable. Or anything else appropriate.
        withIntegrityCheck - true if an integrity packet is to be included
        armor - true for ascii armor
        ids - destination ids
        Returns:
        encrypted data.
        Throws:
        java.io.IOException
        org.bouncycastle.openpgp.PGPException
        java.security.NoSuchProviderException
        java.security.NoSuchAlgorithmException
      • decrypt

        public static byte[] decrypt​(byte[] encrypted,
                                     java.io.InputStream keyIn,
                                     char[] password)
                              throws java.io.IOException,
                                     org.bouncycastle.openpgp.PGPException,
                                     java.security.NoSuchProviderException
        decrypt the passed in message stream
        Parameters:
        encrypted - The message to be decrypted.
        password - Pass phrase (key)
        Returns:
        Clear text as a byte array. I18N considerations are not handled by this routine
        Throws:
        java.io.IOException
        org.bouncycastle.openpgp.PGPException
        java.security.NoSuchProviderException
      • decrypt

        public static byte[] decrypt​(byte[] encrypted,
                                     java.lang.String keyIn,
                                     char[] password)
                              throws java.io.IOException,
                                     org.bouncycastle.openpgp.PGPException,
                                     java.security.NoSuchProviderException
        decrypt the passed in message stream
        Parameters:
        encrypted - The message to be decrypted.
        password - Pass phrase (key)
        Returns:
        Clear text as a byte array. I18N considerations are not handled by this routine
        Throws:
        java.io.IOException
        org.bouncycastle.openpgp.PGPException
        java.security.NoSuchProviderException