protected Object getPreAuthenticatedPrincipal(HttpServletRequest request) {
		String principal = (String) request.getAttribute(principalEnvironmentVariable);

		if (principal == null && exceptionIfVariableMissing) {
			throw new PreAuthenticatedCredentialsNotFoundException(
					principalEnvironmentVariable + " variable not found in request.");
		}

		return principal;
	}