List of usage examples for org.springframework.security.access.event AuthorizedEvent getSource
public Object getSource()
From source file:com.muk.security.AuthEventListener.java
@Override public void onApplicationEvent(AuthorizedEvent event) { final Exchange exchange = (Exchange) event.getSource(); if (!RestConstants.Rest.anonymousToken.equals(event.getAuthentication().getName()) && exchange.getIn().getHeader(HttpHeaders.AUTHORIZATION, String.class) != null) { final Authentication currentAuthentication = event.getAuthentication(); final String currentTokenRepresentation = (String) currentAuthentication.getCredentials(); final String incomingTokenRepresentation = StringUtils .substringAfter(exchange.getIn().getHeader(HttpHeaders.AUTHORIZATION, String.class), "Bearer "); if (!currentTokenRepresentation.equals(incomingTokenRepresentation)) { exchange.getOut().getHeaders().put(RestConstants.Headers.refreshToken, currentTokenRepresentation); }/*from w ww . j av a 2s. c om*/ } }