Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Formulario; import BD.Metodos_Rut; import BD.ConexionBD; import com.digitalpersona.onetouch.DPFPDataPurpose; import com.digitalpersona.onetouch.DPFPFeatureSet; import com.digitalpersona.onetouch.DPFPGlobal; import com.digitalpersona.onetouch.DPFPSample; import com.digitalpersona.onetouch.DPFPTemplate; import com.digitalpersona.onetouch.capture.DPFPCapture; import com.digitalpersona.onetouch.capture.event.DPFPDataAdapter; import com.digitalpersona.onetouch.capture.event.DPFPDataEvent; import com.digitalpersona.onetouch.capture.event.DPFPErrorAdapter; import com.digitalpersona.onetouch.capture.event.DPFPErrorEvent; import com.digitalpersona.onetouch.capture.event.DPFPReaderStatusAdapter; import com.digitalpersona.onetouch.capture.event.DPFPReaderStatusEvent; import com.digitalpersona.onetouch.capture.event.DPFPSensorAdapter; import com.digitalpersona.onetouch.capture.event.DPFPSensorEvent; import com.digitalpersona.onetouch.processing.DPFPEnrollment; import com.digitalpersona.onetouch.processing.DPFPFeatureExtraction; import com.digitalpersona.onetouch.processing.DPFPImageQualityException; import com.digitalpersona.onetouch.verification.DPFPVerification; import com.digitalpersona.onetouch.verification.DPFPVerificationResult; import com.jcraft.jsch.Channel; import java.awt.Image; import java.awt.event.FocusEvent; import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.lang.String; import java.net.InetAddress; import java.net.SocketException; import java.net.UnknownHostException; import javax.imageio.ImageIO; import static javax.print.attribute.standard.ReferenceUriSchemesSupported.FTP; import org.apache.commons.net.ftp.FTP; import static org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPReply; import org.apache.commons.net.ftp.FTPFile; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import com.jcraft.jsch.SftpException; import com.jcraft.jsch.UserInfo; import java.io.FileNotFoundException; import javax.swing.JFileChooser; /** * * @author alumno.desarrollo1 */ //Inicio de la clase principal public class CapturaHuella extends javax.swing.JFrame { FileInputStream fis; int longitudBytes; //Clase que se ejecuta al iniciar el programa public CapturaHuella() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Imposible modificar el tema visual", "Lookandfeel invlido.", JOptionPane.ERROR_MESSAGE); } initComponents(); //Carga los componentes del JPanel txtArea.setEditable(false); //agreagr logo y nombre en la barra superior setIconImage(new ImageIcon(getClass().getResource("/img/logoCrecic.jpg")).getImage()); setTitle("Crecic S.A"); } //Codigo generado por Netbeans //Aqui se encuentran lo botones, paneles y etiquetas /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { panHuellas = new javax.swing.JPanel(); lblImagenHuella = new javax.swing.JLabel(); panBtns = new javax.swing.JPanel(); btnGuardar = new javax.swing.JButton(); btnSalir = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); txtArea = new javax.swing.JTextArea(); jSeparator1 = new javax.swing.JSeparator(); jTextField1 = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); bt_buscar = new javax.swing.JButton(); btnConfiguracion = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } public void windowOpened(java.awt.event.WindowEvent evt) { formWindowOpened(evt); } }); panHuellas.setBackground(new java.awt.Color(214, 226, 249)); panHuellas.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Huella Digital", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 204))); // NOI18N javax.swing.GroupLayout panHuellasLayout = new javax.swing.GroupLayout(panHuellas); panHuellas.setLayout(panHuellasLayout); panHuellasLayout.setHorizontalGroup(panHuellasLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panHuellasLayout.createSequentialGroup() .addContainerGap(156, Short.MAX_VALUE).addComponent(lblImagenHuella, javax.swing.GroupLayout.PREFERRED_SIZE, 343, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(127, 127, 127))); panHuellasLayout .setVerticalGroup(panHuellasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panHuellasLayout.createSequentialGroup().addGap(27, 27, 27) .addComponent(lblImagenHuella, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(60, Short.MAX_VALUE))); panBtns.setBackground(new java.awt.Color(214, 226, 249)); btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/guardar_blanco.PNG"))); // NOI18N btnGuardar.setBorder(javax.swing.BorderFactory.createEtchedBorder()); btnGuardar.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/img/guardar_azul.png"))); // NOI18N btnGuardar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnGuardarActionPerformed(evt); } }); btnSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/salir2_blanco.PNG"))); // NOI18N btnSalir.setBorder(javax.swing.BorderFactory.createEtchedBorder()); btnSalir.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/img/salir2_azul.PNG"))); // NOI18N btnSalir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSalirActionPerformed(evt); } }); txtArea.setColumns(20); txtArea.setForeground(new java.awt.Color(0, 0, 204)); txtArea.setRows(5); jScrollPane1.setViewportView(txtArea); javax.swing.GroupLayout panBtnsLayout = new javax.swing.GroupLayout(panBtns); panBtns.setLayout(panBtnsLayout); panBtnsLayout.setHorizontalGroup(panBtnsLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panBtnsLayout.createSequentialGroup().addGap(36, 36, 36) .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 366, Short.MAX_VALUE) .addComponent(btnSalir).addGap(64, 64, 64)) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)); panBtnsLayout.setVerticalGroup(panBtnsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panBtnsLayout.createSequentialGroup().addGap(23, 23, 23) .addGroup(panBtnsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnGuardar).addComponent(btnSalir)) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jSeparator1.setForeground(new java.awt.Color(214, 226, 249)); jTextField1.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { jTextField1FocusLost(evt); } }); jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField1ActionPerformed(evt); } }); jTextField1.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jTextField1KeyTyped(evt); } }); jLabel1.setForeground(new java.awt.Color(0, 0, 204)); bt_buscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/busca_blanco.PNG"))); // NOI18N bt_buscar.setBorder(javax.swing.BorderFactory.createEtchedBorder()); bt_buscar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/img/busca_azul.PNG"))); // NOI18N bt_buscar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bt_buscarActionPerformed(evt); } }); btnConfiguracion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/llave_blanca.PNG"))); // NOI18N btnConfiguracion.setToolTipText(""); btnConfiguracion.setBorder(javax.swing.BorderFactory.createEtchedBorder()); btnConfiguracion.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/img/llave_azul.PNG"))); // NOI18N btnConfiguracion.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnConfiguracionActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(23, 23, 23) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(bt_buscar) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 335, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnConfiguracion)) .addGroup(layout.createSequentialGroup().addGap(10, 10, 10).addComponent(panBtns, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap()) .addComponent(panHuellas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jSeparator1)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnConfiguracion) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bt_buscar))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(panHuellas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(panBtns, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); pack(); }// </editor-fold>//GEN-END:initComponents //Boton Salir private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed // TODO add your handling code here: System.exit(0); }//GEN-LAST:event_btnSalirActionPerformed //Accion que se activa al ejecutar el programa private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened // TODO add your handling code here: Iniciar(); start(); //EstadoHuellas(); btnGuardar.setEnabled(false); btnSalir.grabFocus(); }//GEN-LAST:event_formWindowOpened //Accion que se ejecuta al salir del programa private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing // TODO add your handling code here: stop(); }//GEN-LAST:event_formWindowClosing //Boton Guardar private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed // TODO add your handling code here: String nom = jTextField1.getText(); //Toma lo que se rellena en el campo de texto guardarHuella(nom); //Activa la funcion guardarhuella, AUN NO TERMINADA!!!!!!! Reclutador.clear(); lblImagenHuella.setIcon(null); // start(); }//GEN-LAST:event_btnGuardarActionPerformed //Campo de texto private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed // TODO add your handling code here: String nom = jTextField1.getText(); consultap(nom); //Ejecuta la consulta en SQL Reclutador.clear(); }//GEN-LAST:event_jTextField1ActionPerformed //Accion de perder el foco del campo de texto private void jTextField1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusLost // TODO add your handling code here: }//GEN-LAST:event_jTextField1FocusLost //Restriccion del campo de texto, aun no implementada ya que lo que aparece en //comentario solo permite el uso de numeros, falta habilitar el caracter "." y "-" private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyTyped // TODO add your handling code here: /*String rut = String.valueOf(evt.getKeyChar()); if(!(rut.matches("[0-9_@]"))){ evt.consume(); getToolkit().beep(); } */ }//GEN-LAST:event_jTextField1KeyTyped private void bt_buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_buscarActionPerformed // TODO add your handling code here: Buscar_Usuarios uss = new Buscar_Usuarios(); uss.setVisible(true); this.stop(); this.setVisible(false); }//GEN-LAST:event_bt_buscarActionPerformed private void btnConfiguracionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfiguracionActionPerformed // TODO add your handling code here: stop(); int op = JOptionPane.showConfirmDialog(this, "No modifique estos parametros al menos que se requiera.\n" + "Desea configurar?", "Desea configurar?", JOptionPane.YES_NO_OPTION); if (op == JOptionPane.OK_OPTION) { // Ingreso in=new Ingreso(this, true); try { new Ingreso(this, true).setVisible(true); dispose(); } catch (Exception ex) { Logger.getLogger(CapturaHuella.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_btnConfiguracionActionPerformed public DPFPCapture Lector = DPFPGlobal.getCaptureFactory().createCapture(); private DPFPEnrollment Reclutador = DPFPGlobal.getEnrollmentFactory().createEnrollment(); private DPFPVerification Verificador = DPFPGlobal.getVerificationFactory().createVerification(); private DPFPTemplate template; private Session session; public BufferedImage Ejemplo; /** * @param args the command line arguments */ //Inicio de lectura de Huella, NO MODIFICAR public static String TEMPLATE_PROPERTY = "template"; protected void Iniciar() { Lector.addDataListener(new DPFPDataAdapter() { @Override public void dataAcquired(final DPFPDataEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { EnviarTexto("La Huella Digital ha sido Capturada"); ProcesarCaptura(e.getSample()); } }); } }); Lector.addReaderStatusListener(new DPFPReaderStatusAdapter() { @Override public void readerConnected(final DPFPReaderStatusEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { EnviarTexto("El Sensor de Huella Digital esta Activado o Conectado"); } }); } @Override public void readerDisconnected(final DPFPReaderStatusEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { EnviarTexto("El Sensor de Huella Digital esta Desactivado o no Conectado"); } }); } }); Lector.addSensorListener(new DPFPSensorAdapter() { @Override public void fingerTouched(final DPFPSensorEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { EnviarTexto("El dedo ha sido colocado sobre el Lector de Huella"); } }); } @Override public void fingerGone(final DPFPSensorEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { EnviarTexto("El dedo ha sido quitado del Lector de Huella"); } }); } }); Lector.addErrorListener(new DPFPErrorAdapter() { public void errorReader(final DPFPErrorEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { EnviarTexto("Error: " + e.getError()); } }); } }); } //Termino de proceso de captura de Huella public DPFPFeatureSet featuresinscripcion; public DPFPFeatureSet featuresverificacion; //Funcion que se ejecuta al poner el dedo en el lector public void ProcesarCaptura(DPFPSample sample) { //BufferedImage image = null; File f = null; // Procesar la muestra de la huella y crear un conjunto de caractersticas con el propsito de inscripcin. featuresinscripcion = extraerCaracteristicas(sample, DPFPDataPurpose.DATA_PURPOSE_ENROLLMENT); // Procesar la muestra de la huella y crear un conjunto de caractersticas con el propsito de verificacion. //featuresverificacion = extraerCaracteristicas(sample, DPFPDataPurpose.DATA_PURPOSE_VERIFICATION); // Comprobar la calidad de la muestra de la huella y lo aade a su reclutador si es bueno //System.out.println(featuresinscripcion); if (featuresinscripcion != null) { try { System.out.println("Las Caracteristicas de la Huella han sido creada"); Reclutador.addFeatures(featuresinscripcion);// Agregar las caracteristicas de la huella a la plantilla a crear // Dibuja la huella dactilar capturada. Image imagen = CrearImagenHuella(sample); //Dibuja Huella en el panel principal DibujarHuella(imagen); // Guarda la imagen de la huella en una ruta predeterminada String usuario = System.getProperty("user.name"); String ruta = "C:/Users/" + usuario + "/AppData/Local/Temp/"; f = new File(ruta + "imagen_huella.jpg"); ImageIO.write((RenderedImage) imagen, "jpg", f); System.out.println("Imagen Guardada"); fis = new FileInputStream(f); longitudBytes = (int) f.length(); // System.out.println("sample:"+sample); // System.out.println("file:"+f); // System.out.println("file input:"+fis); // System.out.println("lo :"+ longitudBytes); btnGuardar.setEnabled(true); } catch (DPFPImageQualityException ex) { System.err.println("Error: " + ex.getMessage()); } catch (Exception ex) { Logger.getLogger(CapturaHuella.class.getName()).log(Level.SEVERE, null, ex); } } } ConexionBD cn = new ConexionBD(); //Funcion Guardar Huella, AUN NO TERMINADA public void guardarHuella(String nom) { String rut = jTextField1.getText(); if (rut.isEmpty()) { EnviarTexto("No se ha ingresado el rut del usuario"); } else { try { Connection c = cn.conectar(); PreparedStatement buscar = c.prepareStatement( "select count(*) numero from municipalidad.foto_contribuyente where rut = ?"); String rut_form = Metodos_Rut.formatear(nom); buscar.setString(1, rut_form); ResultSet rs = buscar.executeQuery(); if (rs.next()) { Object numero = rs.getObject("numero"); int resultado = Integer.parseInt(numero.toString()); if (resultado == 0) { System.out.println("tienes que insertar"); PreparedStatement insertar = c.prepareStatement( "INSERT INTO municipalidad.foto_contribuyente(rut,pulgar_der) values(?,?)"); insertar.setString(1, rut_form); insertar.setBinaryStream(2, fis, longitudBytes); insertar.execute(); insertar.close(); JOptionPane.showMessageDialog(null, "Huella Guardada Correctamente"); } else { PreparedStatement guardarStmt = c.prepareStatement( " update municipalidad.foto_contribuyente set pulgar_der = ? where rut= ?"); guardarStmt.setBinaryStream(1, fis, longitudBytes); guardarStmt.setString(2, nom); //Ejecuta la sentencia guardarStmt.execute(); guardarStmt.close(); JOptionPane.showMessageDialog(null, "Huella Guardada Correctamente"); } } //SQL AQUI //PreparedStatement guardarStmt = c.prepareStatement("INSERT INTO somhue(huenombre, huehuella) values(?,?)");//AQUI SQL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //AQUI // PreparedStatement guardarStmt = c.prepareStatement("INSERT INTO municipalidad.foto_contribuyente(pulgar_der) values(?) WHERE rut=?"); // cn.desconectar(); btnGuardar.setEnabled(false); } catch (SQLException ex) { //Si ocurre un error lo indica en la consola System.err.println("Error al guardar los datos de la huella."); } finally { cn.desconectar(); } } } /** * Identifica a una persona registrada por medio de su huella digital */ //CONEXION STFP EMPIEZA AQUI,AUN NO TERMINADA !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! public void connect(String username, String password, String host, int port) throws JSchException, IllegalAccessException { if (this.session == null || !this.session.isConnected()) { JSch jsch = new JSch(); this.session = jsch.getSession(username, host, port); this.session.setPassword(password); // Parametro para no validar key de conexion. this.session.setConfig("StrictHostKeyChecking", "no"); this.session.connect(); } else { throw new IllegalAccessException("Sesion SFTP ya iniciada."); } } public final void addFile(String ftpPath, String filePath, String fileName) throws IllegalAccessException, IOException, SftpException, JSchException { if (this.session != null && this.session.isConnected()) { // Abrimos un canal SFTP. Es como abrir una consola. ChannelSftp channelSftp = (ChannelSftp) this.session.openChannel("sftp"); // Nos ubicamos en el directorio del FTP. channelSftp.cd(ftpPath); channelSftp.connect(); System.out.println(String.format("Creando archivo %s en el " + "directorio %s", fileName, ftpPath)); channelSftp.put(filePath, fileName); System.out.println("Archivo subido exitosamente"); channelSftp.exit(); channelSftp.disconnect(); } else { throw new IllegalAccessException("No existe sesion SFTP iniciada."); } } /** * Cierra la sesion SFTP. */ public final void disconnect() { this.session.disconnect(); } //CONEXION SFTP TERMINA AQUI!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //Funcion que extrae caracteristicas de la huella, //se usa para funciones como identificar o verificar una huella //No es necesaria para este caso, pero se mantiene en el codigo para evitar errores de compilacion public DPFPFeatureSet extraerCaracteristicas(DPFPSample sample, DPFPDataPurpose purpose) { DPFPFeatureExtraction extractor = DPFPGlobal.getFeatureExtractionFactory().createFeatureExtraction(); try { return extractor.createFeatureSet(sample, purpose); } catch (DPFPImageQualityException e) { return null; } } //Funcion Consulta del Rut que imprime el nombre asociado public void consultap(String nom) { Connection c = cn.conectar(); try { PreparedStatement verificarStmt = c.prepareStatement( "SELECT nombres ,apellido_paterno, apellido_materno FROM municipalidad.maestra_contribuyente WHERE rut=?"); String rut_form = Metodos_Rut.formatear(nom); verificarStmt.setString(1, rut_form); ResultSet rs = verificarStmt.executeQuery(); if (rs.next()) { String nombre = rs.getString("nombres"); String paterno = rs.getString("apellido_paterno"); String materno = rs.getString("apellido_materno"); //JOptionPane.showMessageDialog(null, "El Rut: " +nom+ " corresponde a: " +nombre+" " +paterno+" " +materno,"Verificacion de Rut", JOptionPane.INFORMATION_MESSAGE); jLabel1.setText("El Rut: " + Metodos_Rut.formatear(nom) + " corresponde a: " + nombre + " " + paterno + " " + materno); } else { if (Metodos_Rut.validarRut(nom) == false) { jLabel1.setText("El Rut ingresado no es valido."); } else { //JOptionPane.showMessageDialog(null, "El siguiente Rut: " +nom+ " no esta en la base de datos ","Verificacion de Rut", JOptionPane.ERROR_MESSAGE); jLabel1.setText("El Rut no existe en la base de datos."); } } rs.close(); } catch (SQLException e) { System.err.println(e.getMessage()); } //cn.desconectar(); } public Image CrearImagenHuella(DPFPSample sample) { return DPFPGlobal.getSampleConversionFactory().createImage(sample); } public void DibujarHuella(Image image) { lblImagenHuella.setIcon(new ImageIcon(image.getScaledInstance(lblImagenHuella.getWidth(), lblImagenHuella.getHeight(), Image.SCALE_DEFAULT))); repaint(); } //Funcion que imprime el estado de la huella, no es importante /*public void EstadoHuellas(){ EnviarTexto("Muestra de Huellas Necesarias para Guardar Template "+ Reclutador.getFeaturesNeeded()); }*/ // De aqui en adelante solo hay funciones que vienen por descarte en el codigo, no deben ser modificadas public void EnviarTexto(String string) { txtArea.append(string + "\n"); } public void start() { Lector.startCapture(); EnviarTexto("Utilizando el Lector de Huella Dactilar "); } public void stop() { Lector.stopCapture(); EnviarTexto("No se est usando el Lector de Huella Dactilar "); } public DPFPTemplate getTemplate() { return template; } public void setTemplate(DPFPTemplate template) { DPFPTemplate old = this.template; this.template = template; firePropertyChange(TEMPLATE_PROPERTY, old, template); } public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(CapturaHuella.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(CapturaHuella.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(CapturaHuella.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(CapturaHuella.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new CapturaHuella().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton bt_buscar; private javax.swing.JButton btnConfiguracion; private javax.swing.JButton btnGuardar; private javax.swing.JButton btnSalir; private javax.swing.JLabel jLabel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator1; public javax.swing.JTextField jTextField1; private javax.swing.JLabel lblImagenHuella; private javax.swing.JPanel panBtns; private javax.swing.JPanel panHuellas; private javax.swing.JTextArea txtArea; // End of variables declaration//GEN-END:variables private void focusLost() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }