public final String encodeKeyStore(KeyStore keyStore, char[] password) {
        logger.entry();
        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
            keyStore.store(out, password);
            out.flush();
            byte[] bytes = out.toByteArray();
            String encodedKeyStore = Base64Utils.encode(bytes);
            logger.exit();
            return encodedKeyStore;
        } catch (IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException e) {
            RuntimeException exception = new RuntimeException("An unexpected exception occurred while attempting to encode a keystore.", e);
            logger.error(exception.toString());
            throw exception;
        }
    }
public final String encodeKeyStore ( KeyStore keyStore , char [ ] password ) { logger . entry ( ) ; try ( ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ) { keyStore . store ( out , password ) ; out . flush ( ) ; byte [ ] bytes = out . toByteArray ( ) ; String encodedKeyStore = Base64Utils . encode ( bytes ) ; logger . exit ( ) ; return encodedKeyStore ; } catch ( IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occurred while attempting to encode a keystore." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } }
This method encodes a PKCS12 format key store into a base 64 string format.

@param keyStore The PKCS12 format key store to be encoded.
@param password The password to be used to encrypt the byte stream.
@return The base 64 encoded string.