core/src/main/java/org/springframework/security/authentication/jaas/JaasNameCallbackHandler.java
public void handle(Callback callback, Authentication authentication)
			throws IOException, UnsupportedCallbackException {
		if (callback instanceof NameCallback) {
			NameCallback ncb = (NameCallback) callback;
			String username;

			Object principal = authentication.getPrincipal();

			if (principal instanceof UserDetails) {
				username = ((UserDetails) principal).getUsername();
			}
			else {
				username = principal.toString();
			}

			ncb.setName(username);
		}
	}
public void handle(Callback callback, Authentication authentication)
			throws IOException, UnsupportedCallbackException {
		if (callback instanceof NameCallback) {
			NameCallback ncb = (NameCallback) callback;
			String username;

			Object principal = authentication.getPrincipal();

			if (principal instanceof UserDetails) {
				username = ((UserDetails) principal).getUsername();
			}
			else {
				username = principal.toString();
			}

			ncb.setName(username);
		}
	}
If the callback passed to the 'handle' method is an instance of NameCallback, the
JaasNameCallbackHandler will call,
callback.setName(authentication.getPrincipal().toString()).

@param callback
@param authentication

@throws IOException
@throws UnsupportedCallbackException