Example usage for java.math BigInteger toString

List of usage examples for java.math BigInteger toString

Introduction

In this page you can find the example usage for java.math BigInteger toString.

Prototype

public String toString(int radix) 

Source Link

Document

Returns the String representation of this BigInteger in the given radix.

Usage

From source file:com.netscape.ca.CertificateAuthority.java

public String getStartSerial() {
    try {//  w  w w.  j  a  v a 2 s  . c om
        BigInteger serial = mCertRepot.getTheSerialNumber();

        if (serial == null)
            return "";
        else
            return serial.toString(16);
    } catch (EBaseException e) {
        // shouldn't get here.
        return "";
    }
}

From source file:org.signserver.admin.gui.MainView.java

private void authEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_authEditButtonActionPerformed
    final int row = authTable.getSelectedRow();
    if (row != -1) {

        final String serialNumberBefore = (String) authTable.getValueAt(row, 0);
        final String issuerDNBefore = (String) authTable.getValueAt(row, 1);

        editSerialNumberTextfield.setText(serialNumberBefore);
        editSerialNumberTextfield.setEditable(true);
        editIssuerDNTextfield.setText(issuerDNBefore);
        editIssuerDNTextfield.setEditable(true);
        editUpdateAllCheckbox.setSelected(false);

        final int res = JOptionPane.showConfirmDialog(getFrame(), authEditPanel, "Edit authorized client",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
        if (res == JOptionPane.OK_OPTION) {
            try {
                List<Worker> workers;
                if (editUpdateAllCheckbox.isSelected()) {
                    workers = selectedWorkers;
                } else {
                    workers = Collections.singletonList(selectedWorker);
                }/*from   w  w  w  .ja v a  2s.c  o  m*/

                if (LOG.isDebugEnabled()) {
                    LOG.debug("Selected workers: " + workers);
                }

                final AuthorizedClient oldAuthorizedClient = new AuthorizedClient();
                oldAuthorizedClient.setCertSN(serialNumberBefore);
                oldAuthorizedClient.setIssuerDN(issuerDNBefore);

                final AuthorizedClient client = new AuthorizedClient();
                final BigInteger sn = new BigInteger(editSerialNumberTextfield.getText(), 16);

                client.setCertSN(sn.toString(16));
                client.setIssuerDN(
                        org.cesecore.util.CertTools.stringToBCDNString(editIssuerDNTextfield.getText()));

                for (Worker worker : workers) {
                    try {
                        boolean removed = SignServerAdminGUIApplication.getAdminWS()
                                .removeAuthorizedClient(worker.getWorkerId(), oldAuthorizedClient);
                        if (removed) {
                            SignServerAdminGUIApplication.getAdminWS().addAuthorizedClient(worker.getWorkerId(),
                                    client);
                            SignServerAdminGUIApplication.getAdminWS()
                                    .reloadConfiguration(worker.getWorkerId());
                        }
                    } catch (AdminNotAuthorizedException_Exception ex) {
                        showAdminNotAuthorized(ex);
                    } catch (SOAPFaultException ex) {
                        showServerSideException(ex);
                    } catch (EJBException ex) {
                        showServerSideException(ex);
                    }
                }
                refreshButton.doClick();
            } catch (NumberFormatException e) {
                showMalformedSerialNumber(e);
            }
        }
    }
}

From source file:org.signserver.admin.gui.MainView.java

private void authAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_authAddButtonActionPerformed
    editSerialNumberTextfield.setText("");
    editSerialNumberTextfield.setEditable(true);
    editIssuerDNTextfield.setText("");
    editIssuerDNTextfield.setEditable(true);
    editUpdateAllCheckbox.setSelected(false);

    final int res = JOptionPane.showConfirmDialog(getFrame(), authEditPanel, "Add authorized client",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (res == JOptionPane.OK_OPTION) {
        List<Worker> workers;
        if (editUpdateAllCheckbox.isSelected()) {
            workers = selectedWorkers;//from   w w  w .  j  a  v a  2  s .  c  o  m
        } else {
            workers = Collections.singletonList(selectedWorker);
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("Selected workers: " + workers);
        }

        for (Worker worker : workers) {
            try {
                final BigInteger sn = new BigInteger(editSerialNumberTextfield.getText(), 16);
                org.signserver.admin.gui.adminws.gen.AuthorizedClient client = new org.signserver.admin.gui.adminws.gen.AuthorizedClient();
                client.setCertSN(sn.toString(16));
                client.setIssuerDN(
                        org.cesecore.util.CertTools.stringToBCDNString(editIssuerDNTextfield.getText()));
                SignServerAdminGUIApplication.getAdminWS().addAuthorizedClient(worker.getWorkerId(), client);
                SignServerAdminGUIApplication.getAdminWS().reloadConfiguration(worker.getWorkerId());
            } catch (AdminNotAuthorizedException_Exception ex) {
                showAdminNotAuthorized(ex);
            } catch (NumberFormatException ex) {
                showMalformedSerialNumber(ex);
            } catch (SOAPFaultException ex) {
                showServerSideException(ex);
            } catch (EJBException ex) {
                showServerSideException(ex);
            }
        }
        refreshButton.doClick();
    }
}

From source file:org.cesecore.certificates.ocsp.OcspResponseGeneratorSessionBean.java

/**
 * This method takes byte array and translates it onto a OCSPReq class.
 * //w w w  .  j ava 2 s .  c  o  m
 * @param request the byte array in question.
 * @param remoteAddress The remote address of the HttpRequest associated with this array.
 * @param transactionLogger A transaction logger.
 * @return
 * @throws MalformedRequestException
 * @throws SignRequestException thrown if an unsigned request was processed when system configuration requires that all requests be signed.
 * @throws CertificateException
 * @throws NoSuchAlgorithmException
 * @throws SignRequestSignatureException
 */
private OCSPReq translateRequestFromByteArray(byte[] request, String remoteAddress,
        TransactionLogger transactionLogger) throws MalformedRequestException, SignRequestException,
        SignRequestSignatureException, CertificateException, NoSuchAlgorithmException {
    final OCSPReq ocspRequest;
    try {
        ocspRequest = new OCSPReq(request);
    } catch (IOException e) {
        throw new MalformedRequestException("Could not form OCSP request", e);
    }
    if (ocspRequest.getRequestorName() == null) {
        if (log.isDebugEnabled()) {
            log.debug("Requestor name is null");
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Requestor name is: " + ocspRequest.getRequestorName().toString());
        }
        if (transactionLogger.isEnabled()) {
            transactionLogger.paramPut(TransactionLogger.REQ_NAME, ocspRequest.getRequestorName().toString());
        }
    }

    /**
     * check the signature if contained in request. if the request does not contain a signature and the servlet is configured in the way the a
     * signature is required we send back 'sigRequired' response.
     */
    if (log.isDebugEnabled()) {
        log.debug("Incoming OCSP request is signed : " + ocspRequest.isSigned());
    }
    if (ocspRequest.isSigned()) {
        final X509Certificate signercert = checkRequestSignature(remoteAddress, ocspRequest);
        final String signercertIssuerName = CertTools.getIssuerDN(signercert);
        final BigInteger signercertSerNo = CertTools.getSerialNumber(signercert);
        final String signercertSubjectName = CertTools.getSubjectDN(signercert);
        if (transactionLogger.isEnabled()) {
            transactionLogger.paramPut(TransactionLogger.SIGN_ISSUER_NAME_DN, signercertIssuerName);
            transactionLogger.paramPut(TransactionLogger.SIGN_SERIAL_NO,
                    signercert.getSerialNumber().toByteArray());
            transactionLogger.paramPut(TransactionLogger.SIGN_SUBJECT_NAME, signercertSubjectName);
            transactionLogger.paramPut(PatternLogger.REPLY_TIME, TransactionLogger.REPLY_TIME);
        }
        // Check if we have configured request verification using the old property file way..
        boolean enforceRequestSigning = OcspConfiguration.getEnforceRequestSigning();
        // Next, check if there is an OcspKeyBinding where signing is required and configured for this request
        // In the case where multiple requests are bundled together they all must be trusting the signer
        for (final Req req : ocspRequest.getRequestList()) {
            OcspSigningCacheEntry ocspSigningCacheEntry = OcspSigningCache.INSTANCE.getEntry(req.getCertID());
            if (ocspSigningCacheEntry == null) {
                if (log.isTraceEnabled()) {
                    log.trace("Using default responder to check signature.");
                }
                ocspSigningCacheEntry = OcspSigningCache.INSTANCE.getDefaultEntry();
            }
            if (ocspSigningCacheEntry != null
                    && ocspSigningCacheEntry.isUsingSeparateOcspSigningCertificate()) {
                if (log.isTraceEnabled()) {
                    log.trace("ocspSigningCacheEntry.isUsingSeparateOcspSigningCertificate: "
                            + ocspSigningCacheEntry.isUsingSeparateOcspSigningCertificate());
                }
                final OcspKeyBinding ocspKeyBinding = ocspSigningCacheEntry.getOcspKeyBinding();
                if (log.isTraceEnabled()) {
                    log.trace("OcspKeyBinding " + ocspKeyBinding.getId() + ", RequireTrustedSignature: "
                            + ocspKeyBinding.getRequireTrustedSignature());
                }
                if (ocspKeyBinding.getRequireTrustedSignature()) {
                    enforceRequestSigning = true;
                    boolean isTrusted = false;
                    final List<InternalKeyBindingTrustEntry> trustedCertificateReferences = ocspKeyBinding
                            .getTrustedCertificateReferences();
                    if (trustedCertificateReferences.isEmpty()) {
                        // We trust ANY cert from a known CA
                        isTrusted = true;
                    } else {
                        for (final InternalKeyBindingTrustEntry trustEntry : trustedCertificateReferences) {
                            final int trustedCaId = trustEntry.getCaId();
                            final BigInteger trustedSerialNumber = trustEntry.fetchCertificateSerialNumber();
                            if (log.isTraceEnabled()) {
                                log.trace("Processing trustedCaId=" + trustedCaId + " trustedSerialNumber="
                                        + trustedSerialNumber + " signercertIssuerName.hashCode()="
                                        + signercertIssuerName.hashCode() + " signercertSerNo="
                                        + signercertSerNo);
                            }
                            if (trustedCaId == signercertIssuerName.hashCode()) {
                                if (trustedSerialNumber == null) {
                                    // We trust any certificate from this CA
                                    isTrusted = true;
                                    if (log.isTraceEnabled()) {
                                        log.trace(
                                                "Trusting request signature since ANY certificate from issuer "
                                                        + trustedCaId + " is trusted.");
                                    }
                                    break;
                                } else if (signercertSerNo.equals(trustedSerialNumber)) {
                                    // We trust this particular certificate from this CA
                                    isTrusted = true;
                                    if (log.isTraceEnabled()) {
                                        log.trace(
                                                "Trusting request signature since certificate with serialnumber "
                                                        + trustedSerialNumber + " from issuer " + trustedCaId
                                                        + " is trusted.");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    if (!isTrusted) {
                        final String infoMsg = intres.getLocalizedMessage("ocsp.infosigner.notallowed",
                                signercertSubjectName, signercertIssuerName, signercertSerNo.toString(16));
                        log.info(infoMsg);
                        throw new SignRequestSignatureException(infoMsg);
                    }
                }
            }
        }
        if (enforceRequestSigning) {
            // If it verifies OK, check if it is revoked
            final CertificateStatus status = certificateStoreSession.getStatus(signercertIssuerName,
                    signercertSerNo);
            /*
             * If rci == null it means the certificate does not exist in database, we then treat it as ok, because it may be so that only revoked
             * certificates is in the (external) OCSP database.
             */
            if (status.equals(CertificateStatus.REVOKED)) {
                String serno = signercertSerNo.toString(16);
                String infoMsg = intres.getLocalizedMessage("ocsp.infosigner.revoked", signercertSubjectName,
                        signercertIssuerName, serno);
                log.info(infoMsg);
                throw new SignRequestSignatureException(infoMsg);
            }
        }
    } else {
        if (OcspConfiguration.getEnforceRequestSigning()) {
            // Signature required
            throw new SignRequestException("Signature required");
        }
        // Next, check if there is an OcspKeyBinding where signing is required and configured for this request
        // In the case where multiple requests are bundled together they all must be trusting the signer
        for (final Req req : ocspRequest.getRequestList()) {
            OcspSigningCacheEntry ocspSigningCacheEntry = OcspSigningCache.INSTANCE.getEntry(req.getCertID());
            if (ocspSigningCacheEntry == null) {
                ocspSigningCacheEntry = OcspSigningCache.INSTANCE.getDefaultEntry();
            }
            if (ocspSigningCacheEntry != null
                    && ocspSigningCacheEntry.isUsingSeparateOcspSigningCertificate()) {
                final OcspKeyBinding ocspKeyBinding = ocspSigningCacheEntry.getOcspKeyBinding();
                if (ocspKeyBinding.getRequireTrustedSignature()) {
                    throw new SignRequestException("Signature required");
                }
            }
        }
    }
    return ocspRequest;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jRefreshAddressTranslateTableButtonActionPerformed(ActionEvent evt) {
    AddressTranslateTableModel model = (AddressTranslateTableModel) this.jAddressTranslateTable2.getModel();
    for (int x = 0; x < model.getRowCount(); x++) {
        if (model.searchType.get(x).equals(1)) {
            model.segNo.set(x, model.searchSegSelector.get(x).shiftRight(3));
            model.virtualAddress.set(x, model.searchAddress.get(x));

            BigInteger gdtBase = PeterBochsCommonLib.getPhysicalAddress(
                    CommonLib.string2BigInteger(this.registerPanel.jCR3TextField.getText()),
                    CommonLib.string2BigInteger(this.registerPanel.jGDTRTextField.getText()));
            commandReceiver.clearBuffer();
            gdtBase = gdtBase.add(model.segNo.get(x).multiply(BigInteger.valueOf(8)));
            sendCommand("xp /8bx " + gdtBase);
            String result = commandReceiver.getCommandResult(String.format("%08x", gdtBase));

            int bytes[] = new int[8];
            String[] b = result.replaceFirst("^.*:", "").split("\t");
            for (int y = 1; y <= 8; y++) {
                bytes[y - 1] = (int) CommonLib.string2long(b[y]);
            }// w  w w .ja v  a 2 s.  com

            Long gdtDescriptor = CommonLib.getLong(bytes, 0);
            System.out.println(Long.toHexString(gdtDescriptor));
            BigInteger base = CommonLib.getBigInteger(bytes[2], bytes[3], bytes[4], bytes[7], 0, 0, 0, 0);
            System.out.println(base.toString(16));

            model.linearAddress.set(x, base.add(model.searchAddress.get(x)));
        }
    }
    model.fireTableDataChanged();
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jELFLinearBreakpointMenuItemActionPerformed(ActionEvent evt) {
    SourceCodeTableModel model = (SourceCodeTableModel) elfTable.getModel();
    BigInteger address = model.getDebugLineInfo().get(model.getCurrentFile())
            .get(this.elfTable.getSelectedRow());
    if (address != null) {
        sendCommand("lb 0x" + address.toString(16));

        model.updateBreakpoint(getRealEIP());
        this.updateBreakpoint();
    }//w  w  w. ja  va 2s  . co  m
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jELFPhysicalBreakpointMenuItemActionPerformed(ActionEvent evt) {
    SourceCodeTableModel model = (SourceCodeTableModel) elfTable.getModel();
    BigInteger address = model.getDebugLineInfo().get(model.getCurrentFile())
            .get(this.elfTable.getSelectedRow());
    if (address != null) {
        sendCommand("pb 0x" + address.toString(16));

        model.updateBreakpoint(getRealEIP());
        this.updateBreakpoint();
    }// w w  w.  j av  a2  s  .c  o m
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void updateInstructionUsingBochs(BigInteger address) {
    try {/*from w w w  .  j a va  2s .c  o m*/
        final int maximumLine = 400;
        String command;
        jStatusLabel.setText("Updating instruction");
        if (address == null) {
            BigInteger cs = CommonLib.string2BigInteger(this.registerPanel.jCSTextField.getText());
            BigInteger eip = CommonLib.string2BigInteger(this.registerPanel.eipTextField.getText());
            eip = eip.and(CommonLib.string2BigInteger("0xffffffffffffffff"));
            command = "disasm cs:0x" + eip.toString(16) + " 0x" + cs.toString(16) + ":0x"
                    + eip.add(BigInteger.valueOf(0x400)).toString(16);
        } else {
            command = "disasm " + address + " " + address.add(BigInteger.valueOf(0x400));
        }
        commandReceiver.clearBuffer();
        commandReceiver.shouldShow = false;
        sendCommand(command);
        commandReceiver.waitUntilHaveLine(30);
        String result = commandReceiver.getCommandResultUntilEnd();
        String lines[] = result.split("\n");
        if (lines.length > 0) {
            InstructionTableModel model = (InstructionTableModel) instructionTable.getModel();
            jStatusProgressBar.setMaximum(lines.length - 1);
            for (int x = 0; x < lines.length && x < maximumLine; x++) {
                jStatusProgressBar.setValue(x);
                try {
                    lines[x] = lines[x].replaceFirst("\\<.*\\>", "");
                    String strs[] = lines[x].split(":");
                    int secondColon = lines[x].indexOf(":", lines[x].indexOf(":") + 1);

                    // load cCode
                    String pcStr = strs[0].trim();
                    BigInteger pc = CommonLib.string2BigInteger("0x" + pcStr);
                    if (pc == null) {
                        continue;
                    }
                    String s[] = getCCode(pc, false);
                    String lineNo[] = getCCode(pc, true);
                    if (s != null && lineNo != null) {
                        for (int index = 0; index < s.length; index++) {
                            model.addRow(new String[] { "",
                                    "cCode : 0x" + pc.toString(16) + " : " + lineNo[index], s[index], "" });
                        }
                    }
                    // end load cCode
                    model.addRow(new String[] { "", "0x" + pc.toString(16),
                            lines[x].substring(secondColon + 1).trim().split(";")[0].trim(),
                            lines[x].split(";")[1] });
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }

            model.removeNonOrderInstruction();
            model.fireTableDataChanged();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

public void updatePageTable(BigInteger pageDirectoryBaseAddress) {
    Vector<IA32PageDirectory> ia32_pageDirectories = new Vector<IA32PageDirectory>();
    try {//from w w w  .j  a  v a  2 s  . co  m
        commandReceiver.clearBuffer();
        commandReceiver.shouldShow = false;
        jStatusLabel.setText("Updating page table");
        // commandReceiver.setCommandNoOfLine(512);
        sendCommand("xp /4096bx " + pageDirectoryBaseAddress);
        float totalByte2 = 4096 - 1;
        totalByte2 = totalByte2 / 8;
        int totalByte3 = (int) Math.floor(totalByte2);
        String realEndAddressStr;
        String realStartAddressStr;
        BigInteger realStartAddress = pageDirectoryBaseAddress;
        realStartAddressStr = realStartAddress.toString(16);
        BigInteger realEndAddress = realStartAddress.add(BigInteger.valueOf(totalByte3 * 8));
        realEndAddressStr = String.format("%08x", realEndAddress);
        String result = commandReceiver.getCommandResult(realStartAddressStr, realEndAddressStr, null);
        if (result != null) {
            String[] lines = result.split("\n");
            DefaultTableModel model = (DefaultTableModel) jPageDirectoryTable.getModel();
            while (model.getRowCount() > 0) {
                model.removeRow(0);
            }
            jStatusProgressBar.setMaximum(lines.length - 1);

            for (int y = 0; y < lines.length; y++) {
                jStatusProgressBar.setValue(y);
                String[] b = lines[y].replaceFirst("^.*:", "").trim().split("\t");

                for (int z = 0; z < 2; z++) {
                    try {
                        int bytes[] = new int[4];
                        for (int x = 0; x < 4; x++) {
                            bytes[x] = CommonLib.string2BigInteger(b[x + z * 4].substring(2).trim()).intValue();
                        }
                        long value = CommonLib.getInt(bytes, 0);
                        // "No.", "PT base", "AVL", "G",
                        // "D", "A", "PCD", "PWT",
                        // "U/S", "W/R", "P"

                        long baseL = value & 0xfffff000;
                        // if (baseL != 0) {
                        String base = "0x" + Long.toHexString(baseL);
                        String avl = String.valueOf((value >> 9) & 3);
                        String g = String.valueOf((value >> 8) & 1);
                        String d = String.valueOf((value >> 6) & 1);
                        String a = String.valueOf((value >> 5) & 1);
                        String pcd = String.valueOf((value >> 4) & 1);
                        String pwt = String.valueOf((value >> 3) & 1);
                        String us = String.valueOf((value >> 2) & 1);
                        String wr = String.valueOf((value >> 1) & 1);
                        String p = String.valueOf((value >> 0) & 1);

                        ia32_pageDirectories
                                .add(new IA32PageDirectory(base, avl, g, d, a, pcd, pwt, us, wr, p));

                        model.addRow(new String[] { String.valueOf(y * 2 + z), base, avl, g, d, a, pcd, pwt, us,
                                wr, p });
                        // }
                    } catch (Exception ex) {
                    }
                }
                jStatusLabel.setText("Updating page table " + (y + 1) + "/" + lines.length);
            }
            jPageDirectoryTable.setModel(model);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    /*
     * if (false && Global.debug &&
     * jAutoRefreshPageTableGraphCheckBox.isSelected()) {
     * System.out.println("aa"); GraphModel model = new DefaultGraphModel();
     * GraphLayoutCache view = new GraphLayoutCache(model, new
     * DefaultCellViewFactory() { public CellView createView(GraphModel
     * model, Object cell) { CellView view = null; if (model.isPort(cell)) {
     * view = new PortView(cell); } else if (model.isEdge(cell)) { view =
     * new EdgeView(cell); } else { if (cell instanceof IA32PageDirectory) {
     * view = new PageDirectoryView(cell); } else if (cell instanceof
     * IA32PageTable) { view = new JButtonView(cell, 1); } else { view = new
     * VertexView(cell); } } return view; } }); JGraph graph = new
     * JGraph(model, view);
     * 
     * // add cells
     * 
     * // DefaultGraphCell[] cells = new //
     * DefaultGraphCell[ia32_pageDirectories.size() + 1];
     * Vector<DefaultGraphCell> cells = new Vector<DefaultGraphCell>();
     * DefaultGraphCell root = new DefaultGraphCell("cr3 " +
     * jRegisterPanel1.jCR3TextField.getText());
     * GraphConstants.setGradientColor(root.getAttributes(), Color.red);
     * GraphConstants.setOpaque(root.getAttributes(), true);
     * GraphConstants.setBounds(root.getAttributes(), new
     * Rectangle2D.Double(0, 0, 140, 20)); root.add(new DefaultPort());
     * cells.add(root);
     * 
     * Vector<IA32PageDirectory> pageDirectoryCells = new
     * Vector<IA32PageDirectory>(); for (int x = 0; x <
     * ia32_pageDirectories.size(); x++) { IA32PageDirectory cell =
     * ia32_pageDirectories.get(x);
     * GraphConstants.setGradientColor(cell.getAttributes(), Color.orange);
     * GraphConstants.setOpaque(cell.getAttributes(), true);
     * GraphConstants.setBounds(cell.getAttributes(), new
     * Rectangle2D.Double(0, x * 20, 140, 20)); cell.add(new DefaultPort());
     * pageDirectoryCells.add(cell);
     * 
     * // page table String pageTableAddress =
     * ia32_pageDirectories.get(x).base; sendCommand("xp /4096bx " +
     * pageTableAddress);
     * 
     * float totalByte2 = 4096 - 1; totalByte2 = totalByte2 / 8; int
     * totalByte3 = (int) Math.floor(totalByte2); String realEndAddressStr;
     * String realStartAddressStr; String baseAddress = pageTableAddress;
     * long realStartAddress = CommonLib.string2BigInteger(baseAddress);
     * 
     * realStartAddressStr = String.format("%08x", realStartAddress); long
     * realEndAddress = realStartAddress + totalByte3 * 8; realEndAddressStr
     * = String.format("%08x", realEndAddress);
     * 
     * String result = commandReceiver.getCommandResult(realStartAddressStr,
     * realEndAddressStr); String[] lines = result.split("\n");
     * 
     * Vector<DefaultGraphCell> pageTables = new Vector<DefaultGraphCell>();
     * for (int y = 1; y < 4; y++) { String[] b =
     * lines[y].replaceFirst("         cell.add(new DefaultPort());^.*:",
     * "").trim().split("\t");
     * 
     * for (int z = 0; z < 2; z++) { try { int bytes[] = new int[4]; for
     * (int x2 = 0; x2 < 4; x2++) { bytes[x2] =
     * CommonLib.string2BigInteger(b[x2 + z *
     * 4].substring(2).trim()).intValue(); } long value =
     * CommonLib.getInt(bytes, 0);
     * 
     * String base = Long.toHexString(value & 0xfffff000); String avl =
     * String.valueOf((value >> 9) & 3); String g = String.valueOf((value >>
     * 8) & 1); String d = String.valueOf((value >> 6) & 1); String a =
     * String.valueOf((value >> 5) & 1); String pcd = String.valueOf((value
     * >> 4) & 1); String pwt = String.valueOf((value >> 3) & 1); String us
     * = String.valueOf((value >> 2) & 1); String wr = String.valueOf((value
     * >> 1) & 1); String p = String.valueOf((value >> 0) & 1);
     * IA32PageTable pageTableCell = new IA32PageTable(base, avl, g, d, a,
     * pcd, pwt, us, wr, p);
     * GraphConstants.setGradientColor(pageTableCell.getAttributes(),
     * Color.orange);
     * GraphConstants.setOpaque(pageTableCell.getAttributes(), true);
     * GraphConstants.setBounds(pageTableCell.getAttributes(), new
     * Rectangle2D.Double(0, (z + y) * 20, 140, 20)); pageTableCell.add(new
     * DefaultPort()); pageTables.add(pageTableCell); } catch (Exception ex)
     * { } } }
     * 
     * // group it and link it DefaultGraphCell pt[] =
     * pageTables.toArray(new DefaultGraphCell[] {}); DefaultGraphCell
     * vertex1 = new DefaultGraphCell(new String("page table" + x), null,
     * pt); vertex1.add(new DefaultPort()); cells.add(vertex1);
     * 
     * DefaultEdge edge = new DefaultEdge();
     * edge.setSource(cell.getChildAt(0));
     * edge.setTarget(vertex1.getLastChild());
     * 
     * GraphConstants.setLineStyle(edge.getAttributes(),
     * GraphConstants.STYLE_ORTHOGONAL);
     * GraphConstants.setRouting(edge.getAttributes(),
     * GraphConstants.ROUTING_DEFAULT); int arrow =
     * GraphConstants.ARROW_CLASSIC;
     * GraphConstants.setLineEnd(edge.getAttributes(), arrow);
     * GraphConstants.setEndFill(edge.getAttributes(), true);
     * 
     * cells.add(edge); }
     * 
     * if (pageDirectoryCells.toArray().length > 0) { IA32PageDirectory pt[]
     * = pageDirectoryCells.toArray(new IA32PageDirectory[] {});
     * DefaultGraphCell vertex1 = new DefaultGraphCell(new
     * String("Vertex1"), null, pt); vertex1.add(new DefaultPort());
     * cells.add(vertex1);
     * 
     * DefaultEdge edge = new DefaultEdge();
     * edge.setSource(root.getChildAt(0));
     * edge.setTarget(vertex1.getLastChild()); int arrow =
     * GraphConstants.ARROW_CLASSIC;
     * GraphConstants.setLineEnd(edge.getAttributes(), arrow);
     * GraphConstants.setEndFill(edge.getAttributes(), true);
     * 
     * // lastObj = cells[index]; cells.add(edge); }
     * 
     * graph.getGraphLayoutCache().insert(cells.toArray());
     * graph.setDisconnectable(false);
     * 
     * JGraphFacade facade = new JGraphFacade(graph); JGraphLayout layout =
     * new JGraphTreeLayout(); ((JGraphTreeLayout)
     * layout).setOrientation(SwingConstants.WEST); //
     * ((JGraphHierarchicalLayout) layout).setNodeDistance(100);
     * layout.run(facade); Map nested = facade.createNestedMap(true, true);
     * graph.getGraphLayoutCache().edit(nested);
     * 
     * // JGraphFacade facade = new JGraphFacade(graph); // JGraphLayout
     * layout = new JGraphFastOrganicLayout(); // layout.run(facade); // Map
     * nested = facade.createNestedMap(true, true); //
     * graph.getGraphLayoutCache().edit(nested);
     * 
     * jPageTableGraphPanel.removeAll(); jPageTableGraphPanel.add(new
     * JScrollPane(graph), BorderLayout.CENTER); }
     */

}