Java Code Examples for org.openapitools.client.auth.Authentication#applyToParams()

The following examples show how to use org.openapitools.client.auth.Authentication#applyToParams() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * 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
 * @param cookieParams Map of cookie parameters
 * @param method HTTP method (e.g. POST)
 * @param uri HTTP URI
 */
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams,
                                   Map<String, String> cookieParams, String payload, String method, URI uri) throws ApiException {
  for (String authName : authNames) {
    Authentication auth = authentications.get(authName);
    if (auth == null) {
      continue;
    }
    auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri);
  }
}
 
Example 2
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a retrofit2 client for given API interface
 */
public <S> S createService(Class<S> serviceClass) {
    if(!basePath.endsWith("/")) {
        basePath = basePath + "/";
    }

    Map<String, String> extraHeaders = new HashMap<>();
    Map<String, String> extraCookies = new HashMap<>();
    List<Pair> extraQueryParams = new ArrayList<>();

    for (String authName : authentications.keySet()) {
        Authentication auth = authentications.get(authName);
        if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);

        auth.applyToParams(extraQueryParams, extraHeaders, extraCookies);
    }

    if (callFactory == null) {
        callFactory = new Play26CallFactory(wsClient, extraHeaders, extraCookies, extraQueryParams);
    }
    if (callAdapterFactory == null) {
        callAdapterFactory = new Play26CallAdapterFactory();
    }
    if (defaultMapper == null) {
        defaultMapper = Json.mapper();
        JsonNullableModule jnm = new JsonNullableModule();
        defaultMapper.registerModule(jnm);
    }

    return new Retrofit.Builder()
                    .baseUrl(basePath)
                    .addConverterFactory(new FileConverter())
                    .addConverterFactory(ScalarsConverterFactory.create())
                    .addConverterFactory(JacksonConverterFactory.create(defaultMapper))
                    .callFactory(callFactory)
                    .addCallAdapterFactory(callAdapterFactory)
                    .build()
                    .create(serviceClass);
}
 
Example 3
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * 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, Map<String, String> cookieParams) {
  for (String authName : authNames) {
    Authentication auth = authentications.get(authName);
    if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
    auth.applyToParams(queryParams, headerParams, cookieParams);
  }
}
 
Example 4
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * 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
 * @param cookieParams Map of cookie parameters
 * @param method HTTP method (e.g. POST)
 * @param uri HTTP URI
 */
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams,
                                   Map<String, String> cookieParams, String payload, String method, URI uri) throws ApiException {
  for (String authName : authNames) {
    Authentication auth = authentications.get(authName);
    if (auth == null) {
      continue;
    }
    auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri);
  }
}
 
Example 5
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Update query and header parameters based on authentication settings.
 *
 * @param authNames The authentications to apply
 */
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, MultiMap headerParams, MultiMap cookieParams) {
    for (String authName : authNames) {
        Authentication auth = authentications.get(authName);
        if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
        auth.applyToParams(queryParams, headerParams, cookieParams);
    }
}
 
Example 6
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Update query and header parameters based on authentication settings.
 *
 * @param authNames The authentications to apply
 * @param queryParams The query parameters
 * @param headerParams The header parameters
 * @param cookieParams the cookie parameters
 */
private void updateParamsForAuth(String[] authNames, MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
    for (String authName : authNames) {
        Authentication auth = authentications.get(authName);
        if (auth == null) {
            throw new RestClientException("Authentication undefined: " + authName);
        }
        auth.applyToParams(queryParams, headerParams, cookieParams);
    }
}
 
Example 7
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * 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
 * @param cookieParams Map of cookie parameters
 */
public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
    for (String authName : authNames) {
        Authentication auth = authentications.get(authName);
        if (auth == null) {
            throw new RuntimeException("Authentication undefined: " + authName);
        }
        auth.applyToParams(queryParams, headerParams, cookieParams);
    }
}
 
Example 8
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Update query and header parameters based on authentication settings.
 *
 * @param authNames The authentications to apply
 * @param queryParams The query parameters
 * @param headerParams The header parameters
 */
protected void updateParamsForAuth(String[] authNames, MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
    for (String authName : authNames) {
        Authentication auth = authentications.get(authName);
        if (auth == null) {
            throw new RestClientException("Authentication undefined: " + authName);
        }
        auth.applyToParams(queryParams, headerParams, cookieParams);
    }
}
 
Example 9
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Update query and header parameters based on authentication settings.
 *
 * @param authNames The authentications to apply
 * @param queryParams The query parameters
 * @param headerParams The header parameters
 */
protected void updateParamsForAuth(String[] authNames, MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
    for (String authName : authNames) {
        Authentication auth = authentications.get(authName);
        if (auth == null) {
            throw new RestClientException("Authentication undefined: " + authName);
        }
        auth.applyToParams(queryParams, headerParams, cookieParams);
    }
}
 
Example 10
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * 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
 * @param cookieParams Map of cookie parameters
 */
public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
    for (String authName : authNames) {
        Authentication auth = authentications.get(authName);
        if (auth == null) {
            throw new RuntimeException("Authentication undefined: " + authName);
        }
        auth.applyToParams(queryParams, headerParams, cookieParams);
    }
}
 
Example 11
Source File: ApiInvoker.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 12
Source File: ApiInvoker.java    From swaggy-jenkins with MIT License 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 13
Source File: ApiInvoker.java    From swagger-aem with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 14
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 3 votes vote down vote up
/**
 * Update query and header parameters based on authentication settings.
 *
 * @param authNames The authentications to apply
 * @param queryParams Query parameters
 * @param headerParams Header parameters
 * @param cookieParams Cookie parameters
 */
private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
  for (String authName : authNames) {
    Authentication auth = authentications.get(authName);
    if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
    auth.applyToParams(queryParams, headerParams, cookieParams);
  }
}