final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication instanceof PreAuthenticatedAuthenticationToken) {
PreAuthenticatedAuthenticationToken authToken = (PreAuthenticatedAuthenticationToken) authentication;
final Object credentials = authToken.getCredentials();
if (credentials instanceof AuthorizationToken) {
AuthorizationToken token = (AuthorizationToken) credentials;
final Application applicationForToken = oAuth2MgmtService.getApplicationForToken(token);
String addConnectorCallbackURL = applicationForToken.addConnectorCallbackURL;
if (addConnectorCallbackURL !=null) {
String connectorName = location.substring(location.lastIndexOf("/")+1);
addConnectorCallbackURL += addConnectorCallbackURL.indexOf("?")==-1