org.cert.cc.util
Class EncryptionUtils

java.lang.Object
  extended by org.cert.cc.util.EncryptionUtils

public final class EncryptionUtils
extends Object

EncryptionUtils is set of helper methods for dealing with encrypted data.

© 2009 Carnegie Mellon University

Author:
Steve Scholnick

Field Summary
static String PROVIDER
          The external security provider identifier
 
Method Summary
static void addProvider()
          Adds the provider to the Security
static byte[] convertBase64Encoded(Message message)
          Converts a Base64 encoded email body into binary data.
static byte[] convertBase64Encoded(String text)
          Converts a Base64 encoded text into binary data.
static String extractData(String s)
          Extracts data from the input String, s.
static PGPPrivateKey findPrivateKey(PGPSecretKeyRingCollection collection, long keyId, char[] password)
          Returns a PGPPrivateKey from a PGPSecretKeyRingCollection.
static Set<String> getUsers(PGPSecretKey secretKey)
          Returns all of the users for a PGPSecretKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROVIDER

public static final String PROVIDER
The external security provider identifier

See Also:
Constant Field Values
Method Detail

convertBase64Encoded

public static byte[] convertBase64Encoded(Message message)
                                   throws MessagingException
Converts a Base64 encoded email body into binary data. The text, after the first blank line, is considered. All blanks lines and any header before the first blank line are ignored.

Parameters:
message - Email Message
Returns:
Binary data
Throws:
MessagingException - If unable to convert the Message

convertBase64Encoded

public static byte[] convertBase64Encoded(String text)
                                   throws MessagingException
Converts a Base64 encoded text into binary data. The text, after the first blank line, is considered. All blanks lines and any header before the first blank line are ignored.

BouncyCastle's Base64 class does the actual decoding.

Parameters:
text - Base64 encoded textual data
Returns:
Binary data
Throws:
MessagingException - If unable to convert the text

extractData

public static String extractData(String s)
                          throws IOException
Extracts data from the input String, s. The data is extracted after the first blank line down to a line that starts with "-----END"

Parameters:
s - Input data
Returns:
Extracted data
Throws:
IOException - If unable to read from the String, unlikely.

findPrivateKey

public static PGPPrivateKey findPrivateKey(PGPSecretKeyRingCollection collection,
                                           long keyId,
                                           char[] password)
                                    throws PGPException,
                                           NoSuchProviderException
Returns a PGPPrivateKey from a PGPSecretKeyRingCollection. If the PGPPrivateKey cannot be found, null is returned.

Parameters:
collection - PGPSecretKeyRingCollection
keyId - Key Id
password - PGPPrivateKey's password
Returns:
PGPPrivateKey
Throws:
PGPException - If unable to retrieve the PGPPrivateKey
NoSuchProviderException - If unable to retrieve the PGPPrivateKey

getUsers

public static Set<String> getUsers(PGPSecretKey secretKey)
Returns all of the users for a PGPSecretKey

Parameters:
secretKey - PGPSecretKey
Returns:
Set of users

addProvider

public static void addProvider()
Adds the provider to the Security



Copyright © 2012 Carnegie Mellon University