code: public static String encode(User user) {
  		StringBuilder out = new StringBuilder();
  		out.append(user.id).append(FIELD_SEPARATOR);
  		out.append(user.isEnabled()).append(FIELD_SEPARATOR);
  		out.append(Base64.encodeBase64String(user.name.getBytes())).append(FIELD_SEPARATOR);
  		out.append(user.getContext().getAuthenticationMethod().getType().getUniqueIdentifier()).append(
  				FIELD_SEPARATOR);
  		out.append(user.authenticationCredentials.encode(FIELD_SEPARATOR));
  		if (log.isDebugEnabled())
  			log.debug("Encoded user: " + out.toString());
  		return out.toString();
  	}
docs: Encodes the User in a String. Fields that contain strings are Base64 encoded.
  
  @param user the user
  @return the string