Code example for KeyStore

Methods: setKeyEntry

0
    public static void setSecretKeyBytes(KeyStore ks, String alias) throws Exception {
        setSecretKeyBytes(ks, alias, getSecretKey());
    } 
    public static void setSecretKeyBytes(KeyStore ks, String alias, SecretKey key)
            throws Exception { 
        ks.setKeyEntry(alias,
                       key.getEncoded(),
                       null); 
    } 
 
    public static void setCertificate(KeyStore ks) throws Exception {
        setCertificate(ks, ALIAS_CERTIFICATE);
    } 
    public static void setCertificate(KeyStore ks, String alias) throws Exception {
        setCertificate(ks, alias, getPrivateKey().getCertificate());
    } 
    public static void setCertificate(KeyStore ks, String alias, Certificate certificate)
            throws Exception { 
        ks.setCertificateEntry(alias, certificate);
    }