Codota Logo
ObjectPostProcessor
Code IndexAdd Codota to your IDE (free)

How to use
ObjectPostProcessor
in
org.springframework.security.config.annotation

Best Java code snippets using org.springframework.security.config.annotation.ObjectPostProcessor (Showing top 20 results out of 315)

  • Common ways to obtain ObjectPostProcessor
private void myMethod () {
ObjectPostProcessor o =
  • Codota IconAutowireCapableBeanFactory autowireBeanFactory;new AutowireBeanFactoryObjectPostProcessor(autowireBeanFactory)
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-security

/**
 * Performs post processing of an object. The default is to delegate to the
 * {@link ObjectPostProcessor}.
 *
 * @param object the Object to post process
 * @return the possibly modified Object to use
 */
protected <P> P postProcess(P object) {
  return this.objectPostProcessor.postProcess(object);
}
origin: spring-projects/spring-security

@Autowired(required = false)
public void setObjectPostProcessor(ObjectPostProcessor<Object> objectPostProcessor) {
  this.objectPostProcessor = objectPostProcessor;
  this.defaultMethodExpressionHandler = objectPostProcessor
      .postProcess(defaultMethodExpressionHandler);
}
origin: spring-projects/spring-security

@Autowired(required = false)
public void setObjectPostProcessor(ObjectPostProcessor<Object> objectPostProcessor) {
  defaultExpressionHandler = objectPostProcessor.postProcess(defaultExpressionHandler);
}
origin: spring-projects/spring-security

@SuppressWarnings({ "rawtypes", "unchecked" })
public Object postProcess(Object object) {
  for (ObjectPostProcessor opp : postProcessors) {
    Class<?> oppClass = opp.getClass();
    Class<?> oppType = GenericTypeResolver.resolveTypeArgument(oppClass,
        ObjectPostProcessor.class);
    if (oppType == null || oppType.isAssignableFrom(object.getClass())) {
      object = opp.postProcess(object);
    }
  }
  return object;
}
origin: spring-projects/spring-security

  @Autowired
  public void configure(ObjectPostProcessor<Object> p) {
    p.postProcess(this.toTest);
  }
}
origin: spring-projects/spring-security

/**
 * Creates the Spring Security Filter Chain
 * @return the {@link Filter} that represents the security filter chain
 * @throws Exception
 */
@Bean(name = AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME)
public Filter springSecurityFilterChain() throws Exception {
  boolean hasConfigurers = webSecurityConfigurers != null
      && !webSecurityConfigurers.isEmpty();
  if (!hasConfigurers) {
    WebSecurityConfigurerAdapter adapter = objectObjectPostProcessor
        .postProcess(new WebSecurityConfigurerAdapter() {
        });
    webSecurity.apply(adapter);
  }
  return webSecurity.build();
}
origin: spring-projects/spring-security

  @Autowired
  public void configure(ObjectPostProcessor<Object> p) {
    p.postProcess(new Object());
  }
}
origin: spring-projects/spring-security

/**
 * Creates {@link MvcRequestMatcher} instances for the method and patterns passed in
 *
 * @param method the HTTP method to use or null if any should be used
 * @param mvcPatterns the Spring MVC patterns to match on
 * @return a List of {@link MvcRequestMatcher} instances
 */
protected final List<MvcRequestMatcher> createMvcMatchers(HttpMethod method,
    String... mvcPatterns) {
  Assert.state(!this.anyRequestConfigured, "Can't configure mvcMatchers after anyRequest");
  ObjectPostProcessor<Object> opp = this.context.getBean(ObjectPostProcessor.class);
  if (!this.context.containsBean(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME)) {
    throw new NoSuchBeanDefinitionException("A Bean named " + HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME +" of type " + HandlerMappingIntrospector.class.getName()
      + " is required to use MvcRequestMatcher. Please ensure Spring Security & Spring MVC are configured in a shared ApplicationContext.");
  }
  HandlerMappingIntrospector introspector = this.context.getBean(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME,
    HandlerMappingIntrospector.class);
  List<MvcRequestMatcher> matchers = new ArrayList<>(
      mvcPatterns.length);
  for (String mvcPattern : mvcPatterns) {
    MvcRequestMatcher matcher = new MvcRequestMatcher(introspector, mvcPattern);
    opp.postProcess(matcher);
    if (method != null) {
      matcher.setMethod(method);
    }
    matchers.add(matcher);
  }
  return matchers;
}
origin: spring-projects/spring-security

  throws Exception {
webSecurity = objectPostProcessor
    .postProcess(new WebSecurity(objectPostProcessor));
if (debugEnabled != null) {
  webSecurity.debug(debugEnabled);
origin: spring-projects/spring-security

@SuppressWarnings("unchecked")
private <T> T lazyBean(Class<T> interfaceName) {
  LazyInitTargetSource lazyTargetSource = new LazyInitTargetSource();
  String[] beanNamesForType = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
      applicationContext, interfaceName);
  if (beanNamesForType.length == 0) {
    return null;
  }
  String beanName;
  if (beanNamesForType.length > 1) {
    List<String> primaryBeanNames = Arrays.stream(beanNamesForType)
      .filter(i -> applicationContext instanceof ConfigurableApplicationContext)
      .filter(n -> ((ConfigurableApplicationContext) applicationContext).getBeanFactory().getBeanDefinition(n).isPrimary())
      .collect(Collectors.toList());
    Assert.isTrue(primaryBeanNames.size() != 0, () -> "Found " + beanNamesForType.length
        + " beans for type " + interfaceName + ", but none marked as primary");
    Assert.isTrue(primaryBeanNames.size() == 1, () -> "Found " + primaryBeanNames.size()
        + " beans for type " + interfaceName + " marked as primary");
    beanName = primaryBeanNames.get(0);
  } else {
    beanName = beanNamesForType[0];
  }
  lazyTargetSource.setTargetBeanName(beanName);
  lazyTargetSource.setBeanFactory(applicationContext);
  ProxyFactoryBean proxyFactory = new ProxyFactoryBean();
  proxyFactory = objectPostProcessor.postProcess(proxyFactory);
  proxyFactory.setTargetSource(lazyTargetSource);
  return (T) proxyFactory.getObject();
}
origin: spring-projects/spring-security

@Test
public void getAuthenticationManagerWhenPostProcessThenUsesBeanClassLoaderOnProxyFactoryBean() throws Exception {
  this.spring.register(Sec2531Config.class).autowire();
  ObjectPostProcessor<Object> opp = this.spring.getContext().getBean(ObjectPostProcessor.class);
  when(opp.postProcess(any())).thenAnswer(a -> a.getArgument(0));
  AuthenticationConfiguration config = this.spring.getContext().getBean(AuthenticationConfiguration.class);
  config.getAuthenticationManager();
  verify(opp).postProcess(any(ProxyFactoryBean.class));
}
origin: spring-projects/spring-security

@Test
public void configureWhenRegisteringObjectPostProcessorThenInvokedOnExceptionTranslationFilter() {
  this.spring.register(ObjectPostProcessorConfig.class, DefaultSecurityConfig.class).autowire();
  verify(ObjectPostProcessorConfig.objectPostProcessor)
      .postProcess(any(ExceptionTranslationFilter.class));
}
origin: spring-projects/spring-security

@Test
public void configureWhenRegisteringObjectPostProcessorThenInvokedOnExceptionTranslationFilter() {
  this.spring.register(ObjectPostProcessorConfig.class, DefaultSecurityConfig.class).autowire();
  verify(ObjectPostProcessorConfig.objectPostProcessor)
      .postProcess(any(RequestCacheAwareFilter.class));
}
origin: spring-projects/spring-security

@Test
public void buildWhenAddAuthenticationProviderThenDoesNotPerformRegistration() throws Exception {
  ObjectPostProcessor<Object> opp = mock(ObjectPostProcessor.class);
  AuthenticationProvider provider = mock(AuthenticationProvider.class);
  AuthenticationManagerBuilder builder = new AuthenticationManagerBuilder(opp);
  builder.authenticationProvider(provider);
  builder.build();
  verify(opp, never()).postProcess(provider);
}
origin: spring-projects/spring-security

@Test
public void customAuthenticationEventPublisherWithWeb() throws Exception {
  ObjectPostProcessor<Object> opp = mock(ObjectPostProcessor.class);
  AuthenticationEventPublisher aep = mock(AuthenticationEventPublisher.class);
  when(opp.postProcess(any())).thenAnswer(a -> a.getArgument(0));
  AuthenticationManager am = new AuthenticationManagerBuilder(opp)
        .authenticationEventPublisher(aep)
        .inMemoryAuthentication()
        .and()
        .build();
  try {
    am.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
  } catch (AuthenticationException success) {}
  verify(aep).publishAuthenticationFailure(any(), any());
}
origin: spring-projects/spring-security

@Test
public void postProcessWhenDisposableBeanThenAwareInvoked() throws Exception {
  this.spring.register(Config.class).autowire();
  DisposableBean toPostProcess = mock(DisposableBean.class);
  this.objectObjectPostProcessor.postProcess(toPostProcess);
  this.spring.getContext().close();
  verify(toPostProcess).destroy();
}
origin: spring-projects/spring-security

@Test
public void postProcessWhenBeanFactoryAwareThenAwareInvoked() {
  this.spring.register(Config.class).autowire();
  BeanFactoryAware toPostProcess = mock(BeanFactoryAware.class);
  this.objectObjectPostProcessor.postProcess(toPostProcess);
  verify(toPostProcess).setBeanFactory(isNotNull());
}
origin: spring-projects/spring-security

@Test
public void postProcessWhenApplicationContextAwareThenAwareInvoked() {
  this.spring.register(Config.class).autowire();
  ApplicationContextAware toPostProcess = mock(ApplicationContextAware.class);
  this.objectObjectPostProcessor.postProcess(toPostProcess);
  verify(toPostProcess).setApplicationContext(isNotNull());
}
origin: spring-projects/spring-security

@Test
public void postProcessWhenBeanClassLoaderAwareThenAwareInvoked() {
  this.spring.register(Config.class).autowire();
  BeanClassLoaderAware toPostProcess = mock(BeanClassLoaderAware.class);
  this.objectObjectPostProcessor.postProcess(toPostProcess);
  verify(toPostProcess).setBeanClassLoader(isNotNull());
}
origin: spring-projects/spring-security

@Test
public void postProcessWhenEnvironmentAwareThenAwareInvoked() {
  this.spring.register(Config.class).autowire();
  EnvironmentAware toPostProcess = mock(EnvironmentAware.class);
  this.objectObjectPostProcessor.postProcess(toPostProcess);
  verify(toPostProcess).setEnvironment(isNotNull());
}
org.springframework.security.config.annotationObjectPostProcessor

Javadoc

Allows initialization of Objects. Typically this is used to call the Awaremethods, InitializingBean#afterPropertiesSet(), and ensure that DisposableBean#destroy() has been invoked.

Most used methods

  • postProcess
    Initialize the object possibly returning a modified instance that should be used instead.

Popular in Java

  • Reactive rest calls using spring rest template
  • getResourceAsStream (ClassLoader)
  • runOnUiThread (Activity)
  • startActivity (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • InputStreamReader (java.io)
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes
  • Socket (java.net)
    Provides a client-side TCP socket.
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now