Example #1
0
 /**
  * opens a resource file stream
  *
  * @param filename the file path
  * @return the inputStream containing the file's content
  */
 private InputStream openMyTestStream(final String filename) {
   try {
     URL installURL = FreqAnalysisPlugin.getDefault().getBundle().getEntry("/"); // $NON-NLS-1$
     URL url = new URL(installURL, filename);
     return (url.openStream());
   } catch (MalformedURLException e) {
     LogUtil.logError(FreqAnalysisPlugin.PLUGIN_ID, e);
   } catch (IOException e) {
     LogUtil.logError(FreqAnalysisPlugin.PLUGIN_ID, e);
   }
   return null;
 }
 public void handleEvent(Event event) {
   if (event.widget.equals(defaultRadioButton)) {
     LogUtil.logInfo("default"); // $NON-NLS-1$
     setPageComplete(false);
     useDefaultValues = true;
     wizard.setCanFinish(true);
   } else if (event.widget.equals(customRadioButton)) {
     LogUtil.logInfo("custom"); // $NON-NLS-1$
     wizard.setCanFinish(false);
     useDefaultValues = false;
     setPageComplete(true);
   }
 }
Example #3
0
 private void addFlexibleActions(IToolBarManager manager) {
   Iterator<IKeyStoreActionDescriptor> it =
       KeyStoreActionManager.getInstance().getNewSymmetricKeyActions();
   IKeyStoreActionDescriptor tmp;
   while (it.hasNext()) {
     tmp = it.next();
     if (tmp.getExtensionUID()
         .equals("org.jcryptool.crypto.flexiprovider.keystore")) { // $NON-NLS-1$
       LogUtil.logInfo("should add a secret key command"); // $NON-NLS-1$
       addContributionItem(
           manager,
           tmp.getID(),
           KeyStorePlugin.getImageDescriptor(tmp.getIcon()),
           tmp.getToolTipText());
       break;
     }
   }
   Iterator<IKeyStoreActionDescriptor> it2 =
       KeyStoreActionManager.getInstance().getNewKeyPairActions();
   IKeyStoreActionDescriptor tmp2;
   while (it2.hasNext()) {
     tmp2 = it2.next();
     if (tmp2.getExtensionUID()
         .equals("org.jcryptool.crypto.flexiprovider.keystore")) { // $NON-NLS-1$
       LogUtil.logInfo("should add a key pair command"); // $NON-NLS-1$
       addContributionItem(
           manager,
           tmp2.getID(),
           KeyStorePlugin.getImageDescriptor(tmp2.getIcon()),
           tmp2.getToolTipText());
       break;
     }
   }
   Iterator<IKeyStoreActionDescriptor> it3 =
       KeyStoreActionManager.getInstance().getImportActions();
   IKeyStoreActionDescriptor tmp3;
   while (it3.hasNext()) {
     tmp3 = it3.next();
     if (tmp3.getExtensionUID()
         .equals("org.jcryptool.crypto.flexiprovider.keystore")) { // $NON-NLS-1$
       LogUtil.logInfo("should add an import command"); // $NON-NLS-1$
       addContributionItem(
           manager,
           tmp3.getID(),
           KeyStorePlugin.getImageDescriptor(tmp3.getIcon()),
           tmp3.getToolTipText());
       break;
     }
   }
 }
  private void initGUI() {
    radioGroup =
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            Button b = (Button) event.widget;
            if (b.getSelection() == false) {
              b.setSelection(true);
            } else {
              if (event.widget == btnColumnar) {
                btnRowwise.setSelection(!btnColumnar.getSelection());
              } else {
                btnColumnar.setSelection(!btnRowwise.getSelection());
              }
              input.synchronizeWithUserSide();
            }
          }
        };

    try {
      GridLayout thisLayout = new GridLayout();
      thisLayout.marginWidth = 0;
      thisLayout.marginHeight = 0;
      thisLayout.numColumns = 2;
      thisLayout.horizontalSpacing = 0;
      thisLayout.makeColumnsEqualWidth = true;
      this.setLayout(thisLayout);
      {
        btnColumnar = new Button(this, SWT.TOGGLE | SWT.FLAT | SWT.CENTER);
        GridData btnColumnarLData = new GridData();
        btnColumnarLData.grabExcessHorizontalSpace = true;
        btnColumnarLData.horizontalAlignment = GridData.FILL;
        btnColumnarLData.verticalAlignment = GridData.FILL;
        btnColumnarLData.heightHint = HEIGHT_NORMAL;
        if (flat) btnColumnarLData.heightHint = HEIGHT_FLAT;
        btnColumnar.setLayoutData(btnColumnarLData);
        btnColumnar.setText(Messages.ReadDirectionChooser_0);
        btnColumnar.addListener(SWT.Selection, radioGroup);
      }
      {
        btnRowwise = new Button(this, SWT.TOGGLE | SWT.FLAT | SWT.CENTER);
        GridData btnRowwiseLData = new GridData();
        btnRowwiseLData.grabExcessHorizontalSpace = true;
        btnRowwiseLData.horizontalAlignment = GridData.FILL;
        btnRowwiseLData.verticalAlignment = GridData.FILL;
        btnRowwiseLData.heightHint = HEIGHT_NORMAL;
        if (flat) btnRowwiseLData.heightHint = HEIGHT_FLAT;
        btnRowwise.setLayoutData(btnRowwiseLData);
        btnRowwise.setText(Messages.ReadDirectionChooser_1);
        btnRowwise.addListener(SWT.Selection, radioGroup);
      }
      this.layout();
    } catch (Exception e) {
      LogUtil.logError(e);
    }
    initInput();
  }
Example #5
0
 public Boolean isRetrieverSelected(Retriever retriever) {
   List<Boolean> data = this.getBtnData();
   int pos = this.getRetrievers().indexOf(retriever);
   if (pos < 0) {
     LogUtil.logError(
         Activator.PLUGIN_ID, "retriever object not found in retrieverViewer"); // $NON-NLS-1$
     return false;
   } else {
     return data.get(pos);
   }
 }
Example #6
0
  /**
   * reads the current value from an input stream
   *
   * @param in the input stream
   */
  private String InputStreamToString(InputStream in) {
    BufferedReader reader = null;
    try {
      reader = new BufferedReader(new InputStreamReader(in, IConstants.UTF8_ENCODING));
    } catch (UnsupportedEncodingException e1) {
      LogUtil.logError(FriedmanPlugin.PLUGIN_ID, e1);
    }

    StringBuffer myStrBuf = new StringBuffer();
    int charOut = 0;
    String output = ""; // $NON-NLS-1$
    try {
      while ((charOut = reader.read()) != -1) {
        myStrBuf.append(String.valueOf((char) charOut));
      }
    } catch (IOException e) {
      LogUtil.logError(FriedmanPlugin.PLUGIN_ID, e);
    }
    output = myStrBuf.toString();
    return output;
  }
Example #7
0
  private void createDecryption() {
    try {
      NewDecryptionWizard wizard = new NewDecryptionWizard();
      data = getActiveEditorInputStream();

      wizard.init(data);

      decryptData(wizard);
    } catch (Exception ex) {
      LogUtil.logError(XSTUIPlugin.getId(), Messages.NewDecryptionCommand_1, ex, true);
    }
  }
  public void createControl(Composite parent) {
    LogUtil.logInfo("creating control"); // $NON-NLS-1$
    Composite pageComposite = new Composite(parent, SWT.NULL);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    gridLayout.makeColumnsEqualWidth = true;
    pageComposite.setLayout(gridLayout);
    GridData gridData = new GridData();
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    pageComposite.setLayoutData(gridData);
    createParametersGroup(pageComposite);

    defaultRadioButton.setSelection(true);
    registerListeners();
    pageComposite.setSize(new Point(300, 200));
    pageComposite.setLayout(new GridLayout());
    setControl(pageComposite);
    setPageComplete(false);
  }
Example #9
0
  private void initGUI() {
    try {
      int w = 800;
      int h = 400;

      Font system = getDisplay().getSystemFont();
      FontData base = system.getFontData()[0];
      FontData normdat = new FontData(base.getName(), base.getHeight(), base.getStyle());
      Font normfont = new Font(getDisplay(), normdat);
      FormLayout thisLayout = new FormLayout();
      this.setSize(w, h);
      this.setLayout(thisLayout);

      {
        btn1 = new Button(this, SWT.PUSH | SWT.CENTER);
        FormData btn1LData = new FormData();
        btn1LData.top = new FormAttachment(this, 10);
        btn1LData.left = new FormAttachment(this, 10);
        btn1.setLayoutData(btn1LData);
        btn1.setText(Messages.KegverContent_btn1);
        btn1.setToolTipText(Messages.KegverContent_btn1_tt);
        btn1.setFont(normfont);
        btn1.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent evt) {
                nextStep();
              }
            });
      }

      {
        btn2 = new Button(this, SWT.PUSH | SWT.CENTER);
        FormData btn2LData = new FormData();
        btn2LData.top = new FormAttachment(btn1, 10);
        btn2LData.left = new FormAttachment(this, 10);
        btn2.setLayoutData(btn2LData);
        btn2.setText(Messages.KegverContent_btn2);
        btn2.setToolTipText(Messages.KegverContent_btn2_tt);
        btn2.setFont(normfont);
        btn2.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent evt) {
                editCA();
              }
            });
      }

      {
        btn3 = new Button(this, SWT.PUSH | SWT.CENTER);
        FormData btn3LData = new FormData();
        btn3LData.top = new FormAttachment(btn2, 10);
        btn3LData.left = new FormAttachment(this, 10);
        btn3.setLayoutData(btn3LData);
        btn3.setText(Messages.KegverContent_btn3);
        btn3.setToolTipText(Messages.KegverContent_btn3_tt);
        btn3.setFont(normfont);
        btn3.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent evt) {
                editUser();
              }
            });
      }

      {
        grp1 = new Group(this, SWT.BORDER);
        FormLayout grpstepsLayout = new FormLayout();
        grp1.setLayout(grpstepsLayout);
        FormData grp1LData = new FormData();
        grp1LData.left = new FormAttachment(btn1, 10);
        grp1LData.top = new FormAttachment(this, 10);
        grp1LData.width = w - 20;
        grp1LData.height = h - 20;
        grp1.setLayoutData(grp1LData);
        grp1.setText(Messages.KegverContent_grp1);
        grp1.setFont(normfont);
        {
          // FIXME: Why is SWT.H_SCROLL not working? : As long it is not working, SWT.WRAP
          grp1_t =
              new Text(grp1, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
          FormData grp1_tLData = new FormData();
          grp1_t.setEditable(false);
          grp1_t.setFont(normfont);
          grp1_tLData.left = new FormAttachment(grp1, 0);
          grp1_tLData.top = new FormAttachment(grp1, 0);
          grp1_tLData.width = w - 47;
          grp1_tLData.height = h - 20;
          grp1_t.setBackground(getBackground());
          grp1_t.setText(Messages.KegverContent_grp1_t);
          grp1_t.setLayoutData(grp1_tLData);
        }
      }

      getShell().setDefaultButton(btn1);

      this.layout();

    } catch (Exception ex) {
      LogUtil.logError(ex);
    }
  }
Example #10
0
 private void editUser() {
   LogUtil.logError(new Exception("not implemented yet"));
 }
Example #11
0
  private void initGUI() {
    try {
      GridLayout thisLayout = new GridLayout();
      thisLayout.makeColumnsEqualWidth = true;
      this.setLayout(thisLayout);
      this.setSize(604, 337);
      button1 = new Button(this, SWT.PUSH | SWT.CENTER);
      GridData button1LData = new GridData();
      button1LData.horizontalAlignment = GridData.FILL;
      button1LData.grabExcessHorizontalSpace = true;
      button1.setLayoutData(button1LData);
      button1.setText(Messages.FullAnalysisUI_startanalysis);
      button1.addMouseListener(
          new MouseAdapter() {

            @Override
            public void mouseDown(final MouseEvent evt) {
              if (checkEditor()) {
                text = getEditorText();
                if (btnReferenceTools.getSelection()) {
                  selectAppropriateAlphabet();
                } else {
                  appropriateAlphabetToBeDetected = true;
                }
                recalcGraph();
              }
            }
          });
      composite1 = new Composite(this, SWT.NONE);
      GridLayout composite1Layout = new GridLayout();
      composite1Layout.numColumns = 2;
      composite1Layout.marginWidth = 0;
      composite1Layout.marginHeight = 0;
      GridData composite1LData = new GridData();
      composite1LData.grabExcessHorizontalSpace = true;
      composite1LData.horizontalAlignment = GridData.FILL;
      composite1LData.verticalAlignment = GridData.FILL;
      composite1LData.grabExcessVerticalSpace = true;
      composite1.setLayoutData(composite1LData);
      composite1.setLayout(composite1Layout);
      {
        group1 = new Group(composite1, SWT.NONE);
        GridLayout group1Layout = new GridLayout();
        group1.setLayout(group1Layout);
        GridData group1LData = new GridData();
        group1LData.horizontalAlignment = GridData.FILL;
        group1LData.grabExcessHorizontalSpace = true;
        group1LData.verticalAlignment = GridData.FILL;
        group1LData.grabExcessVerticalSpace = true;
        group1.setLayoutData(group1LData);
        group1.setText(Messages.FullAnalysisUI_graphlabel);
        {
          myGraph = new CustomFreqCanvas(group1, SWT.NONE);

          GridLayout myGraphLayout = new GridLayout();
          myGraph.setLayout(myGraphLayout);
          GridData myGraphLData = new GridData();
          myGraphLData.verticalAlignment = GridData.FILL;
          myGraphLData.grabExcessVerticalSpace = true;
          myGraphLData.grabExcessHorizontalSpace = true;
          myGraphLData.horizontalAlignment = GridData.FILL;
          myGraph.setLayoutData(myGraphLData);
        }
      }
      {
        group4 = new Group(composite1, SWT.NONE);
        GridLayout group4Layout = new GridLayout();
        group4.setLayout(group4Layout);
        GridData group4LData = new GridData();
        group4LData.horizontalAlignment = GridData.FILL;
        group4LData.grabExcessVerticalSpace = true;
        group4LData.verticalAlignment = GridData.FILL;
        group4.setLayoutData(group4LData);
        group4.setText(Messages.FullAnalysisUI_propertieslabel);
        {
          tabFolder1 = new TabFolder(group4, SWT.NONE);
          {
            tabItem1 = new TabItem(tabFolder1, SWT.NONE);
            tabItem1.setText(Messages.FullAnalysisUI_firsttablabel);
            {
              composite3 = new Composite(tabFolder1, SWT.NONE);
              GridLayout composite3Layout = new GridLayout();
              composite3Layout.makeColumnsEqualWidth = true;
              composite3.setLayout(composite3Layout);
              GridData composite3LData = new GridData();
              composite3LData.grabExcessHorizontalSpace = true;
              composite3LData.horizontalAlignment = GridData.FILL;
              composite3LData.verticalAlignment = GridData.FILL;
              composite3LData.grabExcessVerticalSpace = true;
              tabItem1.setControl(composite3);
              {
                composite2 = new Composite(composite3, SWT.NONE);
                GridLayout composite2Layout = new GridLayout();
                composite2Layout.makeColumnsEqualWidth = true;
                composite2Layout.marginHeight = 0;
                GridData composite2LData = new GridData();
                composite2LData.grabExcessHorizontalSpace = true;
                composite2LData.horizontalAlignment = GridData.FILL;
                composite2.setLayoutData(composite2LData);
                composite2.setLayout(composite2Layout);
                {
                  button3 = new Button(composite2, SWT.RADIO | SWT.LEFT);
                  button3.setText(Messages.FullAnalysisUI_monoalphabetic);
                  button3.setSelection(true);
                  button3.addSelectionListener(
                      new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent evt) {
                          polyOnOffSelected(evt);
                        }
                      });
                }
                {
                  button4 = new Button(composite2, SWT.RADIO | SWT.LEFT);
                  button4.setText(Messages.FullAnalysisUI_polyalphabetic);
                  button4.addSelectionListener(
                      new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent evt) {
                          polyOnOffSelected(evt);
                        }
                      });
                }
              }
              {
                group2 = new Group(composite3, SWT.NONE);
                GridLayout group2Layout = new GridLayout();
                group2Layout.numColumns = 2;
                group2.setLayout(group2Layout);
                GridData group2LData = new GridData();
                group2LData.horizontalAlignment = GridData.FILL;
                group2LData.verticalAlignment = GridData.BEGINNING;
                group2LData.grabExcessHorizontalSpace = true;
                group2.setLayoutData(group2LData);
                group2.setText(Messages.FullAnalysisUI_vigeneresettings);
                {
                  GridData spinner1LData = new GridData();
                  spinner1 = new Spinner(group2, SWT.NONE);
                  spinner1.setLayoutData(spinner1LData);
                  spinner1.addMouseListener(
                      new MouseAdapter() {
                        @Override
                        public void mouseDown(MouseEvent evt) {
                          recalcGraph();
                        }
                      });
                  spinner1.addSelectionListener(
                      new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent evt) {
                          changedVigOptions();
                          recalcGraph();
                        }
                      });
                  spinner1.setSelection(1);
                }
                {
                  label1 = new Label(group2, SWT.NONE);
                  label1.setLayoutData(new GridData());
                  label1.setText(Messages.FullAnalysisUI_keylength);
                }
                {
                  GridData spinner2LData = new GridData();
                  spinner2 = new Spinner(group2, SWT.NONE);
                  spinner2.setLayoutData(spinner2LData);
                  spinner2.addMouseListener(
                      new MouseAdapter() {
                        @Override
                        public void mouseDown(MouseEvent evt) {
                          recalcGraph();
                        }
                      });
                  spinner2.addSelectionListener(
                      new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent evt) {
                          changedVigOptions();
                        }
                      });
                }
                {
                  label2 = new Label(group2, SWT.NONE);
                  label2.setLayoutData(new GridData());
                  label2.setText(Messages.FullAnalysisUI_keyoffset);
                }
              }
            }
          }
          {
            tabItem2 = new TabItem(tabFolder1, SWT.NONE);
            tabItem2.setText(Messages.FullAnalysisUI_secondtablabel);
            {
              composite4 = new Composite(tabFolder1, SWT.NONE);
              GridLayout composite4Layout = new GridLayout();
              composite4Layout.makeColumnsEqualWidth = true;
              composite4.setLayout(composite4Layout);
              GridData composite4LData = new GridData();
              composite4LData.grabExcessHorizontalSpace = true;
              composite4LData.horizontalAlignment = GridData.FILL;
              composite4LData.verticalAlignment = GridData.FILL;
              composite4LData.grabExcessVerticalSpace = true;
              tabItem2.setControl(composite4);
              {
                btnReferenceTools = new Button(composite4, SWT.CHECK | SWT.LEFT);
                GridData button2LData = new GridData();
                button2LData.grabExcessHorizontalSpace = true;
                button2LData.horizontalAlignment = GridData.FILL;
                btnReferenceTools.setLayoutData(button2LData);
                btnReferenceTools.setText(Messages.FullAnalysisUI_enabledecrOverlay);
                btnReferenceTools.addMouseListener(
                    new MouseAdapter() {
                      @Override
                      public void mouseDown(MouseEvent evt) {

                        if (!btnReferenceTools.getSelection()) {
                          enableReferenceTools(true);
                          if (myLimitedAnalysis == null) recalcGraph();
                          if (myLimitedAnalysis != null) myGraph.setAnalysis(myLimitedAnalysis);
                        } else {
                          enableReferenceTools(false);
                          if (myAnalysis == null) recalcGraph();
                          if (myAnalysis != null) myGraph.setAnalysis(myAnalysis);
                        }
                        if (myAnalysis != null || myLimitedAnalysis != null) {
                          myGraph.setOverlayActivated(!btnReferenceTools.getSelection());
                          myGraph.redraw();
                        }
                      }
                    });
              }
              {
                combo1 = new Combo(composite4, SWT.READ_ONLY);
                GridData combo1LData = new GridData();
                combo1LData.grabExcessHorizontalSpace = true;
                GridData combo1LData1 = new GridData();
                combo1LData1.horizontalAlignment = GridData.FILL;
                combo1LData1.heightHint = 21;
                combo1.setLayoutData(combo1LData1);

                // add reftexts
                reftexts.add(
                    new Reftext(
                        Messages.FullAnalysisUI_germanreftextname1, Messages.FullAnalysisUI_0));
                reftexts.add(
                    new Reftext(
                        Messages.FullAnalysisUI_germanreftextname2, Messages.FullAnalysisUI_1));
                reftexts.add(
                    new Reftext(
                        Messages.FullAnalysisUI_englishreftextname1, Messages.FullAnalysisUI_2));

                for (int i = 0; i < reftexts.size(); i++) combo1.add(reftexts.get(i).name);
                combo1.addSelectionListener(
                    new SelectionAdapter() {
                      @Override
                      public void widgetSelected(SelectionEvent evt) {
                        combo1WidgetSelected(evt);
                      }
                    });
                combo1.setText(combo1.getItem(0));
              }
              {
                label3 = new Label(composite4, SWT.NONE);
                GridData label3LData = new GridData();
                label3LData.horizontalAlignment = GridData.FILL;
                label3LData.grabExcessHorizontalSpace = true;
                label3.setLayoutData(label3LData);
                label3.setText(Messages.FullAnalysisUI_alphabetused);
              }
              {
                combo2 = new Combo(composite4, SWT.READ_ONLY);
                GridData combo2LData = new GridData();
                combo2LData.heightHint = 21;
                combo2LData.horizontalAlignment = GridData.FILL;
                combo2.setLayoutData(combo2LData);
                combo2.addSelectionListener(
                    new SelectionAdapter() {
                      @Override
                      public void widgetSelected(SelectionEvent evt) {
                        combo2WidgetSelected(evt);
                      }
                    });

                AbstractAlphabet[] alphas = AlphabetsManager.getInstance().getAlphabets();
                for (int i = 0; i < alphas.length; i++) {
                  combo2.add(alphas[i].getName());
                  if (alphas[i].isDefaultAlphabet()) {
                    // combo2.setText(alphas[i].getName());
                    combo2.select(i);
                    myOverlayAlphabet = String.valueOf(alphas[i].getCharacterSet());
                  }
                }
              }
            }
          }
          GridData tabFolder1LData = new GridData();
          tabFolder1LData.horizontalAlignment = GridData.FILL;
          tabFolder1LData.verticalAlignment = GridData.FILL;
          tabFolder1LData.grabExcessVerticalSpace = true;
          tabFolder1LData.grabExcessHorizontalSpace = true;
          tabFolder1.setLayoutData(tabFolder1LData);
          tabFolder1.setSelection(0);
        }
      }
      this.layout();
    } catch (Exception e) {
      LogUtil.logError(FreqAnalysisPlugin.PLUGIN_ID, e);
    }

    tipLauncher = new SingleVanishTooltipLauncher(this.getShell());
    enableReferenceTools(false);
  }
Example #12
0
  private void initGUI() {
    try {
      GridLayout thisLayout = new GridLayout();
      thisLayout.makeColumnsEqualWidth = true;
      this.setLayout(thisLayout);
      Composite composite1 = new Composite(this, SWT.NONE);
      GridLayout composite1Layout = new GridLayout();
      composite1Layout.numColumns = 2;
      composite1Layout.marginHeight = 0;
      composite1Layout.marginWidth = 0;
      composite1Layout.horizontalSpacing = 0;
      GridData composite1LData = new GridData();
      composite1LData.verticalAlignment = GridData.FILL;
      composite1LData.horizontalAlignment = GridData.FILL;
      composite1LData.grabExcessHorizontalSpace = true;
      composite1.setLayoutData(composite1LData);
      composite1.setLayout(composite1Layout);
      {
        Button button2 = new Button(composite1, SWT.PUSH | SWT.CENTER);
        GridData button2LData = new GridData();
        button2LData.horizontalAlignment = GridData.FILL;
        button2LData.grabExcessHorizontalSpace = true;
        button2.setLayoutData(button2LData);
        button2.setText(Messages.FriedmanGraphUI_start);
        button2.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent e) {
                startAnalysis(e);
              }
            });
      }
      group1 = new Group(this, SWT.NONE);
      GridLayout group1Layout = new GridLayout();
      group1Layout.makeColumnsEqualWidth = true;
      group1.setLayout(group1Layout);
      GridData group1LData = new GridData();
      group1LData.grabExcessHorizontalSpace = true;
      group1LData.horizontalAlignment = GridData.FILL;
      group1LData.verticalAlignment = GridData.FILL;
      group1LData.grabExcessVerticalSpace = true;
      group1.setLayoutData(group1LData);
      group1.setText(Messages.FriedmanGraphUI_graph);
      {
        myGraph = new CustomFriedmanCanvas(group1, SWT.DOUBLE_BUFFERED);

        GridLayout myGraphLayout = new GridLayout();
        myGraph.setLayout(myGraphLayout);
        GridData myGraphLData = new GridData();
        myGraphLData.verticalAlignment = GridData.FILL;
        myGraphLData.grabExcessHorizontalSpace = true;
        myGraphLData.horizontalAlignment = GridData.FILL;
        myGraphLData.grabExcessVerticalSpace = true;
        myGraph.setLayoutData(myGraphLData);
      }
      Composite composite2 = new Composite(this, SWT.NONE);
      GridLayout composite2Layout = new GridLayout();
      composite2Layout.numColumns = 2;
      GridData composite2LData = new GridData();
      composite2LData.grabExcessHorizontalSpace = true;
      composite2LData.horizontalAlignment = GridData.FILL;
      composite2.setLayoutData(composite2LData);
      composite2.setLayout(composite2Layout);
      {
        button9 = new Button(composite2, SWT.PUSH | SWT.CENTER);
        GridData button9LData = new GridData();
        button9.setLayoutData(button9LData);
        button9.setText(Messages.FriedmanGraphUI_showastable);
        button9.setEnabled(false);
        button9.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent e) {
                showTableDialog(e);
              }
            });
      }
      this.layout();
    } catch (Exception e) {
      LogUtil.logError(FriedmanPlugin.PLUGIN_ID, e);
    }
  }
Example #13
0
 private void initGUI() {
   try {
     GridLayout thisLayout = new GridLayout();
     thisLayout.makeColumnsEqualWidth = true;
     this.setLayout(thisLayout);
     this.setSize(525, 237);
     group1 = new Group(this, SWT.NONE);
     GridLayout group1Layout = new GridLayout();
     group1Layout.makeColumnsEqualWidth = true;
     group1Layout.numColumns = 2;
     group1.setLayout(group1Layout);
     GridData group1LData = new GridData();
     group1LData.grabExcessHorizontalSpace = true;
     group1LData.horizontalAlignment = GridData.FILL;
     // group1LData.heightHint = 9;
     group1.setLayoutData(group1LData);
     group1.setText(Messages.FreqAnalysisUI_usagedescisionlabel);
     button1 = new Button(group1, SWT.RADIO | SWT.LEFT);
     GridData button1LData = new GridData();
     button1LData.grabExcessHorizontalSpace = true;
     button1LData.horizontalAlignment = GridData.FILL;
     button1.setLayoutData(button1LData);
     button1.setText(Messages.FreqAnalysisUI_descision1label);
     button1.addSelectionListener(
         new SelectionAdapter() {
           public void widgetSelected(SelectionEvent evt) {
             switchComposites(evt);
           }
         });
     button1.setSelection(false);
     button2 = new Button(group1, SWT.RADIO | SWT.LEFT);
     GridData button2LData = new GridData();
     button2LData.grabExcessHorizontalSpace = true;
     button2LData.horizontalAlignment = GridData.FILL;
     button2.setLayoutData(button2LData);
     button2.setText(Messages.FreqAnalysisUI_descision2label);
     button2.addSelectionListener(
         new SelectionAdapter() {
           public void widgetSelected(SelectionEvent evt) {
             switchComposites(evt);
           }
         });
     button2.setSelection(false);
     fakebtn = new Button(group1, SWT.RADIO | SWT.LEFT);
     fakebtn.setText("button3"); // $NON-NLS-1$
     GridData fakebtnLData = new GridData();
     fakebtnLData.exclude = true;
     fakebtn.setLayoutData(fakebtnLData);
     fakebtn.setSelection(true);
     C1 = new SimpleAnalysisUI(this, SWT.NONE);
     GridLayout C1Layout = new GridLayout();
     C1Layout.makeColumnsEqualWidth = true;
     GridData C1LData = new GridData();
     C1LData.grabExcessHorizontalSpace = true;
     C1LData.grabExcessVerticalSpace = true;
     C1LData.horizontalAlignment = GridData.FILL;
     C1LData.verticalAlignment = GridData.FILL;
     C1LData.exclude = true;
     C1.setLayoutData(C1LData);
     C1.setLayout(C1Layout);
     C1.setVisible(false);
     C2 = new FullAnalysisUI(this, SWT.NONE);
     GridLayout C2Layout = new GridLayout();
     C2Layout.makeColumnsEqualWidth = true;
     GridData C2LData = new GridData();
     C2LData.grabExcessHorizontalSpace = true;
     C2LData.grabExcessVerticalSpace = true;
     C2LData.verticalAlignment = GridData.FILL;
     C2LData.horizontalAlignment = GridData.FILL;
     C2LData.exclude = true;
     C2.setLayoutData(C2LData);
     C2.setLayout(C2Layout);
     C2.setVisible(false);
     this.layout();
   } catch (Exception e) {
     LogUtil.logError(FreqAnalysisPlugin.PLUGIN_ID, e);
   }
 }
Example #14
0
  private void initGUI() {
    try {
      FontData coudat = new FontData(VigenereBreakerGui.COURIER, 10, SWT.NORMAL);
      Font coufont = new Font(getDisplay(), coudat);

      FormLayout thisLayout = new FormLayout();
      this.setSize(780, 720);
      this.setLayout(thisLayout);
      {
        cselection = new Composite(this, SWT.NONE);
        FormLayout cselectionLayout = new FormLayout();
        FormData cselectionLData = new FormData();
        cselectionLData.left = new FormAttachment(0, 1000, 10);
        cselectionLData.top = new FormAttachment(0, 1000, 0);
        cselectionLData.width = 760;
        cselectionLData.height = 30;
        cselection.setLayoutData(cselectionLData);
        cselection.setLayout(cselectionLayout);
        {
          lsep = new Label(cselection, SWT.SEPARATOR | SWT.HORIZONTAL);
          FormData lsepLData = new FormData();
          lsepLData.left = new FormAttachment(0, 1000, 0);
          lsepLData.top = new FormAttachment(0, 1000, 26);
          lsepLData.width = 760;
          lsepLData.height = 5;
          lsep.setLayoutData(lsepLData);
        }
        {
          lsthree = new Label(cselection, SWT.BORDER | SWT.CENTER);
          FormData lsthreeLData = new FormData();
          lsthreeLData.left = new FormAttachment(0, 1000, 480);
          lsthreeLData.top = new FormAttachment(0, 1000, 0);
          lsthreeLData.width = 238;
          lsthreeLData.height = 24;
          lsthree.setLayoutData(lsthreeLData);
          lsthree.setText(Messages.VigenereGlobal_navi_decryption);
          lsthree.setFont(FontService.getLargeFont());
          lsthree.setEnabled(false);
        }
        {
          lstwo = new Label(cselection, SWT.BORDER | SWT.CENTER);
          FormData lstwoLData = new FormData();
          lstwoLData.left = new FormAttachment(0, 1000, 240);
          lstwoLData.top = new FormAttachment(0, 1000, 0);
          lstwoLData.width = 238;
          lstwoLData.height = 24;
          lstwo.setLayoutData(lstwoLData);
          lstwo.setText(Messages.VigenereGlobal_navi_frequency);
          lstwo.setFont(FontService.getLargeFont());
        }
        {
          lsone = new Label(cselection, SWT.BORDER | SWT.CENTER);
          FormData lsoneLData = new FormData();
          lsoneLData.left = new FormAttachment(0, 1000, 0);
          lsoneLData.top = new FormAttachment(0, 1000, 0);
          lsoneLData.width = 238;
          lsoneLData.height = 24;
          lsone.setLayoutData(lsoneLData);
          lsone.setText(Messages.VigenereGlobal_navi_friedman);
          lsone.setFont(FontService.getLargeFont());
          lsone.setEnabled(false);
        }
      }
      {
        cvariable = new Composite(this, SWT.NONE);
        FormLayout composite3Layout = new FormLayout();
        FormData composite3LData = new FormData();
        composite3LData.left = new FormAttachment(0, 1000, 10);
        composite3LData.top = new FormAttachment(0, 1000, 30);
        composite3LData.width = 760;
        composite3LData.height = 680;
        cvariable.setLayoutData(composite3LData);
        cvariable.setLayout(composite3Layout);
        {
          lpreview = new Label(cvariable, SWT.NONE);
          FormData lpreviewLData = new FormData();
          lpreviewLData.left = new FormAttachment(0, 1000, 0);
          lpreviewLData.top = new FormAttachment(0, 1000, 10);
          lpreviewLData.width = 760;
          lpreviewLData.height = 15;
          lpreview.setLayoutData(lpreviewLData);
          lpreview.setText(Messages.FrequencyGui_label_preview1 + edtitle);
          lpreview.setFont(FontService.getNormalFont());
        }

        {
          thelp = new Text(cvariable, SWT.MULTI | SWT.WRAP);
          FormData tdescrLData = new FormData();
          tdescrLData.left = new FormAttachment(0, 1000, 0);
          tdescrLData.top = new FormAttachment(0, 1000, 380);
          tdescrLData.width = 234;
          tdescrLData.height = 245;
          thelp.setLayoutData(tdescrLData);
          thelp.setText(
              String.format(Messages.FrequencyGui_text_help, plength) + Messages.FrequencyGui_0);
          thelp.setEditable(false);
          thelp.setEnabled(false);
          thelp.setFont(FontService.getNormalFont());
        }
        {
          lsepend = new Label(cvariable, SWT.SEPARATOR | SWT.HORIZONTAL);
          FormData label1LData = new FormData();
          label1LData.left = new FormAttachment(0, 1000, 0);
          label1LData.top = new FormAttachment(thelp, 5);
          label1LData.width = 760;
          label1LData.height = 4;
          lsepend.setLayoutData(label1LData);
        }
        {
          llength = new Label(cvariable, SWT.NONE);
          FormData llengthLData = new FormData();
          llengthLData.left = new FormAttachment(0, 1000, 260);
          llengthLData.top = new FormAttachment(0, 1000, 400);
          llengthLData.width = 200;
          llengthLData.height = 15;
          llength.setLayoutData(llengthLData);
          String l = Messages.FrequencyGui_label_length;
          llength.setText(l + String.valueOf(plength));
          llength.setFont(FontService.getNormalFont());
        }
        {
          tsample = new Text(cvariable, SWT.MULTI | SWT.WRAP | SWT.BORDER);
          FormData text1LData = new FormData();
          text1LData.left = new FormAttachment(0, 1000, 0);
          text1LData.top = new FormAttachment(0, 1000, 25);
          text1LData.width = 752;
          text1LData.height = 84;
          tsample.setLayoutData(text1LData);
          tsample.setFont(coufont);
          tsample.setEditable(false);
          tsample.setEnabled(false);
          tsample.setBackground(new Color(getDisplay(), 250, 250, 250));
        }
        {
          cgraph = new Composite(cvariable, SWT.NONE);
          GridLayout composite4Layout = new GridLayout();
          composite4Layout.makeColumnsEqualWidth = true;
          FormData composite4LData = new FormData();
          composite4LData.left = new FormAttachment(0, 1000, 0);
          composite4LData.top = new FormAttachment(0, 1000, 120);
          composite4LData.width = 760;
          composite4LData.height = 260;
          cgraph.setLayoutData(composite4LData);
          cgraph.setLayout(composite4Layout);
        }
        {
          cphrase = new Composite(cvariable, SWT.NONE);
          FormLayout composite6Layout = new FormLayout();
          FormData composite6LData = new FormData();
          composite6LData.left = new FormAttachment(0, 1000, 250);
          composite6LData.top = new FormAttachment(0, 1000, 422);
          composite6LData.width = 510;
          composite6LData.height = 100;
          cphrase.setLayoutData(composite6LData);
          cphrase.setLayout(composite6Layout);
        }
        {
          bshift = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData bfriedexecLData = new FormData();
          bfriedexecLData.left = new FormAttachment(0, 1000, 260);
          bfriedexecLData.top = new FormAttachment(lsepend, 5);
          bfriedexecLData.height = 25;
          bshift.setLayoutData(bfriedexecLData);
          bshift.setText(Messages.FrequencyGui_button_shift);
          bshift.setFont(FontService.getNormalFont());
          bshift.setToolTipText(Messages.FrequencyGui_ttip_shift);
          bshift.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent event) {
                  shift();
                }
              });
        }
        {
          bdecrypt = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData button1LData = new FormData();
          button1LData.left = new FormAttachment(bshift, 5);
          button1LData.top = new FormAttachment(lsepend, 5);
          button1LData.height = 25;
          bdecrypt.setLayoutData(button1LData);
          bdecrypt.setText(Messages.FrequencyGui_button_decrypt);
          bdecrypt.setFont(FontService.getNormalFont());
          bdecrypt.setToolTipText(Messages.FrequencyGui_ttip_decrypt);
          bdecrypt.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent evt) {
                  decrypt();
                }
              });
        }
        {
          bback = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData bbackLData = new FormData();
          bbackLData.left = new FormAttachment(0, 1000, 0);
          bbackLData.top = new FormAttachment(lsepend, 5);
          bbackLData.height = 25;
          bbackLData.width = 90;
          bback.setLayoutData(bbackLData);
          bback.setText(Messages.FrequencyGui_button_back);
          bback.setFont(FontService.getNormalFont());
          bback.setToolTipText(Messages.FrequencyGui_ttip_back);
          bback.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent event) {
                  back();
                }
              });
        }
        {
          bnext = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData button1LData = new FormData();
          button1LData.left = new FormAttachment(0, 1000, 670);
          button1LData.top = new FormAttachment(lsepend, 5);
          button1LData.height = 25;
          button1LData.width = 90;
          bnext.setLayoutData(button1LData);
          bnext.setText(Messages.FrequencyGui_button_next);
          bnext.setFont(FontService.getNormalFont());
          bnext.setToolTipText(Messages.FrequencyGui_ttip_next);
          bnext.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent event) {
                  next();
                }
              });
        }
        {
          boptions = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData boptionsLData = new FormData();
          boptionsLData.left = new FormAttachment(0, 1000, 570);
          boptionsLData.top = new FormAttachment(lsepend, 5);
          boptionsLData.height = 25;
          boptionsLData.width = 90;
          boptions.setLayoutData(boptionsLData);
          boptions.setText(Messages.FrequencyGui_button_options);
          boptions.setFont(FontService.getNormalFont());
          boptions.setToolTipText(Messages.FrequencyGui_ttip_options);
          boptions.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent event) {
                  showOptions();
                }
              });
        }
      }

      prepare();
      this.layout();
    } catch (Exception ex) {
      LogUtil.logError(ex);
    }
  }
Example #15
0
  public static KeyStoreAliasNotifier makeKeyPairByWizard(String keyType) {
    LogUtil.logInfo("NewKeyPairAction"); // $NON-NLS-1$
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    Wizard wizard = new NewKeyPairWizard(keyType);
    WizardDialog dialog = new WizardDialog(shell, wizard);
    dialog.setMinimumPageSize(300, 350);

    final KeyStoreAliasNotifier resultAlias = new KeyStoreAliasNotifier();

    int result = dialog.open();
    if (result == Window.OK) {
      if (wizard instanceof INewKeyWizard) {
        final INewEntryDescriptor nkd = ((INewKeyWizard) wizard).getNewEntryDescriptor();
        final Integer[] argument = new Integer[1];
        final Integer arg = nkd.getKeyLength();
        argument[0] = arg;
        final Integer keyLen = argument[0];
        LogUtil.logInfo("nkd.getKeyLength: " + argument[0]); // $NON-NLS-1$
        Job job = new Job("New Key Pair Job") { // $NON-NLS-1$
              @Override
              protected IStatus run(IProgressMonitor monitor) {
                monitor.beginTask("New KeyPair Task", IProgressMonitor.UNKNOWN); // $NON-NLS-1$
                try {
                  IMetaKeyGenerator gen =
                      AlgorithmsXMLManager.getInstance()
                          .getKeyPairGenerator(nkd.getAlgorithmName());
                  IMetaLength validKeyLengths = gen.getLengths();

                  // Check if entered key length is valid
                  boolean isValidKeyLength = true;
                  if (validKeyLengths != null) {
                    isValidKeyLength =
                        (validKeyLengths.getDefaultLength() == keyLen)
                            || (keyLen >= validKeyLengths.getLowerBound()
                                && keyLen <= validKeyLengths.getUpperBound())
                            || (validKeyLengths.getLengths() != null
                                && validKeyLengths.getLengths().contains(keyLen));
                  }
                  if (!isValidKeyLength) {
                    throw new InvalidAlgorithmParameterException("illegal key length");
                  }

                  AlgorithmParameterSpec spec = null;
                  if (arg != -1) {
                    if (gen.getParameterSpecClassName() != null) {
                      spec =
                          Reflector.getInstance()
                              .instantiateParameterSpec(gen.getParameterSpecClassName(), argument);
                    }
                  }
                  KeyPairGenerator generator = Registry.getKeyPairGenerator(nkd.getAlgorithmName());
                  if (spec != null) {
                    generator.initialize(spec, FlexiProviderKeystorePlugin.getSecureRandom());
                  } else if (arg != -1) {
                    generator.initialize(arg, FlexiProviderKeystorePlugin.getSecureRandom());
                  }
                  KeyPair keyPair = generator.genKeyPair();
                  PrivateKey priv = keyPair.getPrivate();
                  PublicKey pub = keyPair.getPublic();
                  NewKeyPairDescriptor descriptor = new NewKeyPairDescriptor(nkd, priv, pub);
                  resultAlias.notifyAboutAlias(
                      AbstractKeyStoreHandler.addKeyPairStatic(
                          descriptor,
                          ((NewKeyPairDescriptor) descriptor).getPrivateKey(),
                          ((NewKeyPairDescriptor) descriptor).getPublicKey()));
                } catch (NoSuchAlgorithmException e) {
                  LogUtil.logError(
                      FlexiProviderKeystorePlugin.PLUGIN_ID,
                      "NoSuchAlgorithmException while generating a key pair",
                      e,
                      true);
                } catch (InvalidAlgorithmParameterException e) {
                  LogUtil.logError(
                      FlexiProviderKeystorePlugin.PLUGIN_ID,
                      "InvalidAlgorithmParameterException while generating a key pair",
                      e,
                      true);
                } catch (SecurityException e) {
                  LogUtil.logError(
                      FlexiProviderKeystorePlugin.PLUGIN_ID,
                      "SecurityException while generating a key pair",
                      e,
                      true);
                } catch (IllegalArgumentException e) {
                  LogUtil.logError(
                      FlexiProviderKeystorePlugin.PLUGIN_ID,
                      "IllegalArgumentException while generating a key pair",
                      e,
                      true);
                } catch (ClassNotFoundException e) {
                  LogUtil.logError(
                      FlexiProviderKeystorePlugin.PLUGIN_ID,
                      "ClassNotFoundException while generating a key pair",
                      e,
                      true);
                } catch (NoSuchMethodException e) {
                  LogUtil.logError(
                      FlexiProviderKeystorePlugin.PLUGIN_ID,
                      "NoSuchMethodException while generating a key pair",
                      e,
                      true);
                } catch (InstantiationException e) {
                  LogUtil.logError(
                      FlexiProviderKeystorePlugin.PLUGIN_ID,
                      "InstantiationException while generating a key pair",
                      e,
                      true);
                } catch (IllegalAccessException e) {
                  LogUtil.logError(
                      FlexiProviderKeystorePlugin.PLUGIN_ID,
                      "IllegalAccessException while generating a key pair",
                      e,
                      true);
                } catch (InvocationTargetException e) {
                  LogUtil.logError(
                      FlexiProviderKeystorePlugin.PLUGIN_ID,
                      "InvocationTargetException while generating a key pair",
                      e,
                      true);
                } finally {
                  monitor.done();
                }
                return Status.OK_STATUS;
              }

              @Override
              public boolean belongsTo(Object family) {
                return family == KEYSTOREHELPER_FAMILY;
              }
            };
        job.setPriority(Job.LONG);
        job.setUser(true);
        job.schedule();
      }
    } else {
      resultAlias.notifyAboutAlias(null);
    }

    return resultAlias;
  }