Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 4ac9e4e

Browse files
author
Emmanuel Hugonnet
committed
The BASIC AUTH Header is now using ISO-8859-1 like Jackrabbit
git-svn-id: https://www.silverpeas.org/svn/silverpeas/services/office-online/trunk@554 a8e77078-a1c7-4fa5-b8fc-53c5178a176c
1 parent ef34dcb commit 4ac9e4e

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

src/main/java/com/silverpeas/openoffice/windows/webdav/UploadProgressBar.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class UploadProgressBar extends JPanel implements PropertyChangeListener
4848
private JLabel messageLabel;
4949
private boolean display = false;
5050
private JFrame frame = null;
51+
private String title = MessageUtil.getMessage("upload.file.title");
52+
private String outputFormat = MessageUtil.getMessage("upload.file.task");
5153

5254
public UploadProgressBar() {
5355
super(new BorderLayout());
@@ -86,6 +88,14 @@ public void setMinimum(int min) {
8688
progressBar.setMinimum(min);
8789
}
8890

91+
/**
92+
* Defines the minimum value for the progress bar.
93+
* @param min the minimum value for the progress bar.
94+
*/
95+
public void setOutputFormat(String outputFormat) {
96+
this.outputFormat = outputFormat;
97+
}
98+
8999
/**
90100
* Defines the message to be displayed before the progress bar.
91101
* @param message the message to be displayed before the progress bar.
@@ -94,6 +104,25 @@ public void setMessage(String message) {
94104
messageLabel.setText(message);
95105
}
96106

107+
/**
108+
* Defines the title of the progress bar dialog.
109+
* @param title the title of the progress bar dialog.
110+
*/
111+
public void setTitle(String title) {
112+
this.title = title;
113+
if (this.frame != null) {
114+
this.frame.setTitle(title);
115+
}
116+
}
117+
118+
/**
119+
* Defines the title of the progress bar dialog.
120+
* @param title the title of the progress bar dialog.
121+
*/
122+
public void setProgress(int progress) {
123+
propertyChange(new PropertyChangeEvent(this, "progress", 0, progress));
124+
}
125+
97126
/**
98127
* Invoked when task's progress property changes.
99128
*/
@@ -106,7 +135,7 @@ public void propertyChange(PropertyChangeEvent evt) {
106135
}
107136
int progress = (Integer) evt.getNewValue();
108137
progressBar.setValue(progress);
109-
taskOutput.setText(String.format(MessageUtil.getMessage("upload.file.task"),
138+
taskOutput.setText(String.format(outputFormat,
110139
100 * progressBar.getPercentComplete()));
111140
}
112141
}
@@ -116,6 +145,7 @@ public void propertyChange(PropertyChangeEvent evt) {
116145
*/
117146
private void start() {
118147
javax.swing.SwingUtilities.invokeLater(new Runnable() {
148+
119149
@Override
120150
public void run() {
121151
createAndShowGUI();
@@ -137,7 +167,7 @@ public void close() {
137167
*/
138168
private void createAndShowGUI() {
139169
// Create and set up the window.
140-
frame = new JFrame(MessageUtil.getMessage("upload.file.title"));
170+
frame = new JFrame(title);
141171
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
142172
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
143173
this.setOpaque(true); // content panes must be opaque

src/main/java/com/silverpeas/openoffice/windows/webdav/WebdavManager.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@
4949
import javax.swing.ProgressMonitor;
5050
import javax.swing.ProgressMonitorInputStream;
5151
import javax.swing.UIManager;
52+
import org.apache.commons.httpclient.HttpVersion;
5253
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
5354
import org.apache.commons.httpclient.methods.GetMethod;
5455
import org.apache.commons.httpclient.methods.RequestEntity;
56+
import org.apache.commons.httpclient.params.HttpClientParams;
5557
import org.apache.jackrabbit.webdav.DavException;
5658
import org.apache.jackrabbit.webdav.client.methods.PutMethod;
5759
import org.apache.jackrabbit.webdav.client.methods.UnLockMethod;
@@ -77,11 +79,14 @@ public WebdavManager(String host, String login, String password) {
7779
hostConfig.setHost(host);
7880
HttpConnectionManager connectionManager =
7981
new MultiThreadedHttpConnectionManager();
80-
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
82+
HttpConnectionManagerParams connectionParams = new HttpConnectionManagerParams();
8183
int maxHostConnections = 20;
82-
params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
83-
connectionManager.setParams(params);
84-
client = new HttpClient(connectionManager);
84+
connectionParams.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
85+
connectionManager.setParams(connectionParams);
86+
HttpClientParams clientParams = new HttpClientParams();
87+
clientParams.setParameter(HttpClientParams.CREDENTIAL_CHARSET, "ISO-8859-1");
88+
clientParams.setParameter(HttpClientParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
89+
client = new HttpClient(clientParams, connectionManager);
8590
Credentials creds = new UsernamePasswordCredentials(login, password);
8691
client.getState().setCredentials(AuthScope.ANY, creds);
8792
client.setHostConfiguration(hostConfig);

src/test/java/com/silverpeas/openoffice/util/PasswordManagerTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public void testDecodePassword() throws Exception {
5959
String expResult = "helloworld";
6060
String result = PasswordManager.decodePassword(encodedPassword);
6161
assertEquals(expResult, result);
62+
encodedPassword = "4e2bb11fc119471ff3c0ba210d9843d1";
63+
expResult = "héhèhàhh";
64+
result = PasswordManager.decodePassword(encodedPassword);
65+
assertEquals(expResult, result);
6266
}
6367

6468
/**
@@ -69,6 +73,10 @@ public void testEncodePassword() throws Exception {
6973
String expResult = "5f6b7130460e9b316ca968ec952d3fa3";
7074
String result = PasswordManager.encodePassword(password);
7175
assertEquals(expResult, result);
76+
password = "héhèhàhh";
77+
expResult = "4e2bb11fc119471ff3c0ba210d9843d1";
78+
result = PasswordManager.encodePassword(password);
79+
assertEquals(expResult, result);
7280
}
7381

7482
/**

0 commit comments

Comments
 (0)