/**
   * Loads TSL certificates If configuration mode is TEST then TSL signature is not checked.
   *
   * @return TSL source
   */
  public TSLCertificateSource getTSL() {
    logger.debug("");
    if (tslCertificateSource != null) {
      logger.debug("Using TSL cached copy");
      return tslCertificateSource;
    }

    tslCertificateSource = new TSLCertificateSource();
    tslCertificateSource.setTslRefreshPolicy(TSLRefreshPolicy.WHEN_NECESSARY);

    String tslLocation = getTslLocation();
    if (Protocol.isHttpUrl(tslLocation)) {
      FileCacheDataLoader dataLoader = new FileCacheDataLoader();
      dataLoader.setConnectTimeout(getConnectionTimeout());
      dataLoader.setFileCacheDirectory(TSLCertificateSource.fileCacheDirectory);
      tslCertificateSource.setTslRefreshPolicy(TSLRefreshPolicy.NEVER);
      tslCertificateSource.setDataLoader(dataLoader);
    } else {
      tslCertificateSource.setDataLoader(new CommonsDataLoader());
    }

    tslCertificateSource.setLotlUrl(tslLocation);

    tslCertificateSource.setCheckSignature(false);

    try {
      tslCertificateSource.init();
    } catch (DSSException e) {
      logger.error(e.getMessage());
      throw new DigiDoc4JException(e.getMessage());
    }

    return tslCertificateSource;
  }
Esempio n. 2
0
  @Override
  public byte[] get(final String urlString) throws DSSCannotFetchDataException {

    if (Protocol.isFileUrl(urlString)) {
      return fileGet(urlString);
    } else if (Protocol.isHttpUrl(urlString)) {
      return httpGet(urlString);
    } else if (Protocol.isFtpUrl(urlString)) {
      return ftpGet(urlString);
    } else if (Protocol.isLdapUrl(urlString)) {
      return ldapGet(urlString);
    } else {
      LOG.warn("DSS framework only supports HTTP, HTTPS, FTP and LDAP CRL's urlString.");
    }

    return httpGet(urlString);
  }