123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- ///////////////////////////////////////////////////////////////////////////
- // Copyright (c) 2016 Intel Corporation. //
- // //
- // All rights reserved. This program and the accompanying materials //
- // are made available under the terms of the Eclipse Public License v1.0 //
- // which accompanies this distribution, and is available at //
- // http://www.eclipse.org/legal/epl-v10.html //
- // //
- // Contributors: //
- // Intel Corporation - initial implementation and documentation //
- ///////////////////////////////////////////////////////////////////////////
- package com.intel.sgx.dialogs;
- import java.io.File;
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- import org.eclipse.swt.SWT;
- import org.eclipse.swt.events.SelectionEvent;
- import org.eclipse.swt.events.SelectionListener;
- import org.eclipse.swt.widgets.FileDialog;
- import org.eclipse.swt.widgets.Shell;
- import org.eclipse.swt.widgets.Text;
- public abstract class TwoStepSignDialogBase extends SGXDialogBase {
- public Text enclaveFileField;
- public Text hashFileField;
- public Text externalSignPublicKeyFileField;
- public Text externalSignedHashFileField;
- public Text outputSignedEnclaveFileField;
- public TwoStepSignDialogBase(Shell parentShell) {
- super(parentShell);
- setShellStyle(SWT.RESIZE | SWT.TITLE);
- this.shell = TwoStepSignDialogBase.this.getParentShell();
-
- }
- // for each field, a corresponding listener
- protected SelectionListener enclaveFileSelectionListener = new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- String result = enclaveFileField.getText();
- FileDialog dialog = new FileDialog(shell, SWT.OPEN);
-
-
-
- dialog.setFilterExtensions(new String[]{"*.so"} );
- dialog.setFilterPath(getCurrentProjectPath().toOSString());
-
- if (result != null && !result.isEmpty()) {
- dialog.setFilterPath(new File(result).getParent());
- } else {
- dialog.setFilterPath(getCurrentProjectPath().toOSString());
- }
-
- result = dialog.open();
-
- enclaveFileField.setText(result);
-
- hashFileField.setText(result + ".hex");
- if (outputSignedEnclaveFileField != null){
- String outputSignedEnclavePath = result;
- if(outputSignedEnclavePath.endsWith(".so"))
- {
- outputSignedEnclavePath =
- outputSignedEnclavePath.substring(0,outputSignedEnclavePath.length() - ".so".length());
- outputSignedEnclaveFileField.setText(outputSignedEnclavePath+".signed.so");
- }
-
- }
-
-
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- }
- };
- protected SelectionListener hashFileSelectionListener = new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- String result = hashFileField.getText();
-
- FileDialog dialog = new FileDialog(shell, SWT.OPEN);
-
- if (result != null && !result.isEmpty()) {
- dialog.setFilterPath(new File(result).getParent());
- } else {
- dialog.setFilterPath(getCurrentProjectPath().toOSString());
- }
-
- result = dialog.open();
-
- hashFileField.setText(result);
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- }
-
- };
-
- protected SelectionListener publicKeyLocationSelectionListener = new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- String result = externalSignPublicKeyFileField.getText();
- FileDialog dialog = new FileDialog(shell, SWT.OPEN);
- dialog.setFilterExtensions(new String [] {"*.pem", "*"});
- dialog.setFilterPath(getCurrentProjectPath().toOSString());
- result = dialog.open();
- externalSignPublicKeyFileField.setText(result);
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- };
-
- protected SelectionListener externalSignedHashFileSelectionListener = new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- String result = externalSignedHashFileField.getText();
- FileDialog dialog = new FileDialog(shell, SWT.OPEN);
- dialog.setFilterPath(getCurrentProjectPath().toOSString());
- result = dialog.open();
- externalSignedHashFileField.setText(result);
- }
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- };
-
- protected SelectionListener outputSignedEnclaveListener = new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- String result = outputSignedEnclaveFileField.getText();
- FileDialog dialog = new FileDialog(shell, SWT.OPEN);
-
-
- dialog.setFilterExtensions(new String[]{"*.so", } );
- dialog.setFilterPath(getCurrentProjectPath().toOSString());
-
- if (result != null && !result.isEmpty()) {
- dialog.setFilterPath(new File(result).getParent());
- } else {
- dialog.setFilterPath(getCurrentProjectPath().toOSString());
- }
-
- result = dialog.open();
-
- outputSignedEnclaveFileField.setText(result);
-
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- }
- };
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- }
-
- }
|