Exemple #1
0
  @Override
  public void init(Config config, Logger logger) {
    super.init(config, logger);

    timeout = config.getInt(CONN_TIMEOUT_KEY, CONN_TIMEOUT_DEFAULT);

    parms.put(CONN_TIMEOUT_KEY, timeout);

    endpoint = config.get(ENDPOINT_KEY, ENDPOINT_DEFAULT);
    accessKey = config.get(AUTH_USERNAME_KEY, AUTH_USERNAME_DEFAULT);
    secretKey = config.get(AUTH_PASSWORD_KEY, AUTH_PASSWORD_DEFAULT);

    boolean pathStyleAccess = config.getBoolean(PATH_STYLE_ACCESS_KEY, PATH_STYLE_ACCESS_DEFAULT);

    String proxyHost = config.get(PROXY_HOST_KEY, "");
    String proxyPort = config.get(PROXY_PORT_KEY, "");

    parms.put(ENDPOINT_KEY, endpoint);
    parms.put(AUTH_USERNAME_KEY, accessKey);
    parms.put(AUTH_PASSWORD_KEY, secretKey);
    parms.put(PATH_STYLE_ACCESS_KEY, pathStyleAccess);
    parms.put(PROXY_HOST_KEY, proxyHost);
    parms.put(PROXY_PORT_KEY, proxyPort);

    logger.debug("using storage config: {}", parms);

    ClientConfiguration clientConf = new ClientConfiguration();
    clientConf.setConnectionTimeout(timeout);
    clientConf.setSocketTimeout(timeout);
    clientConf.withUseExpectContinue(false);
    clientConf.withSignerOverride("S3SignerType");
    //        clientConf.setProtocol(Protocol.HTTP);
    if ((!proxyHost.equals("")) && (!proxyPort.equals(""))) {
      clientConf.setProxyHost(proxyHost);
      clientConf.setProxyPort(Integer.parseInt(proxyPort));
    }

    AWSCredentials myCredentials = new BasicAWSCredentials(accessKey, secretKey);
    client = new AmazonS3Client(myCredentials, clientConf);
    client.setEndpoint(endpoint);
    client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(pathStyleAccess));

    logger.debug("S3 client has been initialized");
  }
Exemple #2
0
  @Override
  public void init(Config config, Logger logger) {
    super.init(config, logger);

    url = config.get(AUTH_URL_KEY, config.get(AUTH_URL_KEY_BACK, URL_DEFAULT));

    username = config.get(AUTH_USERNAME_KEY, AUTH_USERNAME_DEFAULT);
    password = config.get(AUTH_PASSWORD_KEY, AUTH_PASSWORD_DEFAULT);
    timeout = config.getInt(CONN_TIMEOUT_KEY, CONN_TIMEOUT_DEFAULT);

    parms.put(AUTH_URL_KEY, url);
    parms.put(AUTH_USERNAME_KEY, username);
    parms.put(AUTH_PASSWORD_KEY, password);
    parms.put(CONN_TIMEOUT_KEY, timeout);

    logger.debug("using auth config: {}", parms);

    HttpClient httpClient = HttpClientUtil.createHttpClient(timeout);
    client = new SwiftAuthClient(httpClient, url, username, password);
    logger.debug("swauth client has been initialized");
  }
 private static NameIterator getObjNmIter(Config config) {
   String pattern = config.get("objects");
   String prefix = config.get("oprefix", OBJECT_PREFIX);
   String suffix = config.get("osuffix", OBJECT_SUFFIX);
   return Iterators.getNameIterator(pattern, prefix, suffix);
 }
 private static NameIterator getConNmIter(Config config) {
   String pattern = config.get("containers");
   String prefix = config.get("cprefix", CONTAINER_PREFIX);
   String suffix = config.get("csuffix", CONTAINER_SUFFIX);
   return Iterators.getNameIterator(pattern, prefix, suffix);
 }