// Chromis POS - The New Face of Open Source POS // Copyright (C) 2008-2009 // http://www.chromis.co.uk // // This file is part of Chromis POS // // Chromis POS 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 3 of the License, or // (at your option) any later version. // // Chromis POS 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 Chromis POS. If not, see <http://www.gnu.org/licenses/>. package uk.chromis.pos.payment; import javax.swing.JPanel; import uk.chromis.pos.forms.AppConfig; import uk.chromis.pos.forms.AppLocal; import uk.chromis.pos.util.AltEncrypter; /** * * @author Mikel Irurita */ public class ConfigPaymentPanelCaixa extends javax.swing.JPanel implements PaymentConfiguration { /** Creates new form ConfigPaymentPanelCaixa */ public ConfigPaymentPanelCaixa() { initComponents(); } @Override public JPanel getComponent() { return this; } @Override public void loadProperties() { String sCommerceID = AppConfig.getInstance().getProperty("payment.commerceid"); String sCommerceTerminal = AppConfig.getInstance().getProperty("payment.terminal"); String sCommerceSign = AppConfig.getInstance().getProperty("payment.commercesign"); String sCommerceSHA = AppConfig.getInstance().getProperty("payment.SHA"); if (sCommerceID!=null && sCommerceTerminal!=null && sCommerceSign!=null && sCommerceSHA!=null && sCommerceSign.startsWith("crypt:")) { jtxtCommerceCode.setText(AppConfig.getInstance().getProperty("payment.commerceid")); AltEncrypter cypher = new AltEncrypter("cypherkey"); jtxtCommerceTerminal.setText(comboValue(AppConfig.getInstance().getProperty("payment.terminal"))); jtxtCommerceSign.setText(cypher.decrypt(AppConfig.getInstance().getProperty("payment.commercesign").substring(6))); jCheckBox1.setSelected(AppConfig.getInstance().getBoolean("payment.SHA")); } } @Override public void saveProperties() { AppConfig.getInstance().setProperty("payment.commerceid", comboValue(jtxtCommerceCode.getText())); AppConfig.getInstance().setProperty("payment.terminal", comboValue(jtxtCommerceTerminal.getText())); AltEncrypter cypher = new AltEncrypter("cypherkey"); AppConfig.getInstance().setProperty("payment.commercesign", "crypt:" + cypher.encrypt(new String(jtxtCommerceSign.getPassword()))); AppConfig.getInstance().setProperty("payment.SHA", comboValue(jCheckBox1.isSelected())); } private String comboValue(Object value) { return value == null ? "" : value.toString(); } /** 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() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jtxtCommerceCode = new javax.swing.JTextField(); jtxtCommerceSign = new javax.swing.JPasswordField(); jtxtCommerceTerminal = new javax.swing.JTextField(); jCheckBox1 = new eu.hansolo.custom.SteelCheckBox(); jLabel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel1.setText(AppLocal.getIntString("label.merchantcode")); // NOI18N jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel2.setText(AppLocal.getIntString("label.terminal")); // NOI18N jLabel2.setPreferredSize(new java.awt.Dimension(100, 30)); jLabel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel3.setText(AppLocal.getIntString("label.commercesign")); // NOI18N jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); jLabel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel4.setText(AppLocal.getIntString("label.sha")); // NOI18N jLabel4.setPreferredSize(new java.awt.Dimension(100, 30)); jtxtCommerceCode.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jtxtCommerceCode.setPreferredSize(new java.awt.Dimension(200, 30)); jtxtCommerceSign.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jtxtCommerceSign.setPreferredSize(new java.awt.Dimension(200, 30)); jtxtCommerceTerminal.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jtxtCommerceTerminal.setPreferredSize(new java.awt.Dimension(200, 30)); jCheckBox1.setText("Ampliado"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jtxtCommerceCode, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtCommerceSign, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jtxtCommerceTerminal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(72, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtCommerceCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(6, 6, 6) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtCommerceTerminal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtxtCommerceSign, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(14, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private eu.hansolo.custom.SteelCheckBox jCheckBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JTextField jtxtCommerceCode; private javax.swing.JPasswordField jtxtCommerceSign; private javax.swing.JTextField jtxtCommerceTerminal; // End of variables declaration//GEN-END:variables }