summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-07-24 14:57:49 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-07-24 14:57:49 +0000
commita52b66cf1d0a579b95cddba44fb4df0e97bf8e22 (patch)
tree684815b87698872b68d5bfd357a4320dbf38e752 /pdf-over-gui/src/main/java/at/asit
parent7b4a747d8a922cb03c8019249217dbf3ff68302a (diff)
downloadpdf-over-a52b66cf1d0a579b95cddba44fb4df0e97bf8e22.tar.gz
pdf-over-a52b66cf1d0a579b95cddba44fb4df0e97bf8e22.tar.bz2
pdf-over-a52b66cf1d0a579b95cddba44fb4df0e97bf8e22.zip
Add proxy authentication
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@465 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java213
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java8
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java108
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java48
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java66
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java14
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java184
11 files changed, 578 insertions, 105 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
index 4c361819..d95fd000 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
@@ -110,6 +110,12 @@ public class Constants {
/** The proxy port config parameter */
public static final String CFG_PROXY_PORT = "PROXY_PORT"; //$NON-NLS-1$
+ /** The proxy username config parameter */
+ public static final String CFG_PROXY_USER = "PROXY_USER"; //$NON-NLS-1$
+
+ /** The proxy password config parameter */
+ public static final String CFG_PROXY_PASS = "PROXY_PASS"; //$NON-NLS-1$
+
/** The output folder config parameter */
public static final String CFG_OUTPUT_FOLDER = "OUTPUT_FOLDER"; //$NON-NLS-1$
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
index 998e5720..20ca737d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
@@ -91,9 +91,15 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
private Text txtProxyHost;
private ErrorMarker proxyHostErrorMarker;
private Label lblProxyPort;
- Text txtProxyPort;
+ private Text txtProxyPort;
+ private ErrorMarker txtProxyPortErrorMarker;
+ private Label lblProxyUser;
+ private Text txtProxyUser;
+ private ErrorMarker proxyUserErrorMarker;
+ private Label lblProxyPass;
+ private Text txtProxyPass;
+ private ErrorMarker proxyPassErrorMarker;
FormData fd_txtProxyPort;
- ErrorMarker txtProxyPortErrorMarker;
FormData fd_txtProxyPortErrorMarker;
@@ -410,16 +416,16 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.grpProxy.setFont(new Font(Display.getCurrent(), fD_grpProxy[0]));
this.lblProxyHost = new Label(this.grpProxy, SWT.NONE);
- GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false,
+ GridData gd_lblProxyHost = new GridData(SWT.LEFT, SWT.CENTER, false,
false, 1, 1);
- gd_lblNewLabel.widthHint = 66;
- this.lblProxyHost.setLayoutData(gd_lblNewLabel);
+ gd_lblProxyHost.widthHint = 66;
+ this.lblProxyHost.setLayoutData(gd_lblProxyHost);
this.lblProxyHost.setBounds(0, 0, 57, 15);
- FontData[] fD_lblNewLabel = this.lblProxyHost.getFont().getFontData();
- fD_lblNewLabel[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ FontData[] fD_lblProxyHost = this.lblProxyHost.getFont().getFontData();
+ fD_lblProxyHost[0].setHeight(Constants.TEXT_SIZE_NORMAL);
this.lblProxyHost.setFont(new Font(Display.getCurrent(),
- fD_lblNewLabel[0]));
+ fD_lblProxyHost[0]));
Composite compProxyHostContainer = new Composite(this.grpProxy, SWT.NONE);
compProxyHostContainer.setLayout(new FormLayout());
@@ -520,6 +526,118 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
}
});
+ this.lblProxyUser = new Label(this.grpProxy, SWT.NONE);
+ GridData gd_lblProxyUser = new GridData(SWT.LEFT, SWT.CENTER, false,
+ false, 1, 1);
+ gd_lblProxyUser.widthHint = 80;
+ this.lblProxyUser.setLayoutData(gd_lblProxyUser);
+ this.lblProxyUser.setBounds(0, 0, 57, 15);
+
+ FontData[] fD_lblProxyUser = this.lblProxyUser.getFont().getFontData();
+ fD_lblProxyUser[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lblProxyUser.setFont(new Font(Display.getCurrent(),
+ fD_lblProxyUser[0]));
+
+ Composite compProxyUserContainer = new Composite(this.grpProxy, SWT.NONE);
+ compProxyUserContainer.setLayout(new FormLayout());
+ compProxyUserContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
+ 1, 1));
+ this.txtProxyUser = new Text(compProxyUserContainer, SWT.BORDER);
+ FormData fd_txtProxyUser = new FormData();
+ fd_txtProxyUser.right = new FormAttachment(100, -42);
+ fd_txtProxyUser.top = new FormAttachment(0);
+ fd_txtProxyUser.left = new FormAttachment(0, 5);
+
+ FontData[] fD_txtProxyUser = this.txtProxyUser.getFont().getFontData();
+ fD_txtProxyUser[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.txtProxyUser.setFont(new Font(Display.getCurrent(),
+ fD_txtProxyUser[0]));
+
+ this.proxyUserErrorMarker = new ErrorMarker(compProxyUserContainer, SWT.NONE, ""); //$NON-NLS-1$
+
+ FormData fd_proxyUserErrorMarker = new FormData();
+ fd_proxyUserErrorMarker.left = new FormAttachment(100, -32);
+ fd_proxyUserErrorMarker.right = new FormAttachment(100);
+ fd_proxyUserErrorMarker.top = new FormAttachment(0);
+ fd_proxyUserErrorMarker.bottom = new FormAttachment(0, 32);
+
+ this.proxyUserErrorMarker.setLayoutData(fd_proxyUserErrorMarker);
+ this.proxyUserErrorMarker.setVisible(false);
+ this.txtProxyUser.setLayoutData(fd_txtProxyUser);
+
+ this.txtProxyUser.addFocusListener(new FocusAdapter() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ processProxyUserChanged();
+ }
+ });
+
+ this.txtProxyUser.addTraverseListener(new TraverseListener() {
+
+ @Override
+ public void keyTraversed(TraverseEvent e) {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ processProxyUserChanged();
+ }
+ }
+ });
+
+ this.lblProxyPass = new Label(this.grpProxy, SWT.NONE);
+ this.lblProxyPass.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER,
+ false, false, 1, 1));
+ this.lblProxyPass.setBounds(0, 0, 57, 15);
+
+ FontData[] fD_lblProxyPass = this.lblProxyPass.getFont().getFontData();
+ fD_lblProxyPass[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lblProxyPass.setFont(new Font(Display.getCurrent(),
+ fD_lblProxyPass[0]));
+
+ Composite compProxyPassContainer = new Composite(this.grpProxy, SWT.NONE);
+ compProxyPassContainer.setLayout(new FormLayout());
+ compProxyPassContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
+ 1, 1));
+ this.txtProxyPass = new Text(compProxyPassContainer, SWT.PASSWORD | SWT.BORDER);
+ FormData fd_txtProxyPass = new FormData();
+ fd_txtProxyPass.right = new FormAttachment(100, -42);
+ fd_txtProxyPass.top = new FormAttachment(0);
+ fd_txtProxyPass.left = new FormAttachment(0, 5);
+
+ FontData[] fD_txtProxyPass = this.txtProxyPass.getFont().getFontData();
+ fD_txtProxyPass[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.txtProxyPass.setFont(new Font(Display.getCurrent(),
+ fD_txtProxyPass[0]));
+
+ this.proxyPassErrorMarker = new ErrorMarker(compProxyPassContainer, SWT.NONE, ""); //$NON-NLS-1$
+
+ FormData fd_proxyPassErrorMarker = new FormData();
+ fd_proxyPassErrorMarker.left = new FormAttachment(100, -32);
+ fd_proxyPassErrorMarker.right = new FormAttachment(100);
+ fd_proxyPassErrorMarker.top = new FormAttachment(0);
+ fd_proxyPassErrorMarker.bottom = new FormAttachment(0, 32);
+
+ this.proxyPassErrorMarker.setLayoutData(fd_proxyPassErrorMarker);
+ this.proxyPassErrorMarker.setVisible(false);
+ this.txtProxyPass.setLayoutData(fd_txtProxyPass);
+
+ this.txtProxyPass.addFocusListener(new FocusAdapter() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ processProxyPassChanged();
+ }
+ });
+
+ this.txtProxyPass.addTraverseListener(new TraverseListener() {
+
+ @Override
+ public void keyTraversed(TraverseEvent e) {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ processProxyPassChanged();
+ }
+ }
+ });
+
reloadResources();
}
@@ -634,6 +752,44 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.configurationContainer.setProxyHost(host);
}
+ void processProxyUserChanged() {
+ try {
+ this.proxyUserErrorMarker.setVisible(false);
+ plainProxyUserSetter();
+ } catch (Exception ex) {
+ this.proxyUserErrorMarker.setVisible(true);
+ this.proxyUserErrorMarker.setToolTipText(ex.getMessage());
+ log.error("processProxyUser: ", ex); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ private void plainProxyUserSetter() {
+ String user = this.txtProxyUser.getText();
+ this.configurationContainer.setProxyUser(user);
+ }
+
+ void processProxyPassChanged() {
+ try {
+ this.proxyPassErrorMarker.setVisible(false);
+ plainProxyPassSetter();
+ } catch (Exception ex) {
+ this.proxyPassErrorMarker.setVisible(true);
+ this.proxyPassErrorMarker.setToolTipText(ex.getMessage());
+ log.error("processProxyPass: ", ex); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ private void plainProxyPassSetter() {
+ String pass = this.txtProxyPass.getText();
+ this.configurationContainer.setProxyPass(pass);
+ }
+
void processProxyPortChanged() {
try {
this.txtProxyPortErrorMarker.setVisible(false);
@@ -705,7 +861,17 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
if (host != null) {
this.txtProxyHost.setText(host);
}
- }
+
+ String user = this.configurationContainer.getProxyUser();
+ if (user != null) {
+ this.txtProxyUser.setText(user);
+ }
+
+ String pass = this.configurationContainer.getProxyPass();
+ if (pass != null) {
+ this.txtProxyPass.setText(pass);
+ }
+}
/*
* (non-Javadoc)
@@ -737,6 +903,11 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
case 2:
this.plainProxyPortSetter();
// Fall through
+ case 3:
+ this.plainProxyUserSetter();
+ // Fall through
+ case 4:
+ this.plainProxyPassSetter();
}
}
@@ -778,17 +949,27 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.cmbLocaleAuswahl.setToolTipText(Messages
.getString("advanced_config.LocaleSelection_ToolTip")); //$NON-NLS-1$
- this.grpProxy.setText(Messages.getString("simple_config.Proxy_Title")); //$NON-NLS-1$
- this.lblProxyHost.setText(Messages.getString("simple_config.ProxyHost")); //$NON-NLS-1$
+ this.grpProxy.setText(Messages.getString("advanced_config.Proxy_Title")); //$NON-NLS-1$
+ this.lblProxyHost.setText(Messages.getString("advanced_config.ProxyHost")); //$NON-NLS-1$
this.txtProxyHost.setToolTipText(Messages
- .getString("simple_config.ProxyHost_ToolTip")); //$NON-NLS-1$
+ .getString("advanced_config.ProxyHost_ToolTip")); //$NON-NLS-1$
this.txtProxyHost.setMessage(Messages
- .getString("simple_config.ProxyHostTemplate")); //$NON-NLS-1$
+ .getString("advanced_config.ProxyHost_Template")); //$NON-NLS-1$
this.lblProxyPort.setText(Messages
- .getString("simple_config.ProxyPort")); //$NON-NLS-1$
+ .getString("advanced_config.ProxyPort")); //$NON-NLS-1$
this.txtProxyPort.setToolTipText(Messages
- .getString("simple_config.ProxyPort_ToolTip")); //$NON-NLS-1$
+ .getString("advanced_config.ProxyPort_ToolTip")); //$NON-NLS-1$
this.txtProxyPort.setMessage(Messages
- .getString("simple_config.ProxyPortTemplate")); //$NON-NLS-1$
+ .getString("advanced_config.ProxyPort_Template")); //$NON-NLS-1$
+ this.lblProxyUser.setText(Messages.getString("advanced_config.ProxyUser")); //$NON-NLS-1$
+ this.txtProxyUser.setToolTipText(Messages
+ .getString("advanced_config.ProxyUser_ToolTip")); //$NON-NLS-1$
+ this.txtProxyUser.setMessage(Messages
+ .getString("advanced_config.ProxyUser_Template")); //$NON-NLS-1$
+ this.lblProxyPass.setText(Messages.getString("advanced_config.ProxyPass")); //$NON-NLS-1$
+ this.txtProxyPass.setToolTipText(Messages
+ .getString("advanced_config.ProxyPass_ToolTip")); //$NON-NLS-1$
+ this.txtProxyPass.setMessage(Messages
+ .getString("advanced_config.ProxyPass_Template")); //$NON-NLS-1$
}
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
index c4691571..fcf3119f 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
@@ -320,6 +320,10 @@ public class ConfigurationComposite extends StateComposite {
} catch (InvalidPortException e) {
log.error("Failed to set proxy port!", e); //$NON-NLS-1$
}
+ this.configurationContainer.setProxyUser(this.configProvider
+ .getProxyUserPersistent());
+ this.configurationContainer.setProxyPass(this.configProvider
+ .getProxyPassPersistent());
this.simpleConfigComposite.loadConfiguration();
this.advancedConfigComposite.loadConfiguration();
@@ -421,6 +425,10 @@ public class ConfigurationComposite extends StateComposite {
.getProxyHost());
this.configManipulator.setProxyPort(this.configurationContainer
.getProxyPort());
+ this.configManipulator.setProxyUser(this.configurationContainer
+ .getProxyUser());
+ this.configManipulator.setProxyPass(this.configurationContainer
+ .getProxyPass());
this.configManipulator.setDefaultEmblem(this.configurationContainer
.getEmblem());
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java
index 58b9e453..68b48242 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java
@@ -76,6 +76,18 @@ public interface ConfigManipulator {
public void setProxyPort(int port);
/**
+ * Sets the proxy username
+ * @param user the proxy username
+ */
+ public void setProxyUser(String user);
+
+ /**
+ * Sets the proxy password
+ * @param pass the proxy password
+ */
+ public void setProxyPass(String pass);
+
+ /**
* Sets the default output folder
* @param outputFolder the default output folder
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java
index 952116ec..e3fec9f5 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java
@@ -61,6 +61,18 @@ public interface ConfigOverlayManipulator {
public void setProxyPortOverlay(int port);
/**
+ * Sets the proxy username
+ * @param user the proxy username
+ */
+ public void setProxyUserOverlay(String user);
+
+ /**
+ * Sets the proxy password
+ * @param pass the proxy password
+ */
+ public void setProxyPassOverlay(String pass);
+
+ /**
* Sets the default output folder
* @param outputFolder the default output folder
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java
index 1adf39e4..91bd5ecf 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java
@@ -85,6 +85,18 @@ public interface ConfigProvider {
public int getProxyPort();
/**
+ * Gets the proxy username
+ * @return the proxy username
+ */
+ public String getProxyUser();
+
+ /**
+ * Gets the proxy password
+ * @return the proxy password
+ */
+ public String getProxyPass();
+
+ /**
* Get the default configured BKU
* @return the default configured BKU
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
index 3225c92d..3010868b 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
@@ -101,6 +101,14 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
this.setProxyHost(config
.getProperty(Constants.CFG_PROXY_HOST));
+ // Set Proxy User
+ this.setProxyUser(config
+ .getProperty(Constants.CFG_PROXY_USER));
+
+ // Set Proxy Password
+ this.setProxyPass(config
+ .getProperty(Constants.CFG_PROXY_PASS));
+
// Set Output Folder
this.setDefaultOutputFolder(config
.getProperty(Constants.CFG_OUTPUT_FOLDER));
@@ -279,6 +287,8 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
props.setProperty(Constants.CFG_PROXY_HOST, this.getProxyHostPersistent());
props.setProperty(Constants.CFG_PROXY_PORT,
Integer.toString(getProxyPortPersistent()));
+ props.setProperty(Constants.CFG_PROXY_USER, this.getProxyUserPersistent());
+ props.setProperty(Constants.CFG_PROXY_PASS, this.getProxyPassPersistent());
props.setProperty(Constants.CFG_EMBLEM, this.getDefaultEmblemPersistent());
props.setProperty(Constants.CFG_SIGNATURE_NOTE, this.getSignatureNote());
props.setProperty(Constants.CFG_MOBILE_NUMBER, this.getDefaultMobileNumberPersistent());
@@ -758,6 +768,104 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
return this.configuration.getProxyPort();
}
+ /**
+ * Sets the proxy username
+ *
+ * @param user
+ * the proxy username
+ */
+ @Override
+ public void setProxyUser(String user) {
+ if (user == null || user.trim().isEmpty()) {
+ this.configuration.setProxyUser(STRING_EMPTY);
+ } else {
+ this.configuration.setProxyUser(user);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigOverlayManipulator#setProxyUserOverlay(java.lang.String)
+ */
+ @Override
+ public void setProxyUserOverlay(String user) {
+ if (user == null || user.trim().isEmpty()) {
+ this.configurationOverlay.setProxyUser(STRING_EMPTY);
+ } else {
+ this.configurationOverlay.setProxyUser(user);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigProvider#getProxyUser()
+ */
+ @Override
+ public String getProxyUser() {
+ String user = this.configurationOverlay.getProxyUser();
+ if (user == null)
+ user = getProxyUserPersistent();
+ return user;
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.PersistentConfigProvider#getProxyUserPersistent()
+ */
+ @Override
+ public String getProxyUserPersistent() {
+ String user = this.configuration.getProxyUser();
+ if (user == null)
+ user = STRING_EMPTY;
+ return user;
+ }
+
+ /**
+ * Sets the proxy password
+ *
+ * @param pass
+ * the proxy password
+ */
+ @Override
+ public void setProxyPass(String pass) {
+ if (pass == null || pass.trim().isEmpty()) {
+ this.configuration.setProxyPass(STRING_EMPTY);
+ } else {
+ this.configuration.setProxyPass(pass);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigOverlayManipulator#setProxyPassOverlay(java.lang.String)
+ */
+ @Override
+ public void setProxyPassOverlay(String pass) {
+ if (pass == null || pass.trim().isEmpty()) {
+ this.configurationOverlay.setProxyPass(STRING_EMPTY);
+ } else {
+ this.configurationOverlay.setProxyPass(pass);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigProvider#getProxyPass()
+ */
+ @Override
+ public String getProxyPass() {
+ String pass = this.configurationOverlay.getProxyPass();
+ if (pass == null)
+ pass = getProxyPassPersistent();
+ return pass;
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.PersistentConfigProvider#getProxyPassPersistent()
+ */
+ @Override
+ public String getProxyPassPersistent() {
+ String pass = this.configuration.getProxyPass();
+ if (pass == null)
+ pass = STRING_EMPTY;
+ return pass;
+ }
+
/*
* (non-Javadoc)
*
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java
index 383f5e9b..486647cc 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java
@@ -81,18 +81,6 @@ public interface ConfigurationContainer {
public void setProxyHost(String host);
/**
- * Gets the signature note
- * @return the signature note
- */
- public String getSignatureNote();
-
- /**
- * Sets the signature note
- * @param note the signature note
- */
- public void setSignatureNote(String note);
-
- /**
* Gets the proxy port
*
* if port is -1 no port is selected
@@ -112,6 +100,42 @@ public interface ConfigurationContainer {
public void setProxyPort(int port) throws InvalidPortException;
/**
+ * Gets the proxy username
+ * @return the proxy username
+ */
+ public String getProxyUser();
+
+ /**
+ * Sets the proxy username
+ * @param user the proxy username
+ */
+ public void setProxyUser(String user);
+
+ /**
+ * Gets the proxy password
+ * @return the proxy password
+ */
+ public String getProxyPass();
+
+ /**
+ * Sets the proxy password
+ * @param pass the proxy password
+ */
+ public void setProxyPass(String pass);
+
+ /**
+ * Gets the signature note
+ * @return the signature note
+ */
+ public String getSignatureNote();
+
+ /**
+ * Sets the signature note
+ * @param note the signature note
+ */
+ public void setSignatureNote(String note);
+
+ /**
* Gets the transparency of the placeholder
* @return transparency of the placeholder (0-255)
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java
index d878f59e..ec79b403 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java
@@ -54,31 +54,37 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
/** The mobile phone number */
protected String mobileNumber = null;
-
+
/** The mobile phone password */
protected String mobilePassword = null;
-
- /** Holds the proxy Host */
+
+ /** Holds the proxy host */
protected String proxyHost = null;
-
- /** Holds the signatureNote */
- protected String signatureNote = null;
-
+
/** Holds the proxy port number */
protected int proxyPort = -1;
-
+
+ /** Holds the proxy username */
+ protected String proxyUser = null;
+
+ /** Holds the proxy password */
+ protected String proxyPass = null;
+
+ /** Holds the signatureNote */
+ protected String signatureNote = null;
+
/** Holds the locale */
protected Locale locale = null;
-
+
/** Holds the signature locale */
protected Locale signLocale = null;
-
+
/** Holds the output folder */
protected String folder = null;
-
+
/** Holds the default BKU to use */
protected BKUs defaultBKU = BKUs.NONE;
-
+
/** Holds the automatic positioning value */
protected boolean automaticPositioning = false;
@@ -225,6 +231,42 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
/* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getProxyUser()
+ */
+ @Override
+ public String getProxyUser() {
+ return this.proxyUser;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setProxyUser(java.lang.String)
+ */
+ @Override
+ public void setProxyUser(String user) {
+ this.proxyUser = user;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getProxyPass()
+ */
+ @Override
+ public String getProxyPass() {
+ return this.proxyPass;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setProxyPass(java.lang.String)
+ */
+ @Override
+ public void setProxyPass(String pass) {
+ this.proxyPass = pass;
+ }
+
+
+ /* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getPlaceholderTransparency()
*/
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java
index ea2c97b1..fe4fceb3 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java
@@ -52,7 +52,7 @@ public interface PersistentConfigProvider {
* @return the emblem
*/
public String getDefaultEmblemPersistent();
-
+
/**
* Gets the proxy host
* @return the proxy hostname or ip address
@@ -66,6 +66,18 @@ public interface PersistentConfigProvider {
public int getProxyPortPersistent();
/**
+ * Gets the proxy username
+ * @return the proxy username
+ */
+ public String getProxyUserPersistent();
+
+ /**
+ * Gets the proxy password
+ * @return the proxy password
+ */
+ public String getProxyPassPersistent();
+
+ /**
* Gets the default output folder for signed documents
* @return the default output folder
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
index d0e9bdfe..ad0658c5 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
@@ -16,6 +16,9 @@
package at.asit.pdfover.gui.workflow.states;
//Imports
+import java.net.Authenticator;
+import java.net.PasswordAuthentication;
+
import org.eclipse.swt.SWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,7 +39,8 @@ import at.asit.pdfover.signator.SignatureParameter;
import at.asit.pdfover.signator.Signer;
/**
- * User waiting state, wait for PDF Signator library to prepare document for signing.
+ * User waiting state, wait for PDF Signator library to prepare document for
+ * signing.
*/
public class PrepareSigningState extends State {
@@ -48,97 +52,145 @@ public class PrepareSigningState extends State {
}
private final class PrepareDocumentThread implements Runnable {
-
+
private PrepareSigningState state;
-
+
/**
* Default constructor
+ *
* @param state
*/
public PrepareDocumentThread(PrepareSigningState state) {
this.state = state;
}
-
+
@Override
public void run() {
try {
-
+
Status status = this.state.stateMachine.getStatus();
-
- ConfigProvider configuration = this.state.stateMachine.getConfigProvider();
-
+
+ ConfigProvider configuration = this.state.stateMachine
+ .getConfigProvider();
+
// SET PROXY HOST and PORT settings
- String proxyHost = configuration.getProxyHost();
- int proxyPort = configuration.getProxyPort();
-
- if(proxyPort > 0 && proxyPort <= 0xFFFF) {
- System.setProperty("http.proxyPort", Integer.toString(proxyPort)); //$NON-NLS-1$
- System.setProperty("https.proxyPort", Integer.toString(proxyPort)); //$NON-NLS-1$
- }
-
- if(proxyHost != null && !proxyHost.isEmpty()) {
+ final String proxyHost = configuration.getProxyHost();
+ final int proxyPort = configuration.getProxyPort();
+ final String proxyUser = configuration.getProxyUser();
+ final String proxyPass = configuration.getProxyPass();
+
+ if (proxyPort > 0 && proxyPort <= 0xFFFF) {
+ System.setProperty(
+ "http.proxyPort", Integer.toString(proxyPort)); //$NON-NLS-1$
+ System.setProperty(
+ "https.proxyPort", Integer.toString(proxyPort)); //$NON-NLS-1$
+ }
+
+ if (proxyHost != null && !proxyHost.isEmpty()) {
System.setProperty("http.proxyHost", proxyHost); //$NON-NLS-1$
System.setProperty("https.proxyHost", proxyHost); //$NON-NLS-1$
- }
-
- if(this.state.signer == null) {
- this.state.signer = this.state.stateMachine.getPDFSigner().getPDFSigner();
}
-
- if(this.state.signatureParameter == null) {
- this.state.signatureParameter = this.state.signer.newParameter();
+
+ if (proxyUser != null && !proxyUser.isEmpty()) {
+ System.setProperty("http.proxyUser", proxyUser); //$NON-NLS-1$
+ System.setProperty("https.proxyUser", proxyUser); //$NON-NLS-1$
+ }
+
+ if (proxyPass != null && !proxyPass.isEmpty()) {
+ System.setProperty("http.proxyPassword", proxyPass); //$NON-NLS-1$
+ System.setProperty("https.proxyPassword", proxyPass); //$NON-NLS-1$
+ }
+
+ if (proxyUser != null && !proxyUser.isEmpty() &&
+ proxyPass != null && !proxyPass.isEmpty()) {
+ Authenticator.setDefault(new Authenticator() {
+ /* (non-Javadoc)
+ * @see java.net.Authenticator#getPasswordAuthentication()
+ */
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ if (getRequestorType() == RequestorType.PROXY) {
+ if (getRequestingHost().equalsIgnoreCase(proxyHost) &&
+ (getRequestingPort() == proxyPort)) {
+ return new PasswordAuthentication(proxyUser,
+ proxyPass.toCharArray());
+ }
+ }
+ return super.getPasswordAuthentication();
+ }
+ });
+ }
+ if (this.state.signer == null) {
+ this.state.signer = this.state.stateMachine.getPDFSigner()
+ .getPDFSigner();
}
-
- this.state.signatureParameter.setInputDocument(new PDFFileDocumentSource(status.getDocument()));
- this.state.signatureParameter.setSignatureDevice(status.getBKU());
- this.state.signatureParameter.setSignaturePosition(status.getSignaturePosition());
-
- if(configuration.getDefaultEmblem() != null && !configuration.getDefaultEmblem().isEmpty()) {
- this.state.signatureParameter.setEmblem(new FileNameEmblem(configuration.getDefaultEmblem()));
+
+ if (this.state.signatureParameter == null) {
+ this.state.signatureParameter = this.state.signer
+ .newParameter();
+ }
+
+ this.state.signatureParameter
+ .setInputDocument(new PDFFileDocumentSource(status
+ .getDocument()));
+ this.state.signatureParameter.setSignatureDevice(status
+ .getBKU());
+ this.state.signatureParameter.setSignaturePosition(status
+ .getSignaturePosition());
+
+ if (configuration.getDefaultEmblem() != null
+ && !configuration.getDefaultEmblem().isEmpty()) {
+ this.state.signatureParameter.setEmblem(new FileNameEmblem(
+ configuration.getDefaultEmblem()));
}
-
- if(configuration.getSignatureNote() != null && !configuration.getSignatureNote().isEmpty()) {
- this.state.signatureParameter.setProperty("SIG_NOTE", configuration.getSignatureNote()); //$NON-NLS-1$
+
+ if (configuration.getSignatureNote() != null
+ && !configuration.getSignatureNote().isEmpty()) {
+ this.state.signatureParameter.setProperty(
+ "SIG_NOTE", configuration.getSignatureNote()); //$NON-NLS-1$
}
-
- this.state.signatureParameter.setSignatureLanguage(configuration.getSignLocale().getLanguage());
-
- this.state.signingState = this.state.signer.prepare(this.state.signatureParameter);
-
+
+ this.state.signatureParameter
+ .setSignatureLanguage(configuration.getSignLocale()
+ .getLanguage());
+
+ this.state.signingState = this.state.signer
+ .prepare(this.state.signatureParameter);
+
} catch (Exception e) {
log.error("PrepareDocumentThread: ", e); //$NON-NLS-1$
this.state.threadException = e;
- }
- finally {
+ } finally {
this.state.stateMachine.invokeUpdate();
}
}
}
-
+
/**
* SFL4J Logger instance
**/
- static final Logger log = LoggerFactory.getLogger(PrepareSigningState.class);
-
+ static final Logger log = LoggerFactory
+ .getLogger(PrepareSigningState.class);
+
SignatureParameter signatureParameter;
-
+
private WaitingComposite waitingComposite = null;
private WaitingComposite getSelectionComposite() {
if (this.waitingComposite == null) {
- this.waitingComposite =
- this.stateMachine.getGUIProvider().createComposite(WaitingComposite.class, SWT.RESIZE, this);
+ this.waitingComposite = this.stateMachine.getGUIProvider()
+ .createComposite(WaitingComposite.class, SWT.RESIZE, this);
}
return this.waitingComposite;
}
-
- at.asit.pdfover.signator.SigningState signingState = null;
+
+ at.asit.pdfover.signator.SigningState signingState = null;
Signer signer;
-
+
Exception threadException = null;
-
+
@Override
public void run() {
WaitingComposite waiting = this.getSelectionComposite();
@@ -149,22 +201,23 @@ public class PrepareSigningState extends State {
Status status = this.stateMachine.getStatus();
- if(this.signatureParameter == null) {
- this.signatureParameter = this.signer.newParameter();
+ if (this.signatureParameter == null) {
+ this.signatureParameter = this.signer.newParameter();
}
- if(this.signingState == null && this.threadException == null) {
+ if (this.signingState == null && this.threadException == null) {
Thread t = new Thread(new PrepareDocumentThread(this));
t.start();
return;
}
- if(this.threadException != null) {
- ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(),
- Messages.getString("error.PrepareDocument"), //$NON-NLS-1$
+ if (this.threadException != null) {
+ ErrorDialog error = new ErrorDialog(this.stateMachine
+ .getGUIProvider().getMainShell(),
+ Messages.getString("error.PrepareDocument"), //$NON-NLS-1$
BUTTONS.RETRY_CANCEL);
this.threadException = null;
- if(error.open() == SWT.RETRY) {
+ if (error.open() == SWT.RETRY) {
run();
} else {
this.setNextState(new BKUSelectionState(this.stateMachine));
@@ -174,10 +227,10 @@ public class PrepareSigningState extends State {
// We got the Request set it into status and move on to next state ...
status.setSigningState(this.signingState);
-
- if(this.stateMachine.getStatus().getBKU() == BKUs.LOCAL) {
+
+ if (this.stateMachine.getStatus().getBKU() == BKUs.LOCAL) {
this.setNextState(new LocalBKUState(this.stateMachine));
- } else if(this.stateMachine.getStatus().getBKU() == BKUs.MOBILE) {
+ } else if (this.stateMachine.getStatus().getBKU() == BKUs.MOBILE) {
this.setNextState(new MobileBKUState(this.stateMachine));
} else {
log.error("Invalid selected BKU Value \"NONE\" in PrepareSigningState!"); //$NON-NLS-1$
@@ -185,7 +238,8 @@ public class PrepareSigningState extends State {
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
*/
@Override
@@ -194,12 +248,14 @@ public class PrepareSigningState extends State {
this.waitingComposite.dispose();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
*/
@Override
public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior();
+ MainWindowBehavior behavior = this.stateMachine.getStatus()
+ .getBehavior();
behavior.reset();
behavior.setActive(Buttons.OPEN, true);
behavior.setActive(Buttons.POSITION, true);