com.stormpath.sdk.application.Application.getApiKey()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(80)

本文整理了Java中com.stormpath.sdk.application.Application.getApiKey()方法的一些代码示例,展示了Application.getApiKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.getApiKey()方法的具体详情如下:
包路径:com.stormpath.sdk.application.Application
类名称:Application
方法名:getApiKey

Application.getApiKey介绍

[英]Gets an ApiKey, by its id, that belongs to an Account that has access to this application by a mapped account store.
[中]按id获取一个ApiKey,该ApiKey属于一个帐户,该帐户通过映射帐户存储访问此应用程序。

代码示例

代码示例来源:origin: stormpath/stormpath-sdk-java

for (int i = 0; i < 3; i++) {
  try {
    apiKey = application.getApiKey(id, new DefaultApiKeyOptions().withAccount());
    break;
  } catch (Exception e) {

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl

for (int i = 0; i < 3; i++) {
  try {
    apiKey = application.getApiKey(id, new DefaultApiKeyOptions().withAccount());
    break;
  } catch (Exception e) {

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-oauth

/**
 * Retrieves the {@link ApiKey} instance pointed by this {@code apiKeyId} and accessible from the {@code
 * application}
 * <p/>
 * The ApiKey is retrieved from the {@link Application} passed as argument.
 * <p/>
 * This method asserts that the ApiKey retrieved status is {@link ApiKeyStatus#ENABLED} and also that the status of
 * the account owner is {@link AccountStatus#ENABLED}
 *
 * @param application - The application that is making the assertion.
 * @param apiKeyId    - The id of the {@link ApiKey} embedded in the access token.
 */
private ApiKey getTokenApiKey(Application application, String apiKeyId) {
  ApiKey apiKey = application.getApiKey(apiKeyId, new DefaultApiKeyOptions().withAccount());
  if (apiKey == null || apiKey.getStatus() == ApiKeyStatus.DISABLED) {
    throw ApiAuthenticationExceptionFactory.newOAuthException(AccessTokenOAuthException.class, INVALID_CLIENT);
  }
  Account account = apiKey.getAccount();
  if (account.getStatus() != AccountStatus.ENABLED) {
    throw ApiAuthenticationExceptionFactory.newOAuthException(AccessTokenOAuthException.class, INVALID_CLIENT);
  }
  return apiKey;
}

代码示例来源:origin: stormpath/stormpath-sdk-java

/**
 * Retrieves the {@link ApiKey} instance pointed by this {@code apiKeyId} and accessible from the {@code
 * application}
 * <p/>
 * The ApiKey is retrieved from the {@link Application} passed as argument.
 * <p/>
 * This method asserts that the ApiKey retrieved status is {@link ApiKeyStatus#ENABLED} and also that the status of
 * the account owner is {@link AccountStatus#ENABLED}
 *
 * @param application - The application that is making the assertion.
 * @param apiKeyId    - The id of the {@link ApiKey} embedded in the access token.
 */
private ApiKey getTokenApiKey(Application application, String apiKeyId) {
  ApiKey apiKey = application.getApiKey(apiKeyId, new DefaultApiKeyOptions().withAccount());
  if (apiKey == null || apiKey.getStatus() == ApiKeyStatus.DISABLED) {
    throw ApiAuthenticationExceptionFactory.newOAuthException(AccessTokenOAuthException.class, INVALID_CLIENT);
  }
  Account account = apiKey.getAccount();
  if (account.getStatus() != AccountStatus.ENABLED) {
    throw ApiAuthenticationExceptionFactory.newOAuthException(AccessTokenOAuthException.class, INVALID_CLIENT);
  }
  return apiKey;
}

代码示例来源:origin: stormpath/stormpath-sdk-java

protected ApiKey getEnabledApiKey(HttpServletRequest request, String apiKeyId)
  throws InvalidApiKeyException, DisabledApiKeyException, DisabledAccountException {
  Application app = getApplication(request);
  ApiKey apiKey = app.getApiKey(apiKeyId);
  if (apiKey == null) {
    throw new InvalidApiKeyException(newError("apiKey is invalid."));
  }
  if (apiKey.getStatus() != ApiKeyStatus.ENABLED) {
    throw new DisabledApiKeyException(newError("apiKey is disabled."));
  }
  Account account = apiKey.getAccount();
  AccountStatus status = account.getStatus();
  if (status != AccountStatus.ENABLED) {
    throw new DisabledAccountException(newError("account is disabled."), status);
  }
  return apiKey;
}

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-servlet

protected ApiKey getEnabledApiKey(HttpServletRequest request, String apiKeyId)
  throws InvalidApiKeyException, DisabledApiKeyException, DisabledAccountException {
  Application app = getApplication(request);
  ApiKey apiKey = app.getApiKey(apiKeyId);
  if (apiKey == null) {
    throw new InvalidApiKeyException(newError("apiKey is invalid."));
  }
  if (apiKey.getStatus() != ApiKeyStatus.ENABLED) {
    throw new DisabledApiKeyException(newError("apiKey is disabled."));
  }
  Account account = apiKey.getAccount();
  AccountStatus status = account.getStatus();
  if (status != AccountStatus.ENABLED) {
    throw new DisabledAccountException(newError("account is disabled."), status);
  }
  return apiKey;
}

相关文章