Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/impl/DefaultGazetteerManager.java
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/impl/DefaultGazetteerManager.java	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/impl/DefaultGazetteerManager.java	(revision 102)
@@ -2,32 +2,33 @@
 *
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
 * of the Valencian Government (CIT)
-* 
+*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
-* 
+*
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
-* 
+*
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA  02110-1301, USA.
-* 
+*
 */
 
 /*
 * AUTHORS (In addition to CIT):
 * 2009 {Iver T.I.}   {Task}
 */
- 
+
 package org.gvsig.gazetteer.impl;
 
 import java.util.Iterator;
+import java.util.Map;
 
 import org.gvsig.gazetteer.GazetteerManager;
 import org.gvsig.gazetteer.drivers.IGazetteerServiceDriver;
@@ -42,8 +43,10 @@
  */
 public class DefaultGazetteerManager implements GazetteerManager{
 	private static final Logger logger = LoggerFactory.getLogger(DefaultGazetteerManager.class);
-	private static final String DRIVER_REGISTER_NAME = "GazetteerDrivers";	
-	
+	private static final String DRIVER_REGISTER_NAME = "GazetteerDrivers";
+
+	private Map<String,String> usernames;
+
 	/* (non-Javadoc)
 	 * @see org.gvsig.gazetteer.GazetteerManager#getDriver(java.lang.String)
 	 */
@@ -51,7 +54,7 @@
 		ExtensionPointManager extensionPointManager = ToolsLocator
 		.getExtensionPointManager();
 		ExtensionPoint extensionPoint = extensionPointManager.add(DRIVER_REGISTER_NAME);
-		
+
 		Iterator extensions = extensionPoint.iterator();
 		while (extensions.hasNext()){
 			ExtensionPoint.Extension extension = (ExtensionPoint.Extension)extensions.next();
@@ -65,7 +68,7 @@
 				logger.error("Impossible to create a gazetteer driver", e);
 			} catch (IllegalAccessException e) {
 				logger.error("Impossible to create a gazetteer driver", e);
-			}			
+			}
 		}
 		return null;
 	}
@@ -79,20 +82,20 @@
 		.getExtensionPointManager();
 		ExtensionPoint extensionPoint = extensionPointManager.add(DRIVER_REGISTER_NAME);
 		drivers = new IGazetteerServiceDriver[extensionPoint.getCount()];
-		Iterator extensions = extensionPoint.iterator();		
-		int i = 0;		
+		Iterator extensions = extensionPoint.iterator();
+		int i = 0;
 		while (extensions.hasNext()){
 			ExtensionPoint.Extension extension = (ExtensionPoint.Extension)extensions.next();
 			IGazetteerServiceDriver driver;
 			try {
 				driver = (IGazetteerServiceDriver)extension.create();
-				drivers[i] = driver;				
+				drivers[i] = driver;
 			} catch (InstantiationException e) {
 				logger.error("Impossible to create a gazetteer driver", e);
 			} catch (IllegalAccessException e) {
 				logger.error("Impossible to create a gazetteer driver", e);
-			}			
-			
+			}
+
 			i++;
 		}
 		return drivers;
@@ -108,5 +111,25 @@
 		extensionPoint.append(name.toLowerCase(), "", driver);
 	}
 
+    @Override
+    public String getUsername(String protocol) {
+        if (usernames!=null){
+            return (String)usernames.get(protocol);
+        }
+        return null;
+    }
+
+    @Override
+    public void setUsername(String protocol, String username) {
+        if (usernames!=null){
+            usernames.put(protocol, username);
+        }
+    }
+
+    @Override
+    public void setUsernames(Map usernames) {
+        this.usernames=usernames;
+    }
+
 }
 
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/GazetteerManager.java
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/GazetteerManager.java	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/GazetteerManager.java	(revision 102)
@@ -2,40 +2,41 @@
 *
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
 * of the Valencian Government (CIT)
-* 
+*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
-* 
+*
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
-* 
+*
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA  02110-1301, USA.
-* 
+*
 */
 
 /*
 * AUTHORS (In addition to CIT):
 * 2009 {Iver T.I.}   {Task}
 */
- 
+
 package org.gvsig.gazetteer;
 
+import java.util.Map;
+
 import org.gvsig.gazetteer.drivers.IGazetteerServiceDriver;
 
 /**
  * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
  */
 public interface GazetteerManager {
-	
 	/**
-	 * It is used to retrieve a driver that supports a concrete 
+	 * It is used to retrieve a driver that supports a concrete
 	 * protocol
 	 * @param protocol
 	 * Gazetteer protocol
@@ -43,18 +44,39 @@
 	 * The concrete gazatteer service driver
 	 */
 	public IGazetteerServiceDriver getDriver(String protocol);
-	
+
 	/**
 	 * @return a list with all the gazetteer drivers
 	 */
 	public IGazetteerServiceDriver[] getDrivers();
-	
+
 	/**
-	 * This method is used to register a new gazetter driver 
+	 * This method is used to register a new gazetter driver
 	 * that manage a concrete protocol
 	 * @param driver
 	 * Gazetteer driver to register
 	 */
 	public void register(String name, Class driver);
+
+	/**
+	 * Returns username for a given protocol
+	 * @param protocol
+	 * @return
+	 */
+	public String getUsername(String protocol);
+
+	/**
+	 * Saves username for a given protocol
+	 * @param protocol
+	 * @param username
+	 */
+	public void setUsername(String protocol, String username);
+
+	/**
+	 * Receives Map with the saved usernames for the different protocols
+	 * @param usernames
+	 */
+	public void setUsernames(Map usernames);
+
 }
 
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/ui/serverconnect/ServerConnectDialogPanel.java
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/ui/serverconnect/ServerConnectDialogPanel.java	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/ui/serverconnect/ServerConnectDialogPanel.java	(revision 102)
@@ -48,7 +48,6 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
-import java.io.IOException;
 import java.net.URL;
 import java.util.Iterator;
 import java.util.TreeMap;
@@ -57,9 +56,6 @@
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
 import org.gvsig.catalog.utils.CatalogConstants;
 import org.gvsig.gazetteer.GazetteerClient;
@@ -69,6 +65,8 @@
 import org.gvsig.gazetteer.ui.search.SearchDialog;
 import org.gvsig.i18n.Messages;
 import org.gvsig.utils.swing.jcomboServer.ServerData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 
@@ -79,9 +77,9 @@
  * @author Jorge Piera Llodra (piera_jor@gva.es)
  */
 public class ServerConnectDialogPanel extends JPanel implements ActionListener {
-    
+
     private static Logger logger = LoggerFactory.getLogger(ServerConnectDialogPanel.class);
-    
+
 	private static final GazetteerManager gazetteerManager = GazetteerLocator.getGazetteerManager();
 	private static final long serialVersionUID = 7022169996238047820L;
 	private static TreeMap serverList = new TreeMap();
@@ -95,7 +93,7 @@
 
 	/**
 	 * Constructor
-	 * @param parent 
+	 * @param parent
 	 */
 	public  ServerConnectDialogPanel(JFrame parent) {
 		this.parent = parent;
@@ -111,7 +109,7 @@
 	        	controlsPanel.setProtocol(
 	        			controlsPanel.getServer().getServiceSubType());
 	        }
-	        
+
 		} else {
 		    String _msg = Messages.getText("_Unable_to_load_server_list");
 		    String _tit = Messages.getText("gazetteer_search");
@@ -121,60 +119,60 @@
 		        _tit,
 		        JOptionPane.ERROR_MESSAGE);
 		}
-	} 
+	}
 
 	/**
 	* @return the main panel
 	 */
-	public ServerConnectPanel getControlsPanel() {        
+	public ServerConnectPanel getControlsPanel() {
 		if (controlsPanel == null) {
 			controlsPanel = new ServerConnectPanel();
 			controlsPanel.addActionListener(this);
 			controlsPanel.enableSearchButton(false);
 		}
 		return controlsPanel;
-	} 
-	
+	}
+
 	/**
 	 * It adds a server in the TreeMap Object
-	 * @param server 
+	 * @param server
 	 */
-	protected static void addTreeMapServer(ServerData server) {        
+	protected static void addTreeMapServer(ServerData server) {
 		if (ServerConnectDialogPanel.serverList == null) {
 			ServerConnectDialogPanel.serverList = new TreeMap();
 		}
 		serverList.put(server.getServerAddress(), server);
-	} 
+	}
 
 	/**
 	 * This method loads a server list in the combo
-	 * @param sfile 
+	 * @param sfile
 	 */
-	private boolean loadServerList(String sfile) {        
+	private boolean loadServerList(String sfile) {
 		if (loadServersFromFile(sfile)) {
 	        Iterator iter = serverList.keySet().iterator();
 	        while (iter.hasNext()) {
 	            ServerData server = (ServerData) serverList.get((String) iter.next());
 	            controlsPanel.addServer(server);
-	        }    
+	        }
 	        return true;
 		}
 		return false;
-	} 
+	}
 
 	/**
 	 * It loads a server list from a text file
-	 * @param sfile 
+	 * @param sfile
 	 * File that contains the rervers
 	 */
-	private boolean loadServersFromFile(String sfile) {        
+	private boolean loadServersFromFile(String sfile) {
 		File file = null;
 		try {
 	          URL uf = getClass().getClassLoader().getResource(sfile);
 	          if (uf == null) {
                   throw new FileNotFoundException(file.getAbsolutePath());
 	          }
-	                
+
 	          file = new File(uf.getFile());
 			if (file.exists()) {
 				BufferedReader fr = new BufferedReader(new FileReader(file));
@@ -188,13 +186,13 @@
 		    logger.info("While reading gazetteer servers list file: " + e.getMessage());
 		}
 		return false;
-	} 
-	
+	}
+
 	/*
 	 * (non-Javadoc)
 	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 	 */
-	public void actionPerformed(ActionEvent e) {        
+	public void actionPerformed(ActionEvent e) {
 		if (e.getActionCommand().compareTo(CatalogConstants.CONNECT_BUTTON_ACTION_COMMAND)==0) {
 			connectButtonActionPerformed();
 		}else if (e.getActionCommand().compareTo(CatalogConstants.SEARCH_BUTTON_ACTION_COMMAND)==0) {
@@ -206,7 +204,7 @@
 		        isUpdating = true;
 		        controlsPanel.updateServerByProtocol();
 		        isUpdating = false;
-		    }	
+		    }
 		}else if (e.getActionCommand().compareTo(CatalogConstants.SERVER_COMBO_ACTION_COMMAND)==0) {
 		    if (!isUpdating){
 		        isUpdating = true;
@@ -214,21 +212,26 @@
 		        isUpdating = false;
 		    }
 		}
-	} 
+	}
 
 	/**
 	 * Action when the search button is clicked
 	 */
-	protected void searchButtonActionPerformed() {        
+	protected void searchButtonActionPerformed() {
 		setEnabled(false);
 		new SearchDialog(client,parent);
-	} 
+	}
 
 	/**
 	 * It is thrown the the connect button is clicked
 	 */
-	protected void connectButtonActionPerformed() {        
-		controlsPanel.enableSearchButton(false);		
+	protected void connectButtonActionPerformed() {
+		controlsPanel.enableSearchButton(false);
+		IGazetteerServiceDriver driver = (IGazetteerServiceDriver)controlsPanel.getDriver();
+		if( driver.needsUsername(driver.getServiceName()) ) {
+		    String username=requestUsername(driver.getUsername());
+		    driver.setUsername(username);
+		}
 		//Create a new Gazetteer client
 		client = new GazetteerClient(controlsPanel.getServerAddress(),
 				(IGazetteerServiceDriver)controlsPanel.getDriver());
@@ -237,60 +240,69 @@
 		}
 		connectThread = new ConnectThread();
 		setCursor(new Cursor(Cursor.WAIT_CURSOR));
-	} 
+	}
 
+	private String requestUsername (String oldUsername){
+	    String strRequireUserName = Messages.getText("_Insert_Geonames_username");
+	    String newUsername = JOptionPane.showInputDialog(strRequireUserName,oldUsername);
+	    if ( newUsername==null ){
+	        return oldUsername;
+	    }
+	    return newUsername;
+	}
+
 	/**
 	 *  * It is thrown the the close button is clicked
 	 */
-	protected void closeButtonActionPerformed() {        
+	protected void closeButtonActionPerformed() {
 		parent.setVisible(false);
 		System.exit(0);
-	} 
+	}
 
 	/**
 	 * @return Returns the serversFile.
 	 */
-	public String getServersFile() {        
+	public String getServersFile() {
 		return serversFile;
-	} 
+	}
 
 	/**
 	 * @param serversFile The serversFile to set.
 	 */
-	public void setServersFile(String serversFile) {        
+	public void setServersFile(String serversFile) {
 		this.serversFile = serversFile;
-	} 
+	}
 
 	/**
 	 * @return Returns the currentServer.
 	 */
-	public String getCurrentServer() {        
+	public String getCurrentServer() {
 		return currentServer;
-	} 
+	}
 
 	/**
 	 * @return Returns the client.
 	 */
-	public GazetteerClient getCliente() {        
+	public GazetteerClient getCliente() {
 		return client;
-	} 
-	
+	}
+
 	/**
 	 * This class is used to manage the searches.
 	 * It contains method to start and to stop a thread. It is
 	 * necessary to create because "stop" method (for the Thread class)
 	 * is deprecated.
-	 * 
-	 * 
+	 *
+	 *
 	 * @author Jorge Piera Llodra (piera_jor@gva.es)
 	 */
 	private class ConnectThread implements Runnable {
 		volatile Thread myThread = null;
 
-		public  ConnectThread() {        
+		public  ConnectThread() {
 			myThread = new Thread(this);
 			myThread.start();
-		} 
+		}
 
 		public void stop(){
 			myThread.stop();
@@ -299,20 +311,20 @@
 		 * (non-Javadoc)
 		 * @see java.lang.Runnable#run()
 		 */
-		public void run() {        
+		public void run() {
 			try {
 				DiscoveryServiceCapabilities capabilities = client.getCapabilities();
 				if (capabilities.isAvailable()){
 					controlsPanel.enableSearchButton(true);
 					currentServer = controlsPanel.getServerAddress();
 					searchButtonActionPerformed();
-				}	
-				setCursor(new Cursor(Cursor.DEFAULT_CURSOR));   
-				controlsPanel.setServerReply(capabilities.getServerMessage());				
+				}
+				setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+				controlsPanel.setServerReply(capabilities.getServerMessage());
 			} catch (Exception e) {
 				controlsPanel.setServerReply(Messages.getText(e.toString()));
 				e.printStackTrace();
-			}	
+			}
 		}
-	}	
+	}
 }
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/drivers/IGazetteerServiceDriver.java
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/drivers/IGazetteerServiceDriver.java	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/drivers/IGazetteerServiceDriver.java	(revision 102)
@@ -50,8 +50,8 @@
 /**
  * This interface contains the common methods that have to be
  * implemented by all the gazetteer drivers.
- * 
- * 
+ *
+ *
  * @author Jorge Piera Llodra (piera_jor@gva.es)
  */
 public interface IGazetteerServiceDriver extends IDiscoveryServiceDriver{
@@ -62,22 +62,22 @@
 	 * @return Array of the attributes of a feature
 	 */
 	public FeatureTypeAttribute[] describeFeatureType(URI uri, String featureType) throws Exception;
-	
+
 	/**
 	 * There are protocols that need to invoke the describeFeatureType
 	 * operation before to do a getFeature.
-	 * @return if the describeFeatureType operation is needed. 
+	 * @return if the describeFeatureType operation is needed.
 	 */
 	public boolean isDescribeFeatureTypeNeeded();
-	
+
 	/**
 	 * It returns the foubd records
 	 * @param uri Server URI
 	 * @param query Query with the search parameters
 	 * @return The features
-	 */	
+	 */
 	public Feature[] getFeature(URI uri, GazetteerQuery query) throws Exception;
-		
+
 	/**
 	 * @return the projection
 	 */
@@ -88,6 +88,23 @@
 	 */
 	public void setProjection(String projection);
 
+	/**
+	 * Indicates if the protocol requires a username
+	 * @param protocol
+	 * @return
+	 */
+	public boolean needsUsername(String protocol);
+
+	/**
+	 * Returns username for protocol
+	 * @return
+	 */
+	public String getUsername();
+
+	/**
+	 * Saves username for protocol
+	 */
+	public void setUsername(String username);
 }
 
 
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/drivers/AbstractGazetteerServiceDriver.java
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/drivers/AbstractGazetteerServiceDriver.java	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/drivers/AbstractGazetteerServiceDriver.java	(revision 102)
@@ -44,6 +44,7 @@
 
 import org.gvsig.catalog.drivers.AbstractDiscoveryServiceDriver;
 import org.gvsig.catalog.querys.DiscoveryServiceQuery;
+import org.gvsig.gazetteer.GazetteerLocator;
 import org.gvsig.gazetteer.querys.FeatureType;
 import org.gvsig.gazetteer.querys.FeatureTypeAttribute;
 import org.gvsig.gazetteer.querys.GazetteerQuery;
@@ -51,27 +52,27 @@
 
 /**
  * This class must be inherited by all the gazetteer drivers. It contains
- * the common attributes. 
+ * the common attributes.
  * @author Jorge Piera Llodra (piera_jor@gva.es)
  */
 public abstract class AbstractGazetteerServiceDriver extends AbstractDiscoveryServiceDriver implements IGazetteerServiceDriver {
 	private FeatureType[] featureTypes;
 	private GazetteerQuery query;
-	private String projection = null;	
+	private String projection = null;
 
 	/**
 	 * @return Returns the feature.
 	 */
-	public FeatureType[] getFeatureTypes() {        
+	public FeatureType[] getFeatureTypes() {
 		return featureTypes;
-	} 
+	}
 
 	/**
 	 * @param feature The feature to set.
 	 */
-	public void setFeatureTypes(FeatureType[] featureTypes) {        
+	public void setFeatureTypes(FeatureType[] featureTypes) {
 		this.featureTypes = featureTypes;
-	} 	
+	}
 
 	/*
 	 * (non-Javadoc)
@@ -80,41 +81,41 @@
 	public DiscoveryServiceQuery createQuery(){
 		return new GazetteerQuery();
 	}
-	
+
 	/**
 	 * @return Returns the query.
 	 */
-	public GazetteerQuery getQuery() {        
+	public GazetteerQuery getQuery() {
 		return query;
-	} 
+	}
 
 	/**
 	 * @param query The query to set.
 	 */
-	public void setQuery(GazetteerQuery query) {        
+	public void setQuery(GazetteerQuery query) {
 		this.query = query;
-	}	
+	}
 
 	/*
 	 * (non-Javadoc)
 	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#describeFeatureType(java.net.URI, java.lang.String)
 	 */
-	public FeatureTypeAttribute[] describeFeatureType(URI uri, String feature) {        
+	public FeatureTypeAttribute[] describeFeatureType(URI uri, String feature) {
 		return null;
-	} 	
+	}
 
 	/*
 	 * (non-Javadoc)
 	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#isDescribeFeatureTypeNeeded()
 	 */
-	public boolean isDescribeFeatureTypeNeeded()  {        
+	public boolean isDescribeFeatureTypeNeeded()  {
 		return false;
-	} 
+	}
 
 	/*
 	 * (non-Javadoc)
 	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getProjection()
-	 */	 
+	 */
 	public String getProjection(){
 		return projection;
 	}
@@ -126,4 +127,17 @@
 	public void setProjection(String projection){
 		this.projection = projection;
 	}
+
+    public boolean needsUsername(String protocol) {
+        return false;
+    }
+
+    public String getUsername() {
+        return GazetteerLocator.getGazetteerManager().getUsername(this.getServiceName());
+    }
+
+    public void setUsername(String username) {
+        GazetteerLocator.getGazetteerManager().setUsername(this.getServiceName(),username);
+
+    }
 }
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/geonames/GeonamesServiceDriver.java
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/geonames/GeonamesServiceDriver.java	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/geonames/GeonamesServiceDriver.java	(revision 102)
@@ -2,22 +2,22 @@
  *
  * Copyright (C) 2007-2008 Infrastructures and Transports Department
  * of the Valencian Government (CIT)
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
- * 
+ *
  */
 
 /*
@@ -46,11 +46,11 @@
 
 
 public class GeonamesServiceDriver extends AbstractGazetteerServiceDriver {
-	
-	
+
+
 	public GeonamesServiceDriver() {
 		super();
-		setProjection("EPSG:4326");		
+		setProjection("EPSG:4326");
 	}
 
 	/*
@@ -58,6 +58,7 @@
 	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URI, es.gva.cit.gazetteer.querys.GazetteerQuery)
 	 */
 	public Feature[] getFeature(URI uri, GazetteerQuery query) throws Exception {
+	    WebService.setUserName(getUsername());
 		ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
 		searchCriteria.setQ(query.getName());
 		ToponymSearchResult searchResult = WebService.search(searchCriteria);
@@ -70,11 +71,11 @@
 	}
 
 	private Feature converToponym(Toponym toponym) {
-		Feature feature = new Feature(toponym.getFeatureCode(), 
+		Feature feature = new Feature(toponym.getFeatureCode(),
 				toponym.getName(),
 				toponym.getName(),
 				new Point2D.Double(toponym.getLongitude(), toponym.getLatitude()));
-		
+
 		return feature;
 	}
 
@@ -103,6 +104,9 @@
 	public ServerData getOneServer() {
 		return new ServerData("www.geonames.org", "GEONAMES");
 	}
-	
-	
+
+    @Override
+    public boolean needsUsername(String protocol) {
+        return true;
+    }
 }
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/java/org/gvsig/gazetteer/GazetteerExtension.java
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/java/org/gvsig/gazetteer/GazetteerExtension.java	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/java/org/gvsig/gazetteer/GazetteerExtension.java	(revision 102)
@@ -43,14 +43,19 @@
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.gvsig.andami.IconThemeHelper;
 import org.gvsig.andami.PluginServices;
+import org.gvsig.andami.PluginsLocator;
+import org.gvsig.andami.PluginsManager;
 import org.gvsig.andami.persistence.serverData.ServerDataPersistence;
 import org.gvsig.andami.plugins.Extension;
 import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
 import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
 import org.gvsig.gazetteer.gui.ConnectDialog;
+import org.gvsig.tools.dynobject.DynObject;
 import org.gvsig.utils.swing.jcomboServer.ServerData;
 
 
@@ -58,9 +63,9 @@
  * @author Jorge Piera Llodra (piera_jor@gva.es)
  */
 public class GazetteerExtension extends Extension {
-	
+
 	public static void main(String[] args) {
-	    
+
 	}
 
 	public void initialize() {
@@ -72,7 +77,15 @@
 	}
 
 	public void postInitialize() {
-
+	    PluginsManager pluginsManager = PluginsLocator.getManager();
+	    PluginServices plugin=pluginsManager.getPlugin(this);
+	    DynObject config = plugin.getPluginProperties();
+	    Map usernames=(Map)config.getDynValue("usernames");
+	    if (usernames==null){
+	        usernames=new HashMap();
+	        config.setDynValue("usernames", usernames);
+	    }
+	    GazetteerLocator.getGazetteerManager().setUsernames(usernames);
 	}
 
 	public void execute(String actionCommand) {
@@ -124,7 +137,7 @@
 
 	/**
 	 * It creates a server list by default
-	 * 
+	 *
 	 * @return
 	 */
 	private ServerData[] getDefaultServers() {
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/java/org/gvsig/gazetteer/loaders/FeatureLoader.java
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/java/org/gvsig/gazetteer/loaders/FeatureLoader.java	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/java/org/gvsig/gazetteer/loaders/FeatureLoader.java	(revision 102)
@@ -77,35 +77,35 @@
 
 /**
  * This class is used to load a new feature like a layer in gvSIG
- * 
+ *
  * @author Jorge Piera Llodra (piera_jor@gva.es)
  */
-public class FeatureLoader {     
+public class FeatureLoader {
 	private static final Logger LOG =
         LoggerFactory.getLogger(FeatureLoader.class);
-	
+
     private static GeometryManager geometryManager = GeometryLocator.getGeometryManager();
 	private static MapContextManager mapContextManager = MapContextLocator.getMapContextManager();
-	
+
 	/**
 	 * Coordinates Transformer
 	 */
-	private ICoordTrans coordTrans;	
-	
+	private ICoordTrans coordTrans;
+
 	/**
 	 * @param projection
 	 * Server projection
 	 */
 	public FeatureLoader(String sProjection){
-		AbstractViewPanel activeView = 
+		AbstractViewPanel activeView =
 			(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
-		
-		
+
+
 		IProjection projection = CRSFactory.getCRS(sProjection);
 		if (projection == null){
 			projection = activeView.getMapControl().getViewPort().getProjection();
 		}
-		
+
 		coordTrans=  projection.getCT(activeView.getMapControl().getViewPort().getProjection());
 	}
 	/**
@@ -126,42 +126,42 @@
 
 		if (query.getOptions().getAspect().isGoTo()){
 			focusCenter(feature);
-		}        
+		}
 
 		return true;
-	}    
+	}
 
 	/**
-	 * This method focus the toponim in the center of the view 
+	 * This method focus the toponim in the center of the view
 	 * @param feature
 	 * Feature that contains the coordinates
 	 */
 	private void focusCenter(Feature feature){
-		AbstractViewPanel activeView = 
+		AbstractViewPanel activeView =
 			(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
 
 		IProjection projection = activeView.getProjection();
 		ViewPort viewPort = activeView.getMapControl().getViewPort();
 		MapContext mapContext = activeView.getMapControl().getMapContext();
 		Point2D point = getReprojectedPoint(feature.getCoordinates());
-				
+
 		if (viewPort.getAdjustedEnvelope() != null){
 			Toolkit kit = Toolkit.getDefaultToolkit();
 			double dpi = kit.getScreenResolution();
-			
+
 			Envelope envelope = viewPort.getAdjustedEnvelope();
 			Rectangle2D rectangle = new Rectangle2D.Double(envelope.getLowerCorner().getX(),
 					envelope.getLowerCorner().getY(),
 					envelope.getUpperCorner().getX() - envelope.getLowerCorner().getX(),
 					envelope.getUpperCorner().getY() - envelope.getLowerCorner().getY());
-			
+
 			Rectangle2D extent = projection.getExtent(rectangle,
 			        new Double(25000).doubleValue(),
 					new Double(viewPort.getImageWidth()).doubleValue(),
 					new Double(viewPort.getImageHeight()).doubleValue(),
 					viewPort.getMapUnits(),
 					viewPort.getDistanceUnits(),
-					dpi);				
+					dpi);
 			if (extent != null){
 				try {
 					envelope = geometryManager.createEnvelope(SUBTYPES.GEOM2D);
@@ -172,16 +172,16 @@
 							point.getY() + extent.getHeight()/2,
 							SUBTYPES.GEOM2D);
 					envelope.setLowerCorner(loweCorner);
-					envelope.setUpperCorner(upperCorner);				
+					envelope.setUpperCorner(upperCorner);
 					mapContext.zoomToEnvelope(envelope);
 				} catch (CreateEnvelopeException e) {
 				    LOG.error("Error creating the envelope", e);
 				} catch (CreateGeometryException e) {
 				    LOG.error("Error creating the envelope", e);
-				}			
+				}
 			}
-		}		
-	} 
+		}
+	}
 
 	/**
 	 * It adds a new Label to the current view
@@ -191,20 +191,20 @@
 	 * To remove or keep the old searches
 	 */
 	private void addAndDrawLabel(Feature feature,boolean isRemoveOldClicked,boolean isMarkedPlaceClicked){
-		AbstractViewPanel activeView = 
+		AbstractViewPanel activeView =
 			(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
 		MapContext mc = activeView.getMapControl().getMapContext();
 		GraphicLayer lyr = mc.getGraphicsLayer();
-		
+
 		if (isRemoveOldClicked){
 			lyr.clearAllGraphics();
-		}	
-		
+		}
+
 		if (isMarkedPlaceClicked){
 			int pointSymbol = lyr.addSymbol(getSymbol());
 			int textSymbol = lyr.addSymbol(getTextSymbol(feature.getName()));
-			
-				
+
+
 			Point2D point2d = getReprojectedPoint(feature.getCoordinates());
 			feature.setCoordinates(point2d);
 			Point point;
@@ -217,12 +217,12 @@
 				PluginServices.getMainFrame().enableControls();
 			} catch (CreateGeometryException e) {
 			    LOG.error("Error creating the point", e);
-			}			
-		}			
-		
+			}
+		}
+
 		mc.invalidate();
 	}
-	
+
 	/**
 	 * Creates a FSymbol
 	 * @return
@@ -239,7 +239,7 @@
 		theSymbol.setText(text);
 		return theSymbol;
 	}
-	
+
 	/**
 	 * Creates a FSymbol
 	 * @return
@@ -253,7 +253,7 @@
 		theSymbol.setSize(4);
 		return theSymbol;
 	}
-	
+
 	/**
 	 * Reprojects the new point
 	 * @param ptOrig
@@ -263,7 +263,11 @@
 	 */
 	private Point2D getReprojectedPoint(Point2D ptOrigin){
 		Point2D ptDest = null;
-		return getCoordTrans().convert(ptOrigin, ptDest);
+		ICoordTrans ct = getCoordTrans();
+		if(ct != null) {
+		    return ct.convert(ptOrigin, ptDest);
+		}
+		return ptOrigin;
 	}
 	/**
 	 * @return the coordTrans
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/resources-plugin/plugin-persistence.def
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/resources-plugin/plugin-persistence.def	(revision 0)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/resources-plugin/plugin-persistence.def	(revision 102)
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!--
+Definitions of plugin persistence org.gvsig.gazetteer.extension.
+ -->
+<definitions>
+  <version>1.0.0</version>
+  <classes>
+    <class name="org.gvsig.gazetteer.extension">
+      <description>Persistence for the gazetteer plugin</description>
+      <fields>
+        <field name="usernames" type="Map" classOfItems="java.lang.String" mandatory="false">
+          <description></description>
+        </field>
+      </fields>
+    </class>
+  </classes>
+</definitions>
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/resources-plugin/i18n/text.properties
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/resources-plugin/i18n/text.properties	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/resources-plugin/i18n/text.properties	(revision 102)
@@ -140,3 +140,4 @@
 wmsColumn=Mapa
 wmsError=Ha ocurrido un error al cargar el mapa
 _Unable_to_load_server_list=No se pudo cargar lista de servidores
+_Insert_Geonames_username=Inserte su nombre de usuario de Geonames.\nPuede obtenerlo en http://www.geonames.org/login
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/resources-plugin/i18n/text_en.properties
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/resources-plugin/i18n/text_en.properties	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/resources-plugin/i18n/text_en.properties	(revision 102)
@@ -137,3 +137,4 @@
 wmsColumn=Map
 wmsError=Map loading error
 _Unable_to_load_server_list=Unable to load server list
+_Insert_Geonames_username=Insert Geonames user name.\nYou can get it at http://www.geonames.org/login
Index: org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/pom.xml
===================================================================
--- org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/pom.xml	(revision 101)
+++ org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/pom.xml	(revision 102)
@@ -13,7 +13,7 @@
   <parent>
       <groupId>org.gvsig</groupId>
       <artifactId>org.gvsig.desktop</artifactId>
-      <version>2.0.107</version>
+      <version>2.0.109-SNAPSHOT</version>
   </parent>
 
   <url>https://devel.gvsig.org/redmine/projects/gvsig-gazetteer</url>
