public PromptingTrustManager(final ConsoleApplication app,final String acceptedStorePath,final X509TrustManager sourceTrustManager) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
  Reject.ifNull(app,acceptedStorePath);
  this.app=app;
  this.nestedTrustManager=sourceTrustManager;
  inMemoryTrustStore=KeyStore.getInstance(KeyStore.getDefaultType());
  onDiskTrustStore=KeyStore.getInstance(KeyStore.getDefaultType());
  final File onDiskTrustStorePath=new File(acceptedStorePath);
  inMemoryTrustStore.load(null,null);
  if (!onDiskTrustStorePath.exists()) {
    onDiskTrustStore.load(null,null);
  }
 else {
    try (final FileInputStream fos=new FileInputStream(onDiskTrustStorePath)){
      onDiskTrustStore.load(fos,DEFAULT_PASSWORD);
    }
   }
  final TrustManagerFactory tmf=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
  tmf.init(inMemoryTrustStore);
  X509TrustManager x509tm=null;
  for (  final TrustManager tm : tmf.getTrustManagers()) {
    if (tm instanceof X509TrustManager) {
      x509tm=(X509TrustManager)tm;
      break;
    }
  }
  if (x509tm == null) {
    throw new NoSuchAlgorithmException();
  }
  this.inMemoryTrustManager=x509tm;
  tmf.init(onDiskTrustStore);
  x509tm=null;
  for (  final TrustManager tm : tmf.getTrustManagers()) {
    if (tm instanceof X509TrustManager) {
      x509tm=(X509TrustManager)tm;
      break;
    }
  }
  if (x509tm == null) {
    throw new NoSuchAlgorithmException();
  }
  this.onDiskTrustManager=x509tm;
}

public PromptingTrustManager ( final ConsoleApplication app , final String acceptedStorePath , final X509TrustManager sourceTrustManager ) throws KeyStoreException , IOException , NoSuchAlgorithmException , CertificateException { Reject . ifNull ( app , acceptedStorePath ) ; this . app = app ; this . nestedTrustManager = sourceTrustManager ; inMemoryTrustStore = KeyStore . getInstance ( KeyStore . getDefaultType ( ) ) ; onDiskTrustStore = KeyStore . getInstance ( KeyStore . getDefaultType ( ) ) ; final File onDiskTrustStorePath = new File ( acceptedStorePath ) ; inMemoryTrustStore . load ( null , null ) ; if ( ! onDiskTrustStorePath . exists ( ) ) { onDiskTrustStore . load ( null , null ) ; } else { try ( final FileInputStream fos = new FileInputStream ( onDiskTrustStorePath ) ) { onDiskTrustStore . load ( fos , DEFAULT_PASSWORD ) ; } } final TrustManagerFactory tmf = TrustManagerFactory . getInstance ( TrustManagerFactory . getDefaultAlgorithm ( ) ) ; tmf . init ( inMemoryTrustStore ) ; X509TrustManager x509tm = null ; for ( final TrustManager tm : tmf . getTrustManagers ( ) ) { if ( tm instanceof X509TrustManager ) { x509tm = ( X509TrustManager ) tm ; break ; } } if ( x509tm == null ) { throw new NoSuchAlgorithmException ( ) ; } this . inMemoryTrustManager = x509tm ; tmf . init ( onDiskTrustStore ) ; x509tm = null ; for ( final TrustManager tm : tmf . getTrustManagers ( ) ) { if ( tm instanceof X509TrustManager ) { x509tm = ( X509TrustManager ) tm ; break ; } } if ( x509tm == null ) { throw new NoSuchAlgorithmException ( ) ; } this . onDiskTrustManager = x509tm ; }
creates a prompting trust manager based on these arguments .
