Skip to content

KeyStoreHandler

Victor Bieszka edited this page Mar 18, 2019 · 1 revision

Class KeyStoreHandler

public class KeyStoreHandler
extends java.lang.Object

Field Summary

 
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 Summary

 
Constructor and Description
KeyStoreHandler() 

Method Summary

   
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

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait

Constructor Detail

KeyStoreHandler

public KeyStoreHandler()

Method Detail

  • getPlibPrivateKey

    public static java.security.PrivateKey getPlibPrivateKey(android.content.Context context)
  • getPlibPublicKey

    public static java.security.PublicKey getPlibPublicKey(android.content.Context context)
    Returns the plib public key
    Parameters:
    context -
    Returns:
  • getPlibCertificate

    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:
  • getPlibKeyStore

    public static java.security.KeyStore getPlibKeyStore(android.content.Context context)
    Requests the plib keystore
    Parameters:
    context -
    Returns:
  • renewPlibCertificate

    public static boolean renewPlibCertificate(android.content.Context context)
    Let create a new Plib certificate and a corresponding private key.
    Parameters:
    context -
  • setCertificateEntry

    public static boolean setCertificateEntry(android.content.Context context,
                                              java.lang.String alias,
                                              java.security.cert.Certificate certificate)
    REST
  • test

    public static void test(android.content.Context context)
                     throws java.lang.Exception
    Throws:
    java.lang.Exception
  • getSecureSocket

    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
  • getSecureSocket

    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
  • getSecureSocketServer

    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