public Object invoke(Object targetObject) throws NoSuchMethodException,
			IllegalAccessException, InvocationTargetException {

		if (principal != null) {
			Authentication request = createAuthenticationRequest(principal, credentials);
			request.setAuthenticated(false);
			SecurityContextHolder.getContext().setAuthentication(request);

			if (logger.isDebugEnabled()) {
				logger.debug("Set SecurityContextHolder to contain: " + request);
			}
		}

		try {
			return super.invoke(targetObject);
		}
		finally {
			SecurityContextHolder.clearContext();

			if (logger.isDebugEnabled()) {
				logger.debug("Cleared SecurityContextHolder.");
			}
		}
	}
public Object invoke(Object targetObject) throws NoSuchMethodException,
			IllegalAccessException, InvocationTargetException {

		if (principal != null) {
			Authentication request = createAuthenticationRequest(principal, credentials);
			request.setAuthenticated(false);
			SecurityContextHolder.getContext().setAuthentication(request);

			if (logger.isDebugEnabled()) {
				logger.debug("Set SecurityContextHolder to contain: " + request);
			}
		}

		try {
			return super.invoke(targetObject);
		}
		finally {
			SecurityContextHolder.clearContext();

			if (logger.isDebugEnabled()) {
				logger.debug("Cleared SecurityContextHolder.");
			}
		}
	}
public Object invoke ( Object targetObject ) throws NoSuchMethodException , IllegalAccessException , InvocationTargetException { if ( principal != null ) { Authentication request = createAuthenticationRequest ( principal , credentials ) ; request . setAuthenticated ( false ) ; SecurityContextHolder . getContext ( ) . setAuthentication ( request ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Set SecurityContextHolder to contain: " + request ) ; } } try { return super . invoke ( targetObject ) ; } finally { SecurityContextHolder . clearContext ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Cleared SecurityContextHolder." ) ; } } }
Invoked on the server-side.
<p>
The transmitted principal and credentials will be used to create an unauthenticated
{@code Authentication} instance for processing by the {@code AuthenticationManager}.

@param targetObject the target object to apply the invocation to

@return the invocation result

@throws NoSuchMethodException if the method name could not be resolved
@throws IllegalAccessException if the method could not be accessed
@throws InvocationTargetException if the method invocation resulted in an exception
Invoked on the server - side . <p > The transmitted principal and credentials will be used to create an unauthenticated { @code Authentication } instance for processing by the { @code AuthenticationManager } .