List of usage examples for org.springframework.util Assert isInstanceOf
public static void isInstanceOf(Class<?> type, @Nullable Object obj, Supplier<String> messageSupplier)
From source file:org.wso2.msf4j.spring.MSF4JSpringApplication.java
private void applyInitializers(ConfigurableApplicationContext context) { for (ApplicationContextInitializer initializer : getInitializers()) { Class<?> requiredType = GenericTypeResolver.resolveTypeArgument(initializer.getClass(), ApplicationContextInitializer.class); Assert.isInstanceOf(requiredType, context, "Unable to call initializer."); initializer.initialize(context); }//from w w w . jav a 2s. c o m }
From source file:com.autentia.wuija.widget.query.AdvancedQuery.java
@Override protected void prepareUserInterfaz() { simpleExpressionWidgets.clear();/*from w w w.j a va2 s . c o m*/ final List<Criterion> criterions = criteria.getCriterions(); for (int i = 0; i < criterions.size(); i++) { final Criterion criterion = criterions.get(i); Assert.isInstanceOf(SimpleExpression.class, criterion, "Type " + criterion.getClass().getName() + "not supported."); final SimpleExpression simpleExpression = (SimpleExpression) criterion; addSimpleExpressionWidget(simpleExpression); } addSimpleExpressionWidget(); }
From source file:com.ctb.prism.login.security.provider.AbstractUserDetailsAuthenticationProvider.java
public Authentication authenticate(Authentication authentication) throws AuthenticationException { Assert.isInstanceOf(UsernamePasswordAuthenticationToken.class, authentication, messages.getMessage("AbstractUserDetailsAuthenticationProvider.onlySupports", "Only UsernamePasswordAuthenticationToken is supported")); // Determine username String username = (authentication.getPrincipal() == null) ? "NONE_PROVIDED" : authentication.getName(); boolean cacheWasUsed = true; UserDetails user = this.userCache.getUserFromCache(username); if (user == null) { cacheWasUsed = false;//from www . j av a 2s . co m try { user = retrieveUser(username, (UsernamePasswordAuthenticationToken) authentication); } catch (UsernameNotFoundException notFound) { logger.debug("User '" + username + "' not found"); if (hideUserNotFoundExceptions) { throw new BadCredentialsException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); } else { throw notFound; } } Assert.notNull(user, "retrieveUser returned null - a violation of the interface contract"); } try { preAuthenticationChecks.check(user); additionalAuthenticationChecks(user, (UsernamePasswordAuthenticationToken) authentication); } catch (AuthenticationException exception) { if (cacheWasUsed) { // There was a problem, so try again after checking // we're using latest data (i.e. not from the cache) cacheWasUsed = false; user = retrieveUser(username, (UsernamePasswordAuthenticationToken) authentication); preAuthenticationChecks.check(user); additionalAuthenticationChecks(user, (UsernamePasswordAuthenticationToken) authentication); } else { throw exception; } } postAuthenticationChecks.check(user); if (!cacheWasUsed) { this.userCache.putUserInCache(user); } Object principalToReturn = user; if (forcePrincipalAsString) { principalToReturn = user.getUsername(); } return createSuccessAuthentication(principalToReturn, authentication, user); }
From source file:org.activiti.spring.components.scope.ProcessScope.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { beanFactory.registerScope(ProcessScope.PROCESS_SCOPE_NAME, this); Assert.isInstanceOf(BeanDefinitionRegistry.class, beanFactory, "BeanFactory was not a BeanDefinitionRegistry, so ProcessScope cannot be used."); BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; for (String beanName : beanFactory.getBeanDefinitionNames()) { BeanDefinition definition = beanFactory.getBeanDefinition(beanName); // Replace this or any of its inner beans with scoped proxy if it has this scope boolean scoped = PROCESS_SCOPE_NAME.equals(definition.getScope()); Scopifier scopifier = new Scopifier(registry, PROCESS_SCOPE_NAME, proxyTargetClass, scoped); scopifier.visitBeanDefinition(definition); if (scoped) { Scopifier.createScopedProxy(beanName, definition, registry, proxyTargetClass); }//from w w w . jav a 2 s. c o m } beanFactory.registerSingleton(ProcessScope.PROCESS_SCOPE_PROCESS_VARIABLES_SINGLETON, this.processVariablesMap); beanFactory.registerResolvableDependency(ProcessInstance.class, createSharedProcessInstance()); }
From source file:org.synyx.hera.si.PluginRegistryAwareMessageHandler.java
/** * Returns the delimiter object to be used for the given {@link Message}. Will use the configured delimiter expression * if configured./* w ww. j a va2s . c om*/ * * @param message * @return */ private Object getDelimiter(Message<?> message) { Object delimiter = message; if (delimiterExpression != null) { StandardEvaluationContext context = new StandardEvaluationContext(message); delimiter = delimiterExpression.getValue(context); } Assert.isInstanceOf(delimiterType, delimiter, String.format("Delimiter expression did " + "not return a suitable delimiter! Make sure the expression evaluates to a suitable " + "type! Got %s but need %s", delimiter.getClass(), delimiterType)); return delimiter; }
From source file:com.cpst.postal.settlement.user.security.CustomProviderManager.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public void setProviders(List providers) { Assert.notNull(providers, "Providers list cannot be null"); for (Object currentObject : providers) { Assert.isInstanceOf(AuthenticationProvider.class, currentObject, "Can only provide AuthenticationProvider instances"); }//ww w .j a v a2 s. c o m this.providers = providers; }
From source file:com.gfactor.web.wicket.context.ProviderManager.java
/** * Sets the {@link AuthenticationProvider} objects to be used for authentication. * * @param providers the list of authentication providers which will be used to process authentication requests. * * @throws IllegalArgumentException if the list is empty or null, or any of the elements in the list is not an * AuthenticationProvider instance./*from w w w .j a va 2s .c o m*/ */ @SuppressWarnings("unchecked") public void setProviders(List providers) { Assert.notNull(providers, "Providers list cannot be null"); for (Object currentObject : providers) { Assert.isInstanceOf(AuthenticationProvider.class, currentObject, "Can only provide AuthenticationProvider instances"); } this.providers = providers; }
From source file:com.github.springtestdbunit.bean.DatabaseConfigBean.java
/** * Set a property to the underlying data config. * @param propertyName the name of the property * @param dataConfigPropertyName the data config property name * @param value the value to set/*from w ww.j a v a2 s. c om*/ */ private void setProperty(String propertyName, String dataConfigPropertyName, Object value) { ConfigProperty configProperty = CONFIG_PROPERTIES.get(dataConfigPropertyName); Assert.state(configProperty != null, "Unsupported config property " + dataConfigPropertyName + " for " + propertyName); if (!configProperty.isNullable()) { Assert.notNull(value, propertyName + " cannot be null"); } if (value != null) { Assert.isInstanceOf(configProperty.getPropertyType(), value, "Unable to set " + propertyName + " "); } this.databaseConfig.setProperty(dataConfigPropertyName, value); }
From source file:gov.nih.nci.cabig.ctms.acegi.acls.dao.impl.MutableAclDaoImpl.java
void updateObjectIdentity(MutableAcl acl) { AclObjectIdentityBean oidBean = findAclObjectIdentityBeanByObjectIdentity(acl.getObjectIdentity()); AclObjectIdentityBean parentOidBean = null; if (acl.getParentAcl() != null) { Assert.isInstanceOf(ObjectIdentityImpl.class, acl.getParentAcl().getObjectIdentity(), "Implementation only supports ObjectIdentityImpl"); ObjectIdentityImpl oii = (ObjectIdentityImpl) acl.getParentAcl().getObjectIdentity(); parentOidBean = findAclObjectIdentityBeanByObjectIdentity(oii); }/* w ww.ja v a 2 s . co m*/ Assert.notNull(acl.getOwner(), "Owner is required in this implementation"); AclSidBean ownerSid = createOrRetrieveSid(acl.getOwner(), true); oidBean.setAclSid(ownerSid); oidBean.setParent(parentOidBean); oidBean.setIsEntriesInheriting(String.valueOf(acl.isEntriesInheriting())); getHibernateTemplate().update(oidBean); }
From source file:fi.eis.applications.helpers.ServerOsgiBundleXmlWebApplicationContext.java
@Override public ConfigurableWebEnvironment getEnvironment() { ConfigurableEnvironment env = super.getEnvironment(); Assert.isInstanceOf(ConfigurableWebEnvironment.class, env, "ConfigurableWebApplicationContext environment must be of type " + "ConfigurableWebEnvironment"); return (ConfigurableWebEnvironment) env; }