private void storeKey ( SecretKey key ) { final String keyStoreFile = getMain ( ) . getFileSystemManager ( ) . getSystemLocation ( ) + File . separator + "izou.keystore" ; KeyStore keyStore = createKeyStore ( keyStoreFile , "4b[X:+H4CS&avY<)" ) ; try { KeyStore . SecretKeyEntry keyStoreEntry = new KeyStore . SecretKeyEntry ( key ) ; KeyStore . PasswordProtection keyPassword = new KeyStore . PasswordProtection ( "Ev45j>eP}QTR?K9_" . toCharArray ( ) ) ; keyStore . setEntry ( "izou_key" , keyStoreEntry , keyPassword ) ; keyStore . store ( new FileOutputStream ( keyStoreFile ) , "4b[X:+H4CS&avY<)" . toCharArray ( ) ) ; } catch ( NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e ) { logger . error ( "Unable to store key" , e ) ; } }
Stores the izou aes key in a keystore