Java源码示例:io.swagger.client.auth.Authentication

示例1
public ApiClient() {
  // Use ISO 8601 format for date and datetime.
  // See https://en.wikipedia.org/wiki/ISO_8601
  this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

  // Use UTC as the default time zone.
  this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

  // Set default User-Agent.
  setUserAgent("Java-Swagger");

  // Setup authentications (key: authentication name, value: authentication).
  authentications = new HashMap<String, Authentication>();
  // Prevent the authentications from being modified.
  authentications = Collections.unmodifiableMap(authentications);
}
 
示例2
public ApiClient() {
  // Use ISO 8601 format for date and datetime.
  // See https://en.wikipedia.org/wiki/ISO_8601
  this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

  // Use UTC as the default time zone.
  this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

  // Set default User-Agent.
  setUserAgent("Java-Swagger");

  // Setup authentications (key: authentication name, value: authentication).
  authentications = new HashMap<String, Authentication>();
  // Prevent the authentications from being modified.
  authentications = Collections.unmodifiableMap(authentications);
}
 
示例3
public ApiClient() {
    httpClient = new OkHttpClient();

    verifyingSsl = true;

    json = new JSON(this);

    /*
     * Use RFC3339 format for date and datetime.
     * See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
     */
    this.dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    // Always use UTC as the default time zone when dealing with date (without time).
    this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    initDatetimeFormat();

    // Be lenient on datetime formats when parsing datetime from string.
    // See <code>parseDatetime</code>.
    this.lenientDatetimeFormat = true;

    // Set default User-Agent.
    setUserAgent("Swagger-Codegen/1.0.0/java");

    // Setup authentications (key: authentication name, value: authentication).
    authentications = new HashMap<String, Authentication>();
    // Prevent the authentications from being modified.
    authentications = Collections.unmodifiableMap(authentications);
}
 
示例4
/**
 * Helper method to set username for the first HTTP basic authentication.
 *
 * @param username Username
 */
public void setUsername(String username) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof HttpBasicAuth) {
            ((HttpBasicAuth) auth).setUsername(username);
            return;
        }
    }
    throw new RuntimeException("No HTTP basic authentication configured!");
}
 
示例5
/**
 * Helper method to set password for the first HTTP basic authentication.
 *
 * @param password Password
 */
public void setPassword(String password) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof HttpBasicAuth) {
            ((HttpBasicAuth) auth).setPassword(password);
            return;
        }
    }
    throw new RuntimeException("No HTTP basic authentication configured!");
}
 
示例6
/**
 * Helper method to set API key value for the first API key authentication.
 *
 * @param apiKey API key
 */
public void setApiKey(String apiKey) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof ApiKeyAuth) {
            ((ApiKeyAuth) auth).setApiKey(apiKey);
            return;
        }
    }
    throw new RuntimeException("No API key authentication configured!");
}
 
示例7
/**
 * Helper method to set API key prefix for the first API key authentication.
 *
 * @param apiKeyPrefix API key prefix
 */
public void setApiKeyPrefix(String apiKeyPrefix) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof ApiKeyAuth) {
            ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
            return;
        }
    }
    throw new RuntimeException("No API key authentication configured!");
}
 
示例8
/**
 * Helper method to set access token for the first OAuth2 authentication.
 *
 * @param accessToken Access token
 */
public void setAccessToken(String accessToken) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof OAuth) {
            ((OAuth) auth).setAccessToken(accessToken);
            return;
        }
    }
    throw new RuntimeException("No OAuth2 authentication configured!");
}
 
示例9
/**
 * Update query and header parameters based on authentication settings.
 *
 * @param authNames The authentications to apply
 * @param queryParams  List of query parameters
 * @param headerParams  Map of header parameters
 */
public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) {
    for (String authName : authNames) {
        Authentication auth = authentications.get(authName);
        if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
        auth.applyToParams(queryParams, headerParams);
    }
}
 
示例10
/**
 * Helper method to set username for the first HTTP basic authentication.
 */
public void setUsername(String username) {
  for (Authentication auth : authentications.values()) {
    if (auth instanceof HttpBasicAuth) {
      ((HttpBasicAuth) auth).setUsername(username);
      return;
    }
  }
  throw new RuntimeException("No HTTP basic authentication configured!");
}
 
示例11
/**
 * Helper method to set password for the first HTTP basic authentication.
 */
public void setPassword(String password) {
  for (Authentication auth : authentications.values()) {
    if (auth instanceof HttpBasicAuth) {
      ((HttpBasicAuth) auth).setPassword(password);
      return;
    }
  }
  throw new RuntimeException("No HTTP basic authentication configured!");
}
 
示例12
/**
 * Helper method to set API key value for the first API key authentication.
 */
public void setApiKey(String apiKey) {
  for (Authentication auth : authentications.values()) {
    if (auth instanceof ApiKeyAuth) {
      ((ApiKeyAuth) auth).setApiKey(apiKey);
      return;
    }
  }
  throw new RuntimeException("No API key authentication configured!");
}
 
示例13
/**
 * Helper method to set API key prefix for the first API key authentication.
 */
public void setApiKeyPrefix(String apiKeyPrefix) {
  for (Authentication auth : authentications.values()) {
    if (auth instanceof ApiKeyAuth) {
      ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
      return;
    }
  }
  throw new RuntimeException("No API key authentication configured!");
}
 
示例14
/**
 * Update query and header parameters based on authentication settings.
 *
 * @param authNames The authentications to apply
 */
private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) {
  for (String authName : authNames) {
    Authentication auth = authentications.get(authName);
    if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
    auth.applyToParams(queryParams, headerParams);
  }
}
 
示例15
/**
 * Helper method to set username for the first HTTP basic authentication.
 */
public void setUsername(String username) {
  for (Authentication auth : authentications.values()) {
    if (auth instanceof HttpBasicAuth) {
      ((HttpBasicAuth) auth).setUsername(username);
      return;
    }
  }
  throw new RuntimeException("No HTTP basic authentication configured!");
}
 
示例16
/**
 * Helper method to set password for the first HTTP basic authentication.
 */
public void setPassword(String password) {
  for (Authentication auth : authentications.values()) {
    if (auth instanceof HttpBasicAuth) {
      ((HttpBasicAuth) auth).setPassword(password);
      return;
    }
  }
  throw new RuntimeException("No HTTP basic authentication configured!");
}
 
示例17
/**
 * Helper method to set API key value for the first API key authentication.
 */
public void setApiKey(String apiKey) {
  for (Authentication auth : authentications.values()) {
    if (auth instanceof ApiKeyAuth) {
      ((ApiKeyAuth) auth).setApiKey(apiKey);
      return;
    }
  }
  throw new RuntimeException("No API key authentication configured!");
}
 
示例18
/**
 * Helper method to set API key prefix for the first API key authentication.
 */
public void setApiKeyPrefix(String apiKeyPrefix) {
  for (Authentication auth : authentications.values()) {
    if (auth instanceof ApiKeyAuth) {
      ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
      return;
    }
  }
  throw new RuntimeException("No API key authentication configured!");
}
 
示例19
/**
 * Update query and header parameters based on authentication settings.
 *
 * @param authNames The authentications to apply
 */
private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) {
  for (String authName : authNames) {
    Authentication auth = authentications.get(authName);
    if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
    auth.applyToParams(queryParams, headerParams);
  }
}
 
示例20
/**
 * Helper method to set username for the first HTTP basic authentication.
 *
 * @param username Username
 */
public void setUsername(String username) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof HttpBasicAuth) {
            ((HttpBasicAuth) auth).setUsername(username);
            return;
        }
    }
    throw new RuntimeException("No HTTP basic authentication configured!");
}
 
示例21
/**
 * Helper method to set password for the first HTTP basic authentication.
 *
 * @param password Password
 */
public void setPassword(String password) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof HttpBasicAuth) {
            ((HttpBasicAuth) auth).setPassword(password);
            return;
        }
    }
    throw new RuntimeException("No HTTP basic authentication configured!");
}
 
示例22
/**
 * Helper method to set API key value for the first API key authentication.
 *
 * @param apiKey API key
 */
public void setApiKey(String apiKey) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof ApiKeyAuth) {
            ((ApiKeyAuth) auth).setApiKey(apiKey);
            return;
        }
    }
    throw new RuntimeException("No API key authentication configured!");
}
 
示例23
/**
 * Helper method to set API key prefix for the first API key authentication.
 *
 * @param apiKeyPrefix API key prefix
 */
public void setApiKeyPrefix(String apiKeyPrefix) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof ApiKeyAuth) {
            ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
            return;
        }
    }
    throw new RuntimeException("No API key authentication configured!");
}
 
示例24
/**
 * Helper method to set access token for the first OAuth2 authentication.
 *
 * @param accessToken Access token
 */
public void setAccessToken(String accessToken) {
    for (Authentication auth : authentications.values()) {
        if (auth instanceof OAuth) {
            ((OAuth) auth).setAccessToken(accessToken);
            return;
        }
    }
    throw new RuntimeException("No OAuth2 authentication configured!");
}
 
示例25
/**
 * Update query and header parameters based on authentication settings.
 *
 * @param authNames The authentications to apply
 * @param queryParams  List of query parameters
 * @param headerParams  Map of header parameters
 */
public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) {
    for (String authName : authNames) {
        Authentication auth = authentications.get(authName);
        if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
        auth.applyToParams(queryParams, headerParams);
    }
}
 
示例26
/**
 * Get authentications (key: authentication name, value: authentication).
 */
public Map<String, Authentication> getAuthentications() {
  return authentications;
}
 
示例27
/**
 * Get authentications (key: authentication name, value: authentication).
 */
public Map<String, Authentication> getAuthentications() {
  return authentications;
}
 
示例28
public ApiClient() {
    httpClient = new OkHttpClient();


    verifyingSsl = true;

    json = new JSON();

    // Set default User-Agent.
    setUserAgent("Swagger-Codegen/1.0.0/java");

    // Setup authentications (key: authentication name, value: authentication).
    authentications = new HashMap<String, Authentication>();
    // Prevent the authentications from being modified.
    authentications = Collections.unmodifiableMap(authentications);
}
 
示例29
/**
 * Get authentications (key: authentication name, value: authentication).
 *
 * @return Map of authentication objects
 */
public Map<String, Authentication> getAuthentications() {
    return authentications;
}
 
示例30
/**
 * Get authentication for the given name.
 *
 * @param authName The authentication name
 * @return The authentication, null if not found
 */
public Authentication getAuthentication(String authName) {
    return authentications.get(authName);
}