Examples of CixFile


Examples of realcix20.cixfiles.CIXFile

    public ObjectPlugin(Window window, File file) {
       
            this.window = window;           
            this.file = file;
           
            CIXFile cixFile = new CIXFile();
            try {
                cixFile.importFile(file);
                this.cixFile = cixFile;
                analyType();
            } catch (Exception e) {
                DialogManager.showMessageDialog(window, TxtManager.getTxt("PARTNER.IMPORT.NOTVAILDFILE"));
                e.printStackTrace();               
View Full Code Here

Examples of realcix20.cixfiles.CIXFile

                        while (rowIter.hasNext()) {
                            Row childRow = (Row)rowIter.next();                           
                            Cell cCell = findCell(childRow, "PA", "PA");
                            if ( (childRow != getRow()) && (cCell.getColumnValue().equals(pCell.getColumnValue())) ) {
                                CIXFileData data = new CIXFileData(type, getPrivateKey(), childRow);
                                CIXFile cixFile = new CIXFile(getPublicKey(), data);   
                                Random random = new Random();
                                String fileName = "confirm_add_account_" + random.nextInt(25000);
                                cixFile.exportFile(fileName);          
                                String str = TxtManager.getTxt("PARTNER.IMPORT.ADDPARTNER");
                                str = str.replaceAll("%", fileName);
                                DialogManager.showMessageDialog(getWindow(), str);
                                break;
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                   
                } else if ( (cell != null) && (cell.getColumnValue().equals("ME")) ) {
                   
                    try {
                        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
                        keyGen.initialize(1024);
                        KeyPair key = keyGen.generateKeyPair();
                       
                        Iterator rowIter = getRow().getRowSet().getRows().iterator();
                        while (rowIter.hasNext()) {
                            Row childRow = (Row)rowIter.next();
                            if (childRow != getRow()) {
                                Cell publicKeyCell = findCell(childRow, "PA", "PUBKEY");
                                Cell privateKeyCell = findCell(childRow, "PA", "PRIKEY");
                                publicKeyCell.setColumnValue(key.getPublic());
                                privateKeyCell.setColumnValue(key.getPrivate());   
                            }
                        }                                          
                       
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                   
                }

            } else if (action.equals("Confirm Add Account Request")) {                              
               
                Cell cell = findCell(getRow(), "P", "NS");
                if ( (cell != null) && (!cell.getColumnValue().equals("ME")) ) {
                   
                    try {                       
                        Iterator rowIter = getRow().getRowSet().getRows().iterator();
                        while (rowIter.hasNext()) {
                            Row childRow = (Row)rowIter.next();
                            if (childRow != getRow()) {
                                Cell publicKeyCell = findCell(childRow, "PA", "PUBKEY");
                                publicKeyCell.setColumnValue(getCixFile().getPublicKey());
                            }
                        }
                       
                        String type = "Re Confirm Add Account";
                        rowIter = getRow().getRowSet().getRows().iterator();                                               
                        Cell pCell = findCell(getRow(), "P", "DEFPA");
                        while (rowIter.hasNext()) {
                            Row childRow = (Row)rowIter.next();                           
                            Cell cCell = findCell(childRow, "PA", "PA");
                            if ( (childRow != getRow()) && (cCell.getColumnValue().equals(pCell.getColumnValue())) ) {
                                CIXFileData data = new CIXFileData(type, getPrivateKey(), childRow);
                                CIXFile cixFile = new CIXFile(getPublicKey(), data);   
                                Random random = new Random();
                                String fileName = "re_confirm_add_account_"+ random.nextInt(25000);                               
                                cixFile.exportFile(fileName);
                                String str = TxtManager.getTxt("PARTNER.IMPORT.CONFIRMADDPARTNER");
                                str = str.replaceAll("%", fileName);
                                DialogManager.showMessageDialog(getWindow(), str);
                               
                                this.cixFile.getData().setType("Used");
                                this.cixFile.exportFile("used_" + getFile().getName().substring(0, getFile().getName().length() - 2));
                                file.delete();
                                break;
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                   
                }
               
            } else if (action.equals("Re Confirm Add Account")) {
               
                MainView container = (MainView)window;
               
                JTree tree = container.getTree();
               
                Row tRow = cixFile.getData().getRow(cixFile.getPublicKey());
                Cell cell1 = findCell(tRow, "P", "NS");
                Cell cell2 = findCell(tRow, "P", "P");
                Cell cell3 = findCell(tRow, "P", "URNS");
                Cell cell4 = findCell(tRow, "P", "URP");
               
                for (int i = 1; i <= tree.getRowCount(); i++) {
                                                        
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getPathForRow(i).getLastPathComponent();
                    if (node != null) {
                        ObjectInfo oj = (ObjectInfo)node.getUserObject();
                        //It's partner class
                        if ( (oj.flag.equals("object")) && (oj.clsId == 250) ) {                           
                            tree.setSelectionPath(tree.getPathForRow(i));
                            //This will be updated
                            Iterator rowIter = container.getCurrentObject().getRows().iterator();
                            boolean findRow = false;
                            while (rowIter.hasNext()) {
                               
                                Row cRow = (Row)rowIter.next();        
                                Cell ccell1 = findCell(cRow, "P", "NS");
                                Cell ccell2 = findCell(cRow, "P", "P");   
                               
                                if ( (ccell1.getColumnValue().equals(cell3.getColumnValue())) && (ccell2.getColumnValue().equals(cell4.getColumnValue())) ) {                                   
                                   
                                    findRow = true;
                                    Iterator childRowIter = cRow.getRowSet().getRows().iterator();
                                    while (childRowIter.hasNext()) {
                                        Row childRow = (Row)childRowIter.next();
                                        childRow.setModify(true);
                                        Cell ccell3 = findCell(childRow, "P", "URNS");
                                        Cell ccell4 = findCell(childRow, "P", "URP");
                                        Cell publicKeyCell = findCell(childRow, "PA", "PUBKEY");
                                        ccell3.setColumnValue(cell1.getColumnValue());
                                        ccell4.setColumnValue(cell2.getColumnValue());
                                        publicKeyCell.setColumnValue(cixFile.getPublicKey());                                   
                                    }
                                   
                                    container.getCurrentObject().classUpdate_WholeObject(cRow, false);
                                    break;
                                   
View Full Code Here

Examples of realcix20.classes.plugins.CixFile

                Vector data = new Vector();
           
                Cell urtCell = ObjectUtil.findNewCell(mainRow, "T", "URT");
                String urt = (String)urtCell.getColumnValue();
                if ( (urt == null) || (urt.trim().equals("")) ) {                   
                    CixFile file = generateCixFile_Stat4(mainRow);
                    String fileName = generateCixFileName(mainRow, 4);
                    data.add(file);
                    data.add(fileName);
                } else {
                    CixFile file = generateCixFile_Stat5(mainRow);
                    String fileName = generateCixFileName(mainRow, 5);
                    data.add(file);
                    data.add(fileName);
                    registerTransfer(mainRow, null);
                }         
View Full Code Here

Examples of realcix20.classes.plugins.CixFile

           
        }
       
        private CixFile generateCixFile_Stat4(Row mainRow) {
           
                CixFile file = null;
               
                int cixFileStat = 4;
                Vector noEncryData = new Vector();
                byte[] wrappedKey = null;
                Vector encryData = new Vector();
                SealedObject sealedEncryData = null;
               
                Cell nsCell = ObjectUtil.findNewCell(mainRow, "T", "NS");
                String ns = (String)nsCell.getColumnValue();
                Cell pCell = ObjectUtil.findNewCell(mainRow, "T", "P");
                String p = (String)pCell.getColumnValue();
                Cell paCell = ObjectUtil.findNewCell(mainRow, "T", "PA");
                String pa = (String)paCell.getColumnValue();
               
                String urns = null;
                String urp = null;
                DAO dao = DAO.getInstance();
                dao.query(Resources.SELECT_URNS_URP_FORM_P_SQL);
                dao.setObject(1, ns);
                dao.setObject(2, p);
                ResultSet rs = dao.executeQuery();
                try {
                    if (rs.next()) {
                        urns = rs.getString("URNS");
                        urp = rs.getString("URP");
                    }
                    rs.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
               
                String urpa = null;
                dao.query(Resources.SELECT_URPA_FROM_PA_SQL);
                dao.setObject(1, ns);
                dao.setObject(2, p);
                dao.setObject(3, pa);
                rs = dao.executeQuery();
                try {
                    if (rs.next()) {
                        urpa = rs.getString("URPA");
                    }
                    rs.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
               
                noEncryData.add(urns);
                noEncryData.add(urp);
                noEncryData.add(urpa);
               
                encryData.add(mainRow);
               
                PrivateKey priKey = getPriKey(ns, p, pa);
                try {
                    KeyGenerator keyGen = KeyGenerator.getInstance("DES");
                    SecureRandom random = new SecureRandom();
                    keyGen.init(random);
                    SecretKey key = keyGen.generateKey();
                    Cipher cipher = Cipher.getInstance("DES");
                    cipher.init(Cipher.ENCRYPT_MODE,key);
                    sealedEncryData = new SealedObject(encryData, cipher);                      
                    cipher = Cipher.getInstance("RSA");
                    cipher.init(Cipher.WRAP_MODE, priKey);
                    wrappedKey = cipher.wrap(key);
                } catch (Exception e) {
                    e.printStackTrace();
                }
               
                file = new CixFile(cixFileStat, noEncryData, null, wrappedKey, sealedEncryData);
               
                return file;
           
        }
View Full Code Here

Examples of realcix20.classes.plugins.CixFile

           
        }
       
        private CixFile generateCixFile_Stat5(Row mainRow) {
               
                CixFile file = null;
               
               
               
                return file;
           
View Full Code Here

Examples of realcix20.classes.plugins.CixFile

       
        private Vector dealWithPacc(Row mainRow) {
               
                Vector data = null;
           
                CixFile file = null;
           
                Cell urnsCell = ObjectUtil.findNewCell(mainRow, "P", "URNS");
                Cell urpCell = ObjectUtil.findNewCell(mainRow, "P", "URP");
               
                String stat = "Create New Partner";//other is 'Receive An Invite'
View Full Code Here

Examples of realcix20.classes.plugins.CixFile

           
        }
       
        private CixFile dealWithPacc_stat_1(Row mainRow) {
           
                CixFile file = null;
               
                int cixFileStat = 1;
                Vector noEncryData = new Vector();
                PublicKey pubKey = null;
                byte[] wrappedKey = null;
                PrivateKey priKey = null;
                Vector encryData = new Vector();
                SealedObject sealedEncryData = null;
                //use the first account's keypair to encry the data;
                Iterator childRowsIter = mainRow.getRowSet().getRows().iterator();
                int currentRow = 0;
                Vector pubKeys = new Vector();
                Vector pas = new Vector();
                while (childRowsIter.hasNext()) {
                    Row childRow = (Row)childRowsIter.next();
                    if (!childRow.isDelete()) {
                        Cell ruserCell = ObjectUtil.findNewCell(childRow, "PA", "RUSER");
                        Cell ruserPaCell = ObjectUtil.findNewCell(childRow, "PA", "RUSERPA");
                       
                        if ( (ruserCell.getColumnValue() != null) && (ruserPaCell.getColumnValue() != null) ) {
                            currentRow++;
                            DAO dao = DAO.getInstance();
                            dao.query(Resources.SELECT_PUBKEY_PRIKEY_FROM_PA_SQL);
                            dao.setObject(1, "ME");
                            dao.setObject(2, ruserCell.getColumnValue());
                            dao.setObject(3, ruserPaCell.getColumnValue());
                            ResultSet rs = dao.executeQuery();
                            try {
                                if (rs.next()) {
                                    if (currentRow == 1) {
                                        pubKey = (PublicKey)rs.getObject("PUBKEY");
                                        priKey = (PrivateKey)rs.getObject("PRIKEY");
                                    }
                                    Cell paCell = ObjectUtil.findNewCell(childRow, "PA", "PA");
                                    pas.add(paCell.getColumnValue());
                                    pubKeys.add(rs.getObject("PUBKEY"));
                                }
                                rs.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }                                               
                    }                       
                }
                encryData.add(mainRow);
                Vector pairData = new Vector();
                pairData.add(pubKeys);
                pairData.add(pas);                       
                encryData.add(pairData);
                try {
                    KeyGenerator keyGen = KeyGenerator.getInstance("DES");
                    SecureRandom random = new SecureRandom();
                    keyGen.init(random);
                    SecretKey key = keyGen.generateKey();
                    Cipher cipher = Cipher.getInstance("DES");
                    cipher.init(Cipher.ENCRYPT_MODE,key);
                    sealedEncryData = new SealedObject(encryData, cipher);                      
                    cipher = Cipher.getInstance("RSA");
                    cipher.init(Cipher.WRAP_MODE, priKey);
                    wrappedKey = cipher.wrap(key);
                } catch (Exception e) {
                    e.printStackTrace();
                }

                file = new CixFile(cixFileStat, noEncryData, pubKey, wrappedKey, sealedEncryData);
               
                return file;
           
        }
View Full Code Here

Examples of realcix20.classes.plugins.CixFile

           
        }
       
        private CixFile dealWithPacc_stat_2(Row mainRow) {
               
                CixFile file = null;
                int cixFileStat = 2;
                Vector noEncryData = new Vector();
                PublicKey pubKey = null;
                byte[] wrappedKey = null;
                PrivateKey priKey = null;
                Vector encryData = new Vector();
                SealedObject sealedEncryData = null;
               
                //use the first account's keypair to encry the data;
                Iterator childRowsIter = mainRow.getRowSet().getRows().iterator();
                int currentRow = 0;
                Vector pubKeys = new Vector();
                Vector urpas = new Vector();
                Vector pas = new Vector();
                while (childRowsIter.hasNext()) {
                    Row childRow = (Row)childRowsIter.next();
                    if (!childRow.isDelete()) {
                        Cell ruserCell = ObjectUtil.findNewCell(childRow, "PA", "RUSER");
                        Cell ruserPaCell = ObjectUtil.findNewCell(childRow, "PA", "RUSERPA");
                       
                        if ( (ruserCell.getColumnValue() != null) && (ruserPaCell.getColumnValue() != null) ) {
                            currentRow++;
                            DAO dao = DAO.getInstance();
                            dao.query(Resources.SELECT_PUBKEY_PRIKEY_FROM_PA_SQL);
                            dao.setObject(1, "ME");
                            dao.setObject(2, ruserCell.getColumnValue());
                            dao.setObject(3, ruserPaCell.getColumnValue());
                            ResultSet rs = dao.executeQuery();
                            try {
                                if (rs.next()) {
                                    if (currentRow == 1) {
                                        pubKey = (PublicKey)rs.getObject("PUBKEY");
                                        priKey = (PrivateKey)rs.getObject("PRIKEY");
                                    }
                                    Cell urpaCell = ObjectUtil.findNewCell(childRow, "PA", "URPA");
                                    Cell paCell = ObjectUtil.findNewCell(childRow, "PA", "PA");
                                    if ( (urpaCell.getColumnValue() != null) && (!((String)urpaCell.getColumnValue()).trim().equals("")) ) {
                                        pubKeys.add(rs.getObject("PUBKEY"));
                                        urpas.add(urpaCell.getColumnValue());
                                        pas.add(paCell.getColumnValue());
                                    }
                                }
                                rs.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }                                               
                    }                       
                }
                encryData.add(mainRow);
                Vector pairData = new Vector();
                pairData.add(pubKeys);
                pairData.add(pas);
                pairData.add(urpas);
                encryData.add(pairData);
                try {
                    KeyGenerator keyGen = KeyGenerator.getInstance("DES");
                    SecureRandom random = new SecureRandom();
                    keyGen.init(random);
                    SecretKey key = keyGen.generateKey();
                    Cipher cipher = Cipher.getInstance("DES");
                    cipher.init(Cipher.ENCRYPT_MODE,key);
                    sealedEncryData = new SealedObject(encryData, cipher);                      
                    cipher = Cipher.getInstance("RSA");
                    cipher.init(Cipher.WRAP_MODE, priKey);
                    wrappedKey = cipher.wrap(key);
                } catch (Exception e) {
                    e.printStackTrace();
                }

                file = new CixFile(cixFileStat, noEncryData, pubKey, wrappedKey, sealedEncryData);
               
                return file;
           
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.