com.stormpath.sdk.lang.Assert.isInstanceOf()方法的使用及代码示例

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

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

Assert.isInstanceOf介绍

[英]Assert that the provided object is an instance of the provided class.

Assert.instanceOf(Foo.class, foo);

[中]断言所提供的对象是所提供类的实例

Assert.instanceOf(Foo.class, foo);

代码示例

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

/**
 * Assert that the provided object is an instance of the provided class.
 * <pre class="code">Assert.instanceOf(Foo.class, foo);</pre>
 * @param clazz the required class
 * @param obj the object to check
 * @throws IllegalArgumentException if the object is not an instance of clazz
 * @see Class#isInstance
 */
public static void isInstanceOf(Class clazz, Object obj) {
  isInstanceOf(clazz, obj, "");
}

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

public ClientBuilder setClientCredentials(ClientCredentials clientCredentials) {
  Assert.isInstanceOf(ClientCredentials.class, clientCredentials);
  this.clientCredentials = clientCredentials;
  return this;
}

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

@Override
public Object get(Object key) {
  Assert.isInstanceOf(String.class, key);
  readLock.lock();
  try {
    return this.backingMap.get(key);
  } finally {
    readLock.unlock();
  }
}

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

@Override
public boolean containsKey(Object key) {
  Assert.isInstanceOf(String.class, key);
  readLock.lock();
  try {
    return this.backingMap.containsKey(key);
  } finally {
    readLock.unlock();
  }
}

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

@Override
public Object get(Object key) {
  Assert.isInstanceOf(String.class, key);
  readLock.lock();
  try {
    return this.backingMap.get(key);
  } finally {
    readLock.unlock();
  }
}

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

@Override
public Object get(Object key) {
  Assert.isInstanceOf(String.class, key);
  return super.getProperty(key.toString());
}

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

@SuppressWarnings("unchecked")
  @Override
  public Map<String, Object> apply(Account account) {
    Object o = converter.apply(account);
    Assert.isInstanceOf(Map.class, o, "ResourceConverter was expected to return a Map instance.");
    return (Map<String,Object>)o;
  }
};

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

@Override
public Object get(Object key) {
  Assert.isInstanceOf(String.class, key);
  return super.getProperty(key.toString());
}

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

@Override
public CacheManagerBuilder withCache(CacheConfigurationBuilder builder) {
  Assert.isInstanceOf(DefaultCacheConfigurationBuilder.class, builder,
      "This implementation only accepts " + DefaultCacheConfigurationBuilder.class.getName() + " instances.");
  DefaultCacheConfigurationBuilder b = (DefaultCacheConfigurationBuilder) builder;
  this.configs.add(b.build());
  return this;
}

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

protected DefaultCriteria(O options) {
  Assert.notNull(options, "options argument cannot be null.");
  Assert.isInstanceOf(Expandable.class, options, "options argument is expected to implement the " + Expandable.class.getName() + " interface.");
  this.options = options;
  this.criterionEntries = new ArrayList<Criterion>();
  this.orderEntries = new ArrayList<Order>();
  this.customAttributes = new HashMap<>();
}

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

public Client getClient(final ServletContext servletContext) {
  Assert.notNull(servletContext, "ServletContext argument cannot be null.");
  Object object = servletContext.getAttribute(ClientLoader.CLIENT_ATTRIBUTE_KEY);
  Assert.notNull(object, ERROR_MSG);
  Assert.isInstanceOf(Client.class, object, "Object instance found under servlet context attribute name " +
                       ClientLoader.CLIENT_ATTRIBUTE_KEY + "' is not a " +
                       Client.class.getName() + " instance as required.  " +
                       "Instance is of type: " + object.getClass().getName());
  return (Client)object;
}

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

@Override
public Application getApplication(final ServletRequest servletRequest) {
  Object attribute = servletRequest.getAttribute(Application.class.getName());
  if (attribute != null) {
    Assert.isInstanceOf(Application.class, attribute);
    return (Application) attribute;
  }
  return getApplication(servletRequest.getServletContext());
}

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

public Config getConfig(ServletContext servletContext) {

    Assert.notNull(servletContext, "ServletContext argument cannot be null.");

    Object value = servletContext.getAttribute(SERVLET_CONTEXT_ATTRIBUTE_NAME);

    Assert.notNull(value, NULL_ERR_MSG);

    Assert.isInstanceOf(Config.class, value, INSTANCE_ERR_MSG);

    return (Config) value;
  }
}

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

protected ApiAuthenticationResult execute() {
  AuthenticationRequest request = FACTORY.createFrom(httpRequest);
  AuthenticationResult result = application.authenticateAccount(request);
  Assert.isInstanceOf(ApiAuthenticationResult.class, result);
  return (ApiAuthenticationResult) result;
}

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

@SuppressWarnings("unchecked")
@Override
public <T extends Resource> T getResource(String href, Class<T> clazz, Criteria criteria) {
  Assert.isInstanceOf(DefaultCriteria.class, criteria, DEFAULT_CRITERIA_MSG);
  QueryString qs = queryStringFactory.createQueryString(href, (DefaultCriteria)criteria);
  return (T) getResource(href, clazz, (Map) qs);
}

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

public DefaultNonce(Map<String, Object> properties) {
  Assert.notEmpty(properties);
  Assert.isTrue(properties.size() == 1 && properties.containsKey(VALUE.getName()));
  Object value = properties.get(VALUE.getName());
  Assert.isInstanceOf(String.class, value);
  this.properties = properties;
}

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

public SswsAuthenticator(ApiKeyCredentials apiKeyCredentials) {
  Assert.notNull(apiKeyCredentials, "apiKeyCredentials must be not be null.");
  this.apiKeyCredentials = apiKeyCredentials;
  ApiKey apiKey = apiKeyCredentials.getApiKey();
  Assert.notNull(apiKey, "apiKeyCredentials argument cannot have a null apiKey");
  Assert.isInstanceOf(PairedApiKey.class, apiKey, "apiKeyCredentials.getApiKey() must be a PairedApiKey instance");
  this.pairedApiKey = (PairedApiKey) apiKey;
}

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

@Override
public OAuthAuthenticationResult authenticate(HttpServletRequest httpRequest) {
  Assert.notNull(httpRequest, "httpRequest argument cannot be null.");
  Assert.isInstanceOf(javax.servlet.http.HttpServletRequest.class, httpRequest,
      "The specified httpRequest argument must be an instance of " + HTTP_SERVLET_REQUEST_FQCN);
  com.stormpath.sdk.impl.http.ServletHttpRequest stmpHttpRequest = new com.stormpath.sdk.impl.http.ServletHttpRequest(httpRequest);
  return Applications.oauthRequestAuthenticator(application).authenticate(stmpHttpRequest);
}

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

@Override
public AuthenticationResult authenticate(AuthenticationRequest request) {
  Assert.isInstanceOf(DefaultUsernamePasswordRequest.class, request, "Only 'DefaultUsernamePasswordRequest' requests are supported.");
  DefaultUsernamePasswordRequest usernamePasswordRequest = (DefaultUsernamePasswordRequest) request;
  final OktaTokenResponse oktaTokenResponse = doAuthRequest(usernamePasswordRequest);
  String uid = getUserId(oktaTokenResponse.getAccessToken());
  String userHref = OktaApiPaths.apiPath("users", uid);
  return new DefaultOktaAccessTokenResult(oktaTokenResponse, dataStore.getResource(userHref, Account.class));
}

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

@Override
public OAuthGrantRequestAuthenticationResult authenticate(OAuthRequestAuthentication authenticationRequest) {
  Assert.notNull(this.oauthTokenPath, "oauthTokenPath cannot be null or empty");
  Assert.isInstanceOf(OAuthClientCredentialsGrantRequestAuthentication.class, authenticationRequest, "authenticationRequest must be an instance of OAuthClientCredentialsGrantRequestAuthentication.");
  OAuthClientCredentialsGrantRequestAuthentication oAuthClientCredentialsGrantRequestAuthentication = (OAuthClientCredentialsGrantRequestAuthentication) authenticationRequest;
  OAuthClientCredentialsGrantAuthenticationAttempt oAuthClientCredentialsGrantAuthenticationAttempt = new DefaultOAuthClientCredentialsGrantAuthenticationAttempt(dataStore);
  oAuthClientCredentialsGrantAuthenticationAttempt.setGrantType(oAuthClientCredentialsGrantRequestAuthentication.getGrantType());
  oAuthClientCredentialsGrantAuthenticationAttempt.setApiKeyId(oAuthClientCredentialsGrantRequestAuthentication.getApiKeyId());
  oAuthClientCredentialsGrantAuthenticationAttempt.setApiKeySecret(oAuthClientCredentialsGrantRequestAuthentication.getApiKeySecret());
  return performAuthentiationAttempt(oAuthClientCredentialsGrantAuthenticationAttempt, oauthTokenPath);
}

相关文章