Package java.lang

Examples of java.lang.String$ConsolePrintStream


  /**
   * Copy to file action.
   */
  private void copyToFileButton_actionPerformed(ActionEvent e)
  {
    String filename = CBUtility.chooseFileToSave(this, "Please specify a location to save this certificate",
        new String[] {"der"}, "Certificate file (*.der)");
    if (filename == null) return;

    if (!filename.toLowerCase().endsWith(".der"))
      filename = filename + ".der";

    if (!CBUtility.okToWriteFile(CBUtility.getParentFrame(this), filename))
    {
      return;
View Full Code Here


  private void certDetailsTable_selectionChanged(ListSelectionEvent e)
  {
    int selectedRow = certDetailsTable.getSelectedRow();
    if (selectedRow >= 0)
    {
      String selectedValue=certDetailsTable.getValueAt(selectedRow, 1).toString();
      CertDetailsTableModel model = (CertDetailsTableModel) certDetailsTable.getModel();

      Object details = model.getDetails(selectedValue);

      if (details != null)
View Full Code Here

      data.add(subjectRow);

      Vector publicKeyRow = new Vector();
      publicKeyRow.add(new JLabel("Public Key", CertViewer.attributeIcon, SwingConstants.LEFT));
      PublicKey pubKey = cert.getPublicKey();
      String publicKeyString = pubKey.getAlgorithm();
      if (pubKey instanceof RSAPublicKey)
        publicKeyString = publicKeyString + " (" + ((RSAPublicKey) pubKey).getModulus().bitLength() + " Bits)";
      else if (pubKey instanceof DSAPublicKey)
        publicKeyString = publicKeyString + " (" + ((DSAPublicKey) pubKey).getY().bitLength() + " Bits)";
      publicKeyRow.add(publicKeyString);

      /*
      if (pubKey instanceof RSAPublicKey)
        briefDetails.put(publicKeyString, CBUtility.bytes2HexSplit(((RSAPublicKey)pubKey).getModulus().toByteArray(), 4, 36));
      else
        briefDetails.put(publicKeyString, StaticUtil.bytes2Hex(pubKey.getEncoded(), 4, 36));
      */

      data.add(publicKeyRow);
    }

    if (viewMode == 0 || viewMode == 2)
    {
      Set nonCritSet = cert.getNonCriticalExtensionOIDs();
      if (nonCritSet != null && !nonCritSet.isEmpty())
      {
        for (Iterator i = nonCritSet.iterator(); i.hasNext();)
        {
          String oid = (String)i.next();
          Vector nonCritRow = new Vector();
          String extname = getNameFromOID(oid);
          nonCritRow.add(new JLabel(extname, CertViewer.extensionIcon, SwingConstants.LEFT));
          addExtDetails(nonCritRow,
              printext(extname, cert.getExtensionValue(oid)).toString());
          data.add(nonCritRow);
        }
      }
    }

    if (viewMode == 0 || viewMode == 2 || viewMode == 3)
    {
      Set critSet = cert.getCriticalExtensionOIDs();
      if (critSet != null && !critSet.isEmpty())
      {
        for (Iterator i = critSet.iterator(); i.hasNext();)
        {
          String oid = (String)i.next();
          Vector critRow = new Vector();
          String extname = getNameFromOID(oid);
          critRow.add(new JLabel(extname, CertViewer.criticalExtensionIcon, SwingConstants.LEFT));
          addExtDetails(critRow,
              printext(extname, cert.getExtensionValue(oid)).toString());
          data.add(critRow);
        }
View Full Code Here

        System.out.println("toString: " + cert.getSubjectX500Principal().toString());
        System.out.print("der: ");
        byte[] bytes = cert.getSubjectX500Principal().getEncoded();
        for (int i=0; i<bytes.length; i++)
            System.out.print(" " + bytes[i]);
        String name = cert.getSubjectX500Principal().getName();
        System.out.println();
        System.out.println("default: ");

        bytes = name.getBytes();
        System.out.println("straight name: " + CBParse.bytes2Hex(bytes));
        try
        {
            System.out.println("unicode: " + CBParse.bytes2Hex(name.getBytes("UTF-16")));
            System.out.println("utf-8: " + CBParse.bytes2Hex(name.getBytes("UTF-8")));
        }
        catch (UnsupportedEncodingException e2)
        {
            e2.printStackTrace();
        }
View Full Code Here

    private void addExtDetails(Vector row, String extDetails)
  {
    StringTokenizer tok = new StringTokenizer(extDetails, "\n");
    if (tok.countTokens() > 1)
    {
      String brief = tok.nextToken();
      row.addElement(brief);
      briefDetails.put(brief, extDetails);
    }
    else
    {
View Full Code Here

      c[i]=a[i]+b[i];
      /* Sommo i caratteri precedentemente ottenuti e li metto in c[i]*/
      i++;
    }
    i=0;
    String cifrato=new String("");   // stringa che conterr? il testo cifrato
    while (i<n// Per tutta la lunghezza di c[n] (n = lunghezza testo in chiaro = lunghezza testo cifrato)
    {
    if(c[i]>=255) c[i]=255%c[i];
    /* Se l'lelemento i-esimo ? > di 255 calcola il modulo cos? dar? semre un numero corisspondente a un carattere*/
    cifrato=cifrato+(char)c[i];
 
View Full Code Here

          /*converto l'i-esimo crarattere della chiave e lo metto in b[i]*/
          d[i]=c[i]-b[i];
          /*in d[i] metto la sottrazione dei due numeri appena ricavati (cifrato[i]-chiave[i])*/
        i++;
        }
        String decifrato=new String(""); //stringa che conter? l'elemento decifrato
        i=0;
        while (i<m)                    // per la lunghezza del testo cifrato
          {
            if (d[i]<0) d[i]=d[i]+255;
            /*Se l'i-esimo elemento della sottrazione ? negativo vi ? stato effettuato l'operazione di MOD in fase di cifratura, quindi aggiungi 255 */
 
View Full Code Here

    int n = chiaro.length();
    int m = chiave.length();
    int a[] = new int[n];
    int b[] = new int[m];
    int c[] = new int[n];
    String cifrato = new String("");

    while (i < n) {
      a[i] = (int) aC[i];
      b[i] = (int) bC[i];
      c[i] = (a[i] + b[i]) % 255;
View Full Code Here

  }

  public static String decrypt(String chiave, String cifrato) {

    int j = 0, k = 0, count = 0;
    String tmp = new String("");
    char bC[], cC[];
    bC = chiave.toCharArray();
    cC = cifrato.toCharArray();
    int m = chiave.length();
    int cifratoLenght = m;
    int b[] = new int[m];
    int c[] = new int[m];
    int d[] = new int[m];
    boolean ok = false;
    for (j = 0; j < m; j++) {

      try {
        for (k = 0; k < 3; k++) { // Questo ciclo carica i numeri
                      // scritti nella forma 123-234-...
                      // uno alla voltain una stringa
                      // temporanea
          if (cC[count + k] == '-') {
            ok = false;
            break;
          }
          tmp = tmp + cC[count + k];
          ok = true;
        }
      } catch (Exception e) {
        cifratoLenght = j;
        break;
      }

      if (ok)
        try {
          c[j] = Integer.parseInt(tmp);
        } // A questo punto carico la stringa ottenuta nell'array di
          // interi
        catch (Exception e) {
        }
      count = count + tmp.length() + 1;
      tmp = "";
    }
    String decifrato = new String("");
    int i = 0;
    while (i < m) {
      b[i] = (int) bC[i];
      d[i] = ((c[i] - b[i]) + 255) % 255;
      decifrato = decifrato + (char) d[i]; // Ritrasformo i numeri in
                          // caratteri e li carico
                          // nella stringa di output
      i++;
    }
    return decifrato.substring(0, cifratoLenght);
  }
View Full Code Here

              "Title: RedVernam \n Description: Encryption Software \n Copyleft: (c) 2009 Open Source GPL\n Company: www.andrearaso.org \n @version alpha");
    }

    // Apri Messaggio da menu o da tasto:
    if (Ob == jPanel2.ofButton || Ob == OMsg) {
      String temp = new String(apri());
      if (!annullaAction)
        jPanel2.MsgTarea.setText(temp);
      annullaAction = false;
    }
    /*
     * Apre una finestra file chooser tramite un metodo privato
     * (apri())dichiarato successivamente, se il filechooser apre con
     * successo (e non setta anullaAction a true) inserisce nella finestra
     * del pannello 2 (mess in chiaro)
     */

    // Salva il Messaggio da menu o tasto
    if (Ob == jPanel2.sfButton || Ob == SMsg)
      salva(jPanel2.MsgTarea.getText());
    /*
     * Passa al metodo privato salva(String)il testo (in chiaro) che verr�
     * salvato
     */

    if (Ob == jPanel2.clearScnd)
      jPanel2.clear(); // Pulisce l'area di testo del messaggio in chiaro

    // Apri Chiave da menu o da tasto:
    if (Ob == jPanel3.okButton || Ob == OKey) {
      String temp = new String(apri());
      if (!annullaAction)
        jPanel3.keyTarea.setText(temp);
      annullaAction = false;
    }
    /*
     * Apre una finestra file chooser tramite un metodo
     * privato(apri())dichiarato successivamente, se il filechooser apre con
     * successo (e non setta anullaAction a true) inserisce nella finestra
     * del pannello 3 (chiave)
     */

    if (Ob == jPanel3.clearThrd)
      jPanel3.clear();// Pulisce l'area di testo della chiave

    // Apri Messaggio Cifrato da menu o da tasto:
    if (Ob == jPanel4.oEfButton || Ob == OeMsg) {
      String temp = new String(apri());
      if (!annullaAction)
        jPanel4.encrMsgTarea.setText(temp);
      annullaAction = false;
    }
    /*
 
View Full Code Here

TOP

Related Classes of java.lang.String$ConsolePrintStream

Copyright © 2018 www.massapicom. 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.