/** * Obtiene el CN (common name) de la identidad digital que se utilizará por defecto. * @return String */ public String getIdentity() { try { String id = getNodeValue("IDENTIDAD_PRINCIPAL"); if ((id!=null)&&(id.endsWith("\\0"))) { String id1 = new String(id.substring(0, id.length()-2)).concat("\0"); return id1; } return id; } catch (Exception e) { logger.severe( "Error trying to get the tag IDENTIDAD_PRINCIPAL in the config file: " + e.getMessage()); JOptionPane.showMessageDialog(null, "Error trying to get the tag IDENTIDAD_PRINCIPAL in the config file", "FATAL ERROR", JOptionPane.ERROR_MESSAGE); System.exit( -1); } return null; } /** * Cambia la identidad digital por defecto a una especificada por el parámetro id. Esta identidad * también debe estar contenida en el fichero que las almacena * @param id String */ public void setIdentity(String id) { String new_ident=null; char [] c = {'\0'}; String endtag = new String(c); if (id.endsWith(endtag)) { new_ident = new String (id.substring(0,id.length()-1) ).concat("\\0"); } else { new_ident=id; } try { Node n = documentRoot.getElementsByTagName("IDENTIDAD_PRINCIPAL").item(0); Element item = documentRoot.createElement("IDENTIDAD_PRINCIPAL"); // Create element item.appendChild(documentRoot.createTextNode(new_ident)); Node n_root = documentRoot.getElementsByTagName("CONFIGURACION").item(0); n_root.replaceChild(item, n); AlmacenIdentidades.getInstance().reloadConfiguration(); } catch (Exception e) { logger.severe( "Error trying to set the tag IDENTIDAD_PRINCIPAL in the config file: " + e.getMessage()); JOptionPane.showMessageDialog(null, "Error trying to set the tag IDENTIDAD_PRINCIPAL in the config file", "FATAL ERROR", JOptionPane.ERROR_MESSAGE); System.exit( -1); } }