-
Notifications
You must be signed in to change notification settings - Fork 3
KeyStoreHandler
Victor Bieszka edited this page Mar 18, 2019
·
1 revision
public class KeyStoreHandler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KEYSTORE_PLIB_ALIAS |
static java.lang.String |
KEYSTORE_PLIB_KEY_PWD |
static java.lang.String |
KEYSTORE_PWD |
static java.lang.String |
KEYSTORE_SUB_PATH |
Constructor and Description |
---|
KeyStoreHandler() |
Modifier and Type | Method and Description |
---|---|
static java.security.cert.Certificate |
getPlibCertificate(android.content.Context context)
Returns the self-signed plib certificate containing the rsa public key
|
static java.security.KeyStore |
getPlibKeyStore(android.content.Context context)
Requests the plib keystore
|
static java.security.PrivateKey |
getPlibPrivateKey(android.content.Context context) |
static java.security.PublicKey |
getPlibPublicKey(android.content.Context context)
Returns the plib public key
|
static javax.net.ssl.SSLSocket |
getSecureSocket(android.content.Context context,boolean withOsTrustedCertificates)
Creates a secure tls socket in consideration of p-lib own certificate and trusted
certificates
|
static javax.net.ssl.SSLSocket |
getSecureSocket(android.content.Context context,java.lang.String adr,int port,boolean withOsTrustedCertificates)
Creates a secure tls socket and connects to a given adress and port in consideration of p-lib
own certificate and trusted certificates
|
static javax.net.ssl.SSLServerSocket |
getSecureSocketServer(android.content.Context context,int port,boolean withClientAuthentication,boolean withOsTrustedCertificates)
Creates a secure TLS socket binded to given port in consideration of p-lib own certificate
and trusted certificates
|
static boolean |
renewPlibCertificate(android.content.Context context)
Let create a new Plib certificate and a corresponding private key.
|
static boolean |
setCertificateEntry(android.content.Context context,java.lang.String alias,java.security.cert.Certificate certificate)
REST
|
equals, getClass, hashCode, notify, notifyAll, toString, wait
public KeyStoreHandler()
-
public static java.security.PrivateKey getPlibPrivateKey(android.content.Context context)
-
public static java.security.PublicKey getPlibPublicKey(android.content.Context context)
Returns the plib public key- Parameters:
-
context
- - Returns:
-
public static java.security.cert.Certificate getPlibCertificate(android.content.Context context)
Returns the self-signed plib certificate containing the rsa public key- Parameters:
-
context
- - Returns:
-
public static java.security.KeyStore getPlibKeyStore(android.content.Context context)
Requests the plib keystore- Parameters:
-
context
- - Returns:
-
public static boolean renewPlibCertificate(android.content.Context context)
Let create a new Plib certificate and a corresponding private key.- Parameters:
-
context
-
-
public static boolean setCertificateEntry(android.content.Context context, java.lang.String alias, java.security.cert.Certificate certificate)
REST
-
public static void test(android.content.Context context) throws java.lang.Exception
- Throws:
java.lang.Exception
-
public static javax.net.ssl.SSLSocket getSecureSocket(android.content.Context context, java.lang.String adr, int port, boolean withOsTrustedCertificates) throws java.security.UnrecoverableKeyException, java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.KeyManagementException, java.io.IOException
Creates a secure tls socket and connects to a given adress and port in consideration of p-lib own certificate and trusted certificates- Parameters:
-
context
- -
adr
- -
port
- -
withOsTrustedCertificates
- regard os based regarded trusted certificates also as trusted - Returns:
- Throws:
java.security.UnrecoverableKeyException
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.KeyManagementException
java.io.IOException
-
public static javax.net.ssl.SSLSocket getSecureSocket(android.content.Context context, boolean withOsTrustedCertificates) throws java.security.UnrecoverableKeyException, java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.KeyManagementException, java.io.IOException
Creates a secure tls socket in consideration of p-lib own certificate and trusted certificates- Parameters:
-
context
- -
withOsTrustedCertificates
- regard os based regarded trusted certificates also as trusted - Returns:
- Throws:
java.security.UnrecoverableKeyException
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.KeyManagementException
java.io.IOException
-
public static javax.net.ssl.SSLServerSocket getSecureSocketServer(android.content.Context context, int port, boolean withClientAuthentication, boolean withOsTrustedCertificates) throws java.security.UnrecoverableKeyException, java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.KeyManagementException, java.io.IOException
Creates a secure TLS socket binded to given port in consideration of p-lib own certificate and trusted certificates- Parameters:
-
context
- -
port
- -
withClientAuthentication
- if true, connected clients should also be authentcated with existing certificates. -
withOsTrustedCertificates
- regard os based regarded trusted certificates also as trusted - Returns:
- Throws:
java.security.UnrecoverableKeyException
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.KeyManagementException
java.io.IOException