public static KeyStoreHandler create(final File keyStoreFile,final char[] password) throws IOException, KeyStoreException {
  if (keyStoreFile == null) {
    throw new FileNotFoundException(null);
  }
 else   if (keyStoreFile.exists()) {
    throw new FileAlreadyExistsException(keyStoreFile.getAbsolutePath());
  }
  final KeyStore ks=KeyStore.getInstance(KeyStoreHandler.KEYSTORE_TYPE);
  try {
    ks.load(null,password);
  }
 catch (  final NoSuchAlgorithmException|CertificateException ex) {
    throw new IllegalStateException("Should not happen.",ex);
  }
  final SecretKeyFactory skf=KeyStoreHandler.getSecretKeyFactory();
  final KeyStoreHandler ksh=new KeyStoreHandler(ks,password,keyStoreFile,skf,true);
  ksh.save();
  return ksh;
}

public static KeyStoreHandler create ( final File keyStoreFile , final char [ ] password ) throws IOException , KeyStoreException { if ( keyStoreFile == null ) { throw new FileNotFoundException ( null ) ; } else if ( keyStoreFile . exists ( ) ) { throw new FileAlreadyExistsException ( keyStoreFile . getAbsolutePath ( ) ) ; } final KeyStore ks = KeyStore . getInstance ( KeyStoreHandler . KEYSTORE_TYPE ) ; try { ks . load ( null , password ) ; } catch ( final NoSuchAlgorithmException | CertificateException ex ) { throw new IllegalStateException ( "Should not happen." , ex ) ; } final SecretKeyFactory skf = KeyStoreHandler . getSecretKeyFactory ( ) ; final KeyStoreHandler ksh = new KeyStoreHandler ( ks , password , keyStoreFile , skf , true ) ; ksh . save ( ) ; return ksh ; }
create brand new key store protected by a given password , and store it in a file .
