@Bean public static DelegatingApplicationListener delegatingApplicationListener() { return new DelegatingApplicationListener(); }
@Before public void setup() { event = new ApplicationEvent(this) { }; listener = new DelegatingApplicationListener(); listener.addListener(delegate); }
private void registerDelegateApplicationListener(H http, ApplicationListener<?> delegate) { ApplicationContext context = http.getSharedObject(ApplicationContext.class); if (context == null) { return; } if (context.getBeansOfType(DelegatingApplicationListener.class).isEmpty()) { return; } DelegatingApplicationListener delegating = context .getBean(DelegatingApplicationListener.class); SmartApplicationListener smartListener = new GenericApplicationListenerAdapter( delegate); delegating.addListener(smartListener); }
/** * Gets the {@link Authentication} object that represents the user * associated with the current request. */ public static Authentication getAuthentication() { Authentication a = SecurityContextHolder.getContext().getAuthentication(); // on Tomcat while serving the login page, this is null despite the fact // that we have filters. Looking at the stack trace, Tomcat doesn't seem to // run the request through filters when this is the login request. // see http://www.nabble.com/Matrix-authorization-problem-tp14602081p14886312.html if (a == null) { a = ANONYMOUS; } return a; }
protected void resetPreviousAuthentication(Authentication previousAuthentication) { SecurityContextHolder.getContext().setAuthentication(previousAuthentication); }
public final void run() { // background activity gets system credential, // just like executors get it. SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM); try { doRun(); } catch(Throwable t) { LOGGER.log(Level.SEVERE, "Timer task "+this+" failed",t); } finally { SecurityContextHolder.clearContext(); } }
@Test public void processEventNull() { listener.onApplicationEvent(null); verify(delegate, never()).onApplicationEvent(any(ApplicationEvent.class)); }
public boolean preHandleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception { // call to common preHandle method return preHandle(request, response, handler); }
public void afterRenderCompletion(RenderRequest request, RenderResponse response, Object handler, Exception ex) throws Exception { // call to common afterCompletion method afterCompletion(request, response, handler, ex); }
public PortletSessionContextIntegrationInterceptor() throws PortletException { this.contextObject = generateNewContext(); }
private boolean isSAMLInSecurityContext(){ AbstractAuthenticationToken cat = (AbstractAuthenticationToken)SecurityContextHolder.getContext().getAuthentication(); if(cat.getDetails() instanceof SAMLAssertion){ return true; } return false; }
@Override public void run() { try { SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM); reload(); } catch (IOException e) { LOGGER.log(java.util.logging.Level.SEVERE, "Failed to reload Hudson config", e); } catch (ReactorException e) { LOGGER.log(java.util.logging.Level.SEVERE, "Failed to reload Hudson config", e); } catch (InterruptedException e) { LOGGER.log(java.util.logging.Level.SEVERE, "Failed to reload Hudson config", e); } } }.start();
@Test(expected = IllegalArgumentException.class) public void addNull() { listener.addListener(null); }
@Bean public static DelegatingApplicationListener delegatingApplicationListener() { return new DelegatingApplicationListener(); }
@Test public void processEventEventTypeNotSupported() { listener.onApplicationEvent(event); verify(delegate, never()).onApplicationEvent(any(ApplicationEvent.class)); }
public boolean preHandleAction(ActionRequest request, ActionResponse response, Object handler) throws Exception { // call to common preHandle method return preHandle(request, response, handler); }
public void afterActionCompletion(ActionRequest request, ActionResponse response, Object handler, Exception ex) throws Exception { // call to common afterCompletion method afterCompletion(request, response, handler, ex); }
private void registerDelegateApplicationListener(H http, ApplicationListener<?> delegate) { ApplicationContext context = http.getSharedObject(ApplicationContext.class); if (context == null) { return; } if (context.getBeansOfType(DelegatingApplicationListener.class).isEmpty()) { return; } DelegatingApplicationListener delegating = context .getBean(DelegatingApplicationListener.class); SmartApplicationListener smartListener = new GenericApplicationListenerAdapter( delegate); delegating.addListener(smartListener); }
@Test public void processEventSourceTypeNotSupported() { when(delegate.supportsEventType(event.getClass())).thenReturn(true); listener.onApplicationEvent(event); verify(delegate, never()).onApplicationEvent(any(ApplicationEvent.class)); }
@Test public void processEventSuccess() { when(delegate.supportsEventType(event.getClass())).thenReturn(true); when(delegate.supportsSourceType(event.getSource().getClass())).thenReturn(true); listener.onApplicationEvent(event); verify(delegate).onApplicationEvent(event); }