|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tranche.security.SecurityUtil
public class SecurityUtil
A helper class for handling security related tasks. You can also find helper methods here for looking up default X.509 certificates and RSA keys.
| Field Summary | |
|---|---|
static int |
SIGNATURE_BUFFER_SIZE
Size of signature in bytes, used by buffer. |
| Constructor Summary | |
|---|---|
SecurityUtil()
|
|
| Method Summary | |
|---|---|
static boolean |
certificateNamesMatch(java.lang.String a,
java.lang.String b)
A utility method to check whether two certificate names match. |
static java.security.cert.Certificate |
createCertificate(java.lang.String name,
java.security.PublicKey pub,
java.security.PrivateKey priv)
Helper method that uses the bouncycastle.org's X509 certificate generator to make a certificate for the given public/private key pair. |
static java.io.File |
decryptDiskBacked(java.lang.String passphrase,
java.io.File file)
Decrypt an AES-encrypted file using a specified passphrase. |
static java.io.File |
decryptDiskBacked(java.lang.String passphrase,
java.io.File file,
BigHash expectedHash)
Decrypt an AES-encrypted file using a specified passphrase. |
static byte[] |
decryptInMemory(java.lang.String passphrase,
byte[] dataBytes)
In-memory version of decryption function. |
static byte[] |
decryptInMemory(java.lang.String passphrase,
byte[] dataBytes,
BigHash expectedHash)
In-memory version of decryption function. |
static char |
encodeByte(byte b)
Encodes a byte as a character. |
static java.lang.String |
encodeBytes(byte[] bytes)
Helper method to make MD5 hashes digestable and file-name friendly. |
static java.io.File |
encryptDiskBacked(java.lang.String passphrase,
java.io.File file)
Encrypts a file using AES and a passphrase. |
static byte[] |
encryptInMemory(java.lang.String passphrase,
byte[] dataBytes)
In-memory version of encryption function. |
static java.lang.String |
generateBase64Password()
Generate a random base64 password 20 characters long. |
static java.lang.String |
generateBase64Password(int size)
Generate a random base64 password of specified size. |
static User |
getAdmin()
Get User object representing adminstrative privileges. |
static java.security.cert.X509Certificate |
getAdminCertificate()
Returns certificate with priveldges: all |
static User |
getAnonymous()
Get User object representing anonymous, read-only privileges. |
static java.security.cert.X509Certificate |
getAnonymousCertificate()
Returns certificate with priveldges: read only |
static int |
getAnonymousFlags()
Returns integer for flags used to set for user: anonymous. |
static java.security.PrivateKey |
getAnonymousKey()
Returns key with priveldges: read only |
static User |
getAutoCert()
Get User object representing auto-certificate privileges (read, write). |
static java.security.cert.X509Certificate |
getAutoCertCertificate()
Returns certificate with priveldges: read, write (no delete, no write configuration) |
static int |
getAutoCertFlags()
Returns integer for flags used to set for user: auto-cert. |
static java.security.cert.X509Certificate |
getCertificate(byte[] bytes)
Returns X509Certificate object serialized into bytes. |
static java.security.cert.X509Certificate |
getCertificate(java.io.File file)
Helper method to load an X509 certificate from a file. |
static java.security.cert.X509Certificate |
getCertificate(java.io.InputStream in)
Helper method to load an X509 certificate from an input stream. |
static java.security.cert.X509Certificate |
getDefaultCertificate()
Retrieve the default X.509 certificate used by tool. |
static java.security.PrivateKey |
getDefaultKey()
Retrieve the default private key used by the tool. |
static java.security.cert.X509Certificate |
getEmailCertificate()
Returns certificate used for signing email to be sent from server. |
static java.security.PrivateKey |
getEmailKey()
Returns key used for signing email to be sent from server. |
static java.lang.String |
getMD5Name(java.security.cert.X509Certificate cert)
Helper method to convert certificate's into unique names. |
static java.security.PrivateKey |
getPrivateKey(byte[] keyBytes)
Load the PrivateKey serialized to a byte array. |
static java.security.PrivateKey |
getPrivateKey(java.io.File file)
Load the PrivateKey serialized to a file. |
static java.security.PrivateKey |
getPrivateKeyFromKeyStore(java.io.InputStream keystore,
java.lang.String keystorePassword,
java.lang.String alias,
java.lang.String aliasPassword)
Retrieve the PrivateKey (used to sign bytes) from the system keystore. |
static java.security.PrivateKey |
getPrivateKeyFromKeyStore(java.lang.String keystore,
java.lang.String keystorePassword,
java.lang.String alias,
java.lang.String aliasPassword)
Retrieve the PrivateKey (used to sign bytes) from the system keystore. |
static User |
getReadOnly()
Get User object representing read-only privileges. |
static java.security.cert.X509Certificate |
getReadOnlyCertificate()
Returns certificate with priveldges: read only |
static int |
getReadOnlyFlags()
Returns integer for flags used to set for user: read-only. |
static java.lang.String |
getSignatureAlgorithm(java.security.PrivateKey key)
Extract the signature algorithm used with specified PrivateKey. |
static java.lang.String |
getSignatureAlgorithm(java.security.PublicKey key)
Extract the signature algorithm used with specified PublicKey. |
static User |
getUser()
Get User object representing user privileges (read, write, delete). |
static java.security.cert.X509Certificate |
getUserCertificate()
Returns certificate with priveldges: read, write, delete (not set configuration) |
static int |
getUserFlags()
Returns integer for flags used to set for user: (super) user. |
static User |
getWriteOnly()
Get User object representing write-only privileges. |
static java.security.cert.X509Certificate |
getWriteOnlyCertificate()
Returns certificate with priveldges: write |
static int |
getWriteOnlyFlags()
Returns integer for flags used to set for user: write-only. |
static byte[] |
hash(byte[] bytes,
java.lang.String algorithm)
Create a hash using a particular hashing algorithm. |
static byte[] |
hash(java.io.File f,
java.lang.String algorithm)
Create a hash using a particular hashing algorithm. |
static byte[] |
hash(java.io.File f,
java.lang.String algorithm,
byte[] buf)
Create a hash using a particular hashing algorithm. |
static byte[] |
hash(java.io.InputStream is,
java.lang.String algorithm)
Create a hash using a particular hashing algorithm. |
static byte[] |
hash(java.io.InputStream is,
java.lang.String algorithm,
byte[] buf)
Create a hash using a particular hashing algorithm. |
static boolean |
isCertificateSignedByDefaultCerts(java.security.cert.X509Certificate cert)
Checks to see whether certificate is signed by the loaded certificates. |
static void |
lazyLoad()
Lazy load resources used by utility methods. |
static void |
setAdminCert(java.security.cert.X509Certificate cert)
Set the administrator X.509 certificate. |
static void |
setAdminCertLocation(java.lang.String adminCertificateLocation)
Set the file path to the administrator X.509 certificate. |
static void |
setAnonCert(java.security.cert.X509Certificate cert)
Set the anonymous, read-only X.509 certificate. |
static void |
setAnonCertLocation(java.lang.String anonCertificateLocation)
Set the file path to the anonymous, read-only X.509 certificate. |
static void |
setAnonKey(java.security.PrivateKey key)
Set the anonymous, read-only private key. |
static void |
setAnonKeyLocation(java.lang.String anonPrivateKeyLocation)
Set the file path to the anonymous, read-only private key. |
static void |
setAutoCertCert(java.security.cert.X509Certificate cert)
Set the auto-certificate (read, write) X.509 certificate. |
static void |
setAutocertCertLocation(java.lang.String autocertCertificateLocation)
Set the file path to the read-only X.509 certificate. |
static void |
setDefaultCertificate(java.security.cert.X509Certificate aDefaultCertificate)
Set the default X.509 certificate used by the tool. |
static void |
setDefaultKey(java.security.PrivateKey aDefaultKey)
Set the default private key used by the tool. |
static void |
setEmailCert(java.security.cert.X509Certificate cert)
Set the X.509 certificate used to sign email data to be sent by server. |
static void |
setEmailCertLocation(java.lang.String emailCertificateLocation)
Set the file path to the certificate used for signing email to be sent by server. |
static void |
setEmailKey(java.security.PrivateKey key)
Set the private key used to sign email data to be sent by server. |
static void |
setEmailKeyLocation(java.lang.String emailPrivateKeyLocation)
Set the file path to the private key used for signing email to be sent by server. |
static void |
setReadCert(java.security.cert.X509Certificate cert)
Set the read-only X.509 certificate. |
static void |
setReadCertLocation(java.lang.String readCertificateLocation)
Set the file path to the read-only X.509 certificate. |
static void |
setUserCert(java.security.cert.X509Certificate cert)
Set the user (read, write, delete) X.509 certificate. |
static void |
setUserCertLocation(java.lang.String userCertificateLocation)
Set the file path to the user (read, write, delete) X.509 certificate. |
static void |
setWriteCert(java.security.cert.X509Certificate cert)
Set the write-only X.509 certificate. |
static void |
setWriteCertLocation(java.lang.String writeCertificateLocation)
Set the file path to the write-only X.509 certificate. |
static java.lang.String |
SHA1(java.lang.String text)
|
static byte[] |
sign(java.io.File f,
java.security.PrivateKey key)
Sign a file using a private key. |
static byte[] |
sign(java.io.File f,
java.security.PrivateKey key,
byte[] buf)
Sign a file using a private key. |
static byte[] |
sign(java.io.File f,
java.security.PrivateKey key,
java.lang.String algorithm)
Sign a file using a private key and a specified algorithm. |
static byte[] |
sign(java.io.File f,
java.security.PrivateKey key,
java.lang.String algorithm,
byte[] buffer)
Sign a file using a private key and a specified algorithm. |
static byte[] |
sign(java.io.InputStream is,
java.security.PrivateKey key)
Sign data from an InputStream using a private key. |
static byte[] |
sign(java.io.InputStream is,
java.security.PrivateKey key,
java.lang.String algorithm)
Sign data from an InputStream using a private key and a specific algorithm. |
static byte[] |
sign(java.io.InputStream is,
java.security.PrivateKey key,
java.lang.String algorithm,
byte[] buf)
Sign data from an InputStream using a private key and a specific algorithm. |
static boolean |
verify(java.io.InputStream is,
byte[] digitalSignature,
java.lang.String algorithm,
java.security.cert.Certificate cert)
Verify that the contents of an InputStream's bytes were signed by a certificate using a particular algorithm. |
static boolean |
verify(java.io.InputStream is,
byte[] digitalSignature,
java.lang.String algorithm,
java.security.PublicKey publicKey)
Verify that the contents of an InputStream's bytes were signed by a public key using a particular algorithm. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int SIGNATURE_BUFFER_SIZE
Size of signature in bytes, used by buffer.
| Constructor Detail |
|---|
public SecurityUtil()
| Method Detail |
|---|
public static byte[] hash(java.io.File f,
java.lang.String algorithm,
byte[] buf)
throws java.io.IOException,
java.security.GeneralSecurityException
Create a hash using a particular hashing algorithm.
f - algorithm - buf -
java.io.IOException
java.security.GeneralSecurityException
public static byte[] hash(java.io.File f,
java.lang.String algorithm)
throws java.io.IOException,
java.security.GeneralSecurityException
Create a hash using a particular hashing algorithm.
f - algorithm -
java.io.IOException
java.security.GeneralSecurityExceptionpublic static java.lang.String encodeBytes(byte[] bytes)
Helper method to make MD5 hashes digestable and file-name friendly. This encoding represents every 4 bits as 0-f.
bytes -
public static char encodeByte(byte b)
Encodes a byte as a character. Only encodes byte if 0-15, inclusive. Throws a RuntimeException if not in aforementioned range.
b -
public static java.lang.String generateBase64Password(int size)
Generate a random base64 password of specified size.
size -
public static java.lang.String generateBase64Password()
Generate a random base64 password 20 characters long.
public static java.security.cert.Certificate createCertificate(java.lang.String name,
java.security.PublicKey pub,
java.security.PrivateKey priv)
throws java.security.GeneralSecurityException
Helper method that uses the bouncycastle.org's X509 certificate generator to make a certificate for the given public/private key pair.
name - pub - priv -
java.security.GeneralSecurityException
public static byte[] sign(java.io.File f,
java.security.PrivateKey key)
throws java.io.IOException,
java.security.GeneralSecurityException
Sign a file using a private key. Uses key's signature algorithm to sign.
f - key -
java.io.IOException
java.security.GeneralSecurityException
public static byte[] sign(java.io.File f,
java.security.PrivateKey key,
byte[] buf)
throws java.io.IOException,
java.security.GeneralSecurityException
Sign a file using a private key. Uses key's signature algorithm to sign.
f - key - buf -
java.io.IOException
java.security.GeneralSecurityException
public static byte[] sign(java.io.File f,
java.security.PrivateKey key,
java.lang.String algorithm)
throws java.io.IOException,
java.security.GeneralSecurityException
Sign a file using a private key and a specified algorithm.
f - key - algorithm -
java.io.IOException
java.security.GeneralSecurityException
public static byte[] sign(java.io.File f,
java.security.PrivateKey key,
java.lang.String algorithm,
byte[] buffer)
throws java.io.IOException,
java.security.GeneralSecurityException
Sign a file using a private key and a specified algorithm.
f - key - algorithm - buffer -
java.io.IOException
java.security.GeneralSecurityException
public static byte[] sign(java.io.InputStream is,
java.security.PrivateKey key)
throws java.io.IOException,
java.security.GeneralSecurityException
Sign data from an InputStream using a private key. Uses key's signature algorithm.
is - key -
java.io.IOException
java.security.GeneralSecurityException
public static byte[] sign(java.io.InputStream is,
java.security.PrivateKey key,
java.lang.String algorithm)
throws java.io.IOException,
java.security.GeneralSecurityException
Sign data from an InputStream using a private key and a specific algorithm.
is - key - algorithm -
java.io.IOException
java.security.GeneralSecurityException
public static final byte[] sign(java.io.InputStream is,
java.security.PrivateKey key,
java.lang.String algorithm,
byte[] buf)
throws java.io.IOException,
java.security.GeneralSecurityException
Sign data from an InputStream using a private key and a specific algorithm.
After profiling this was hot-spot that dominated the AddFileTool's time. The only speed improvement to make is allowing a reusable buffer of bytes.
is - key - algorithm - buf -
java.io.IOException
java.security.GeneralSecurityException
public static byte[] hash(byte[] bytes,
java.lang.String algorithm)
throws java.io.IOException,
java.security.GeneralSecurityException
Create a hash using a particular hashing algorithm.
bytes - algorithm -
java.io.IOException
java.security.GeneralSecurityException
public static java.lang.String SHA1(java.lang.String text)
throws java.security.NoSuchAlgorithmException,
java.io.UnsupportedEncodingException
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException
public static byte[] hash(java.io.InputStream is,
java.lang.String algorithm)
throws java.io.IOException,
java.security.GeneralSecurityException
Create a hash using a particular hashing algorithm.
is - algorithm -
java.io.IOException
java.security.GeneralSecurityExceptionpublic static void lazyLoad()
Lazy load resources used by utility methods.
public static byte[] hash(java.io.InputStream is,
java.lang.String algorithm,
byte[] buf)
throws java.io.IOException,
java.security.GeneralSecurityException
Create a hash using a particular hashing algorithm.
is - algorithm - buf -
java.io.IOException
java.security.GeneralSecurityException
public static java.security.PrivateKey getPrivateKeyFromKeyStore(java.lang.String keystore,
java.lang.String keystorePassword,
java.lang.String alias,
java.lang.String aliasPassword)
throws java.io.IOException,
java.security.GeneralSecurityException
Retrieve the PrivateKey (used to sign bytes) from the system keystore.
keystore - keystorePassword - alias - aliasPassword -
java.io.IOException
java.security.GeneralSecurityException
public static java.security.PrivateKey getPrivateKeyFromKeyStore(java.io.InputStream keystore,
java.lang.String keystorePassword,
java.lang.String alias,
java.lang.String aliasPassword)
throws java.io.IOException,
java.security.GeneralSecurityException
Retrieve the PrivateKey (used to sign bytes) from the system keystore.
keystore - keystorePassword - alias - aliasPassword -
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.cert.X509Certificate getAnonymousCertificate()
throws java.io.IOException,
java.security.GeneralSecurityException
Returns certificate with priveldges: read only
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.PrivateKey getAnonymousKey()
throws java.io.IOException,
java.security.GeneralSecurityException
Returns key with priveldges: read only
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.cert.X509Certificate getEmailCertificate()
throws java.io.IOException,
java.security.GeneralSecurityException
Returns certificate used for signing email to be sent from server.
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.PrivateKey getEmailKey()
throws java.io.IOException,
java.security.GeneralSecurityException
Returns key used for signing email to be sent from server.
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.cert.X509Certificate getAdminCertificate()
throws java.io.IOException,
java.security.GeneralSecurityException
Returns certificate with priveldges: all
Must have matching key to sign bytes.
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.cert.X509Certificate getUserCertificate()
throws java.io.IOException,
java.security.GeneralSecurityException
Returns certificate with priveldges: read, write, delete (not set configuration)
Must have matching key to sign bytes.
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.cert.X509Certificate getReadOnlyCertificate()
throws java.io.IOException,
java.security.GeneralSecurityException
Returns certificate with priveldges: read only
Must have matching key to sign bytes.
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.cert.X509Certificate getWriteOnlyCertificate()
throws java.io.IOException,
java.security.GeneralSecurityException
Returns certificate with priveldges: write
Must have matching key to sign bytes.
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.cert.X509Certificate getAutoCertCertificate()
throws java.io.IOException,
java.security.GeneralSecurityException
Returns certificate with priveldges: read, write (no delete, no write configuration)
Must have matching key to sign bytes.
java.io.IOException
java.security.GeneralSecurityException
public static final User getAdmin()
throws java.io.IOException,
java.security.GeneralSecurityException
Get User object representing adminstrative privileges. (Cannot sign without private key.)
java.io.IOException
java.security.GeneralSecurityException
public static final User getUser()
throws java.io.IOException,
java.security.GeneralSecurityException
Get User object representing user privileges (read, write, delete). (Cannot sign without private key.)
java.io.IOException
java.security.GeneralSecurityExceptionpublic static final int getUserFlags()
Returns integer for flags used to set for user: (super) user.
public static final User getReadOnly()
throws java.io.IOException,
java.security.GeneralSecurityException
Get User object representing read-only privileges. (Cannot sign without private key.)
java.io.IOException
java.security.GeneralSecurityExceptionpublic static final int getReadOnlyFlags()
Returns integer for flags used to set for user: read-only.
public static final User getAnonymous()
throws java.io.IOException,
java.security.GeneralSecurityException
Get User object representing anonymous, read-only privileges. (Cannot sign without private key.)
java.io.IOException
java.security.GeneralSecurityExceptionpublic static final int getAnonymousFlags()
Returns integer for flags used to set for user: anonymous.
public static final User getWriteOnly()
throws java.io.IOException,
java.security.GeneralSecurityException
Get User object representing write-only privileges. (Cannot sign without private key.)
java.io.IOException
java.security.GeneralSecurityExceptionpublic static final int getWriteOnlyFlags()
Returns integer for flags used to set for user: write-only.
public static final User getAutoCert()
throws java.io.IOException,
java.security.GeneralSecurityException
Get User object representing auto-certificate privileges (read, write). (Cannot sign without private key.)
java.io.IOException
java.security.GeneralSecurityExceptionpublic static final int getAutoCertFlags()
Returns integer for flags used to set for user: auto-cert.
public static final java.security.cert.X509Certificate getCertificate(byte[] bytes)
throws java.io.IOException,
java.security.GeneralSecurityException
Returns X509Certificate object serialized into bytes.
bytes -
java.io.IOException
java.security.GeneralSecurityException
public static final java.security.cert.X509Certificate getCertificate(java.io.InputStream in)
throws java.io.IOException,
java.security.GeneralSecurityException
Helper method to load an X509 certificate from an input stream.
in -
java.io.IOException
java.security.GeneralSecurityException
public static java.security.cert.X509Certificate getCertificate(java.io.File file)
throws java.io.IOException,
java.security.GeneralSecurityException
Helper method to load an X509 certificate from a file.
file -
java.io.IOException
java.security.GeneralSecurityException
public static boolean verify(java.io.InputStream is,
byte[] digitalSignature,
java.lang.String algorithm,
java.security.cert.Certificate cert)
throws java.io.IOException,
java.security.GeneralSecurityException
Verify that the contents of an InputStream's bytes were signed by a certificate using a particular algorithm.
is - digitalSignature - algorithm - cert -
java.io.IOException
java.security.GeneralSecurityException
public static boolean verify(java.io.InputStream is,
byte[] digitalSignature,
java.lang.String algorithm,
java.security.PublicKey publicKey)
throws java.io.IOException,
java.security.GeneralSecurityException
Verify that the contents of an InputStream's bytes were signed by a public key using a particular algorithm.
is - digitalSignature - algorithm - publicKey -
java.io.IOException
java.security.GeneralSecurityExceptionpublic static java.lang.String getMD5Name(java.security.cert.X509Certificate cert)
Helper method to convert certificate's into unique names.
cert -
public static java.lang.String getSignatureAlgorithm(java.security.PublicKey key)
Extract the signature algorithm used with specified PublicKey.
key -
public static java.lang.String getSignatureAlgorithm(java.security.PrivateKey key)
Extract the signature algorithm used with specified PrivateKey.
key -
public static java.security.PrivateKey getPrivateKey(java.io.File file)
throws java.io.IOException,
java.security.GeneralSecurityException
Load the PrivateKey serialized to a file.
file -
java.io.IOException
java.security.GeneralSecurityException
public static java.security.PrivateKey getPrivateKey(byte[] keyBytes)
throws java.io.IOException,
java.security.GeneralSecurityException
Load the PrivateKey serialized to a byte array.
keyBytes -
java.io.IOException
java.security.GeneralSecurityExceptionpublic static java.security.cert.X509Certificate getDefaultCertificate()
Retrieve the default X.509 certificate used by tool. Unless configured otherwise, this is the anonymous certificate.
public static void setDefaultCertificate(java.security.cert.X509Certificate aDefaultCertificate)
Set the default X.509 certificate used by the tool. If not specified, uses the anonymous certificate.
aDefaultCertificate - public static java.security.PrivateKey getDefaultKey()
Retrieve the default private key used by the tool. If not specified, uses the anonymous key.
public static void setDefaultKey(java.security.PrivateKey aDefaultKey)
Set the default private key used by the tool. If not specified, uses the anonymous key.
aDefaultKey -
public static java.io.File encryptDiskBacked(java.lang.String passphrase,
java.io.File file)
throws java.io.IOException
Encrypts a file using AES and a passphrase.
passphrase - file -
java.io.IOException
public static byte[] encryptInMemory(java.lang.String passphrase,
byte[] dataBytes)
throws java.io.IOException
In-memory version of encryption function. This method avoids all uses of temporary files, which can save some time when handling lots of small files.
passphrase - dataBytes -
java.io.IOException
public static java.io.File decryptDiskBacked(java.lang.String passphrase,
java.io.File file)
throws WrongPassphraseException,
java.io.IOException,
java.security.GeneralSecurityException
Decrypt an AES-encrypted file using a specified passphrase.
passphrase - file -
WrongPassphraseException
java.io.IOException
java.security.GeneralSecurityException
public static java.io.File decryptDiskBacked(java.lang.String passphrase,
java.io.File file,
BigHash expectedHash)
throws WrongPassphraseException,
java.io.IOException,
java.security.GeneralSecurityException
Decrypt an AES-encrypted file using a specified passphrase.
passphrase - file - expectedHash -
WrongPassphraseException
java.io.IOException
java.security.GeneralSecurityException
public static byte[] decryptInMemory(java.lang.String passphrase,
byte[] dataBytes)
throws WrongPassphraseException,
java.io.IOException,
java.security.GeneralSecurityException
In-memory version of decryption function. This method avoids all uses of temporary files, which can save some time when handling lots of small files.
passphrase - dataBytes -
WrongPassphraseException
java.io.IOException
java.security.GeneralSecurityException
public static byte[] decryptInMemory(java.lang.String passphrase,
byte[] dataBytes,
BigHash expectedHash)
throws WrongPassphraseException,
java.io.IOException,
java.security.GeneralSecurityException
In-memory version of decryption function. This method avoids all uses of temporary files, which can save some time when handling lots of small files.
passphrase - dataBytes - expectedHash -
WrongPassphraseException
java.io.IOException
java.security.GeneralSecurityException
public static boolean isCertificateSignedByDefaultCerts(java.security.cert.X509Certificate cert)
throws java.lang.Exception
Checks to see whether certificate is signed by the loaded certificates.
Primary use case is to help decide on client's side whether to perform certain network-specific actions. The content will still be validated server-side.
cert - The certificate to check
java.lang.Exception
public static boolean certificateNamesMatch(java.lang.String a,
java.lang.String b)
A utility method to check whether two certificate names match.
Not sufficient for security, but a fast way to check whether found a matching cert name before more expensive security checks.
a - b -
public static void setAdminCert(java.security.cert.X509Certificate cert)
Set the administrator X.509 certificate.
cert - public static void setAdminCertLocation(java.lang.String adminCertificateLocation)
Set the file path to the administrator X.509 certificate.
adminCertificateLocation - public static void setUserCert(java.security.cert.X509Certificate cert)
Set the user (read, write, delete) X.509 certificate.
cert - public static void setUserCertLocation(java.lang.String userCertificateLocation)
Set the file path to the user (read, write, delete) X.509 certificate.
userCertificateLocation - public static void setWriteCert(java.security.cert.X509Certificate cert)
Set the write-only X.509 certificate.
cert - public static void setWriteCertLocation(java.lang.String writeCertificateLocation)
Set the file path to the write-only X.509 certificate.
writeCertificateLocation - public static void setReadCert(java.security.cert.X509Certificate cert)
Set the read-only X.509 certificate.
cert - public static void setReadCertLocation(java.lang.String readCertificateLocation)
Set the file path to the read-only X.509 certificate.
readCertificateLocation - public static void setAutoCertCert(java.security.cert.X509Certificate cert)
Set the auto-certificate (read, write) X.509 certificate.
cert - public static void setAutocertCertLocation(java.lang.String autocertCertificateLocation)
Set the file path to the read-only X.509 certificate.
autocertCertificateLocation - public static void setAnonCert(java.security.cert.X509Certificate cert)
Set the anonymous, read-only X.509 certificate.
cert - public static void setAnonKey(java.security.PrivateKey key)
Set the anonymous, read-only private key.
key - public static void setAnonCertLocation(java.lang.String anonCertificateLocation)
Set the file path to the anonymous, read-only X.509 certificate.
anonCertificateLocation - public static void setAnonKeyLocation(java.lang.String anonPrivateKeyLocation)
Set the file path to the anonymous, read-only private key.
anonPrivateKeyLocation - public static void setEmailCert(java.security.cert.X509Certificate cert)
Set the X.509 certificate used to sign email data to be sent by server.
cert - public static void setEmailKey(java.security.PrivateKey key)
Set the private key used to sign email data to be sent by server.
key - public static void setEmailCertLocation(java.lang.String emailCertificateLocation)
Set the file path to the certificate used for signing email to be sent by server.
emailCertificateLocation - public static void setEmailKeyLocation(java.lang.String emailPrivateKeyLocation)
Set the file path to the private key used for signing email to be sent by server.
emailPrivateKeyLocation -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||