private void jbtnAddUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAddUserActionPerformed
        String fullName = jFullName.getText().trim();
        String orgnName = (String) jOrgnCombo.getSelectedItem();
        String attributes = jAttributes.getText().trim();
        int accessKeysChoice = jAccessRightCombo.getSelectedIndex();

        if (fullName.isEmpty() || orgnName.isEmpty() || attributes.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Please fill up all fields.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        // create a secret key for user
        Cpabe phr = new Cpabe();
        String baseKeyDownloadPath = System.getProperty("user.home") + File.separator + "Desktop" + File.separator;
        String readKeyDownloadPath = baseKeyDownloadPath+fullName.replaceAll(" ", "_") + "_read.key";
        String writeKeyDownloadPath = baseKeyDownloadPath+fullName.replaceAll(" ", "_") + "_write.key";
        System.out.println("read key path:"+readKeyDownloadPath);

        try {
            System.out.println("choice:"+accessKeysChoice);
            switch (accessKeysChoice) {
                case 0:
                    phr.keygen(KeyConfig.getInstance().getPatientReadPublicKeyPath(), readKeyDownloadPath, KeyConfig.getInstance().getPatientReadMasterKeyPath(), attributes);
                    break;
                case 1:
                    phr.keygen(KeyConfig.getInstance().getPatientWritePublicKeyPath(), writeKeyDownloadPath, KeyConfig.getInstance().getPatientWriteMasterKeyPath(), attributes);
                    break;
                case 2:
                    phr.keygen(KeyConfig.getInstance().getPatientReadPublicKeyPath(), readKeyDownloadPath, KeyConfig.getInstance().getPatientReadMasterKeyPath(), attributes);
                    phr.keygen(KeyConfig.getInstance().getPatientWritePublicKeyPath(), writeKeyDownloadPath, KeyConfig.getInstance().getPatientWriteMasterKeyPath(), attributes);
                    break;
                default:
                    JOptionPane.showMessageDialog(null, "No such option available", "Error", JOptionPane.ERROR_MESSAGE);
                    return;

            }
            //update database
            String readSecretKeyChecksum = CryptoUtil.getFileChecksum(readKeyDownloadPath, "SHA1");
            String writeSecretKeyChecksum = CryptoUtil.getFileChecksum(writeKeyDownloadPath, "SHA1");
            int orgnId = orgnMap.get(orgnName);
            DatabaseClient.getInstance().addUser(fullName, orgnId, attributes, readSecretKeyChecksum,writeSecretKeyChecksum);
            JOptionPane.showMessageDialog(null, "User added successfully. Secret key(s) for user is created at following path:" + baseKeyDownloadPath);
            
            //clean up
            jFullName.setText("");
            jAttributes.setText("");

        } catch (Exception ex) {
            Logger.getLogger(AddUser.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, "Ops! Something went wrong.", "Error", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_jbtnAddUserActionPerformed